Deadfish/Implementations (M-Z)
← Back to Deadfish#Implementations
Deadfish has been implemented in lots of different languages, both practical and esoteric. This page lists some of them.
Metabox
┌────────────────────────────────────────────────────────────────────────────┐ │┌──────────────────────────────────────────────────────────────────────────┐│ ││┌─────────────────────────────────┐ ││ │││┌───────────────────────────────┐│ ││ ││││┌─────────────────────────────┐││ ││ │││││┌─────────────┐ set variable │││ ││ ││││││start program│ "a" to 0 │││ ││ │││││└─────────────┘ │││ ││ ││││└─────────────────────────────┘││ ││ ││││ set variable "b" to 0 ││ ││ │││└───────────────────────────────┘│ ││ │││ print ">> " & input │ ││ ││└─────────────────────────────────┘ ││ ││ ││ ││ ││ ││ loop (length of input) times ││ ││┌────────────────────────────────────────────────────────────────────────┐││ │││if character (variable │││ │││ "a") of input = o │││ │││ ┌──────────────────┐ │││ │││ │print variable "b"│ │││ │││ └──────────────────┘ │││ │││┌──────────────────────────────────────────────────────────────────────┐│││ ││││┌────────────────────────────────────────────────────┐ ││││ │││││ if character (variable "a") of input = s │ ││││ │││││┌───────────────────────────────────────────────┐ │ ││││ ││││││set variable "b" to variable "b" * variable "b"│ │ ││││ │││││└───────────────────────────────────────────────┘ │ ││││ │││││┌──────────────────────────────────────────────────┐│ ││││ ││││││ if variable "b" = -1 ││ if variable "b"││││ ││││││┌─────────────────────┐ ││ = 256 ││││ │││││││set variable "b" to 0│ ││ ┌────────────┐ ││││ ││││││└─────────────────────┘ ││ │set variable│ ││││ ││││││┌────────────────────────────────────────────────┐││ │ "b" to 0 │ ││││ │││││││┌──────────────────────┐ │││ └────────────┘ ││││ ││││││││if character (variable│ if character (variable │││ ││││ ││││││││ "a") of input = i │ "a") of input = d │││ ││││ ││││││││ ┌───────────────┐ │ ┌───────────────┐ │││ ││││ ││││││││ │set variable │ │ │set variable │ │││ ││││ ││││││││ │"b" to variable│ │ │"b" to variable│ │││ ││││ ││││││││ │"b" + 1 │ │ │"b" - 1 │ │││ ││││ ││││││││ └───────────────┘ │ └───────────────┘ │││ ││││ │││││││└──────────────────────┘ │││ ││││ ││││││└────────────────────────────────────────────────┘││ ││││ │││││└──────────────────────────────────────────────────┘│ ││││ ││││└────────────────────────────────────────────────────┘ ││││ │││└──────────────────────────────────────────────────────────────────────┘│││ ││└────────────────────────────────────────────────────────────────────────┘││ │└──────────────────────────────────────────────────────────────────────────┘│ │ end program │ └────────────────────────────────────────────────────────────────────────────┘
METAFONT
This is limited range due to limit of numbers in METAFONT.
scrollmode; warningcheck:=0; inner end; Q:=0; def Z = if(Q<0)or(Q=256):Q:=0;fi enddef; def i = Q:=Q+1;Z; enddef; def d = Q:=Q-1;Z; enddef; def s = Q:=Q*Q;Z; enddef; def o = message decimal Q; enddef; def h = ;end; enddef;
Minecraft commands
# works in Minecraft 1.19.4-pre1 (and later, hopefully) # this file should be located at data/deadfish/functions/deadfish.mcfunction in a data pack # (for example, see data pack on GitHub: https://github.com/Arctenik/mc-data-packs/tree/main/interpreters/Deadfish) # to use the interpreter, run a command like this to initialize the program in the "code" tag of the deadfish storage: # /data modify storage deadfish code set value "iiisiiisdddddddo" # and then run this function: # /function deadfish:deadfish ##################################### # make sure the scoreboard objective exists scoreboard objectives add deadfish dummy # if a program is stored in the "code" tag, start running that program # move it the the "code_internal" tag and set the accumulator to 0 execute if data storage deadfish code run data modify storage deadfish code_internal set from storage deadfish code execute if data storage deadfish code run scoreboard players set $accumulator deadfish 0 data remove storage deadfish code # if running a program, move its first character to the "command" tag execute if data storage deadfish code_internal unless data storage deadfish {code_internal:""} run data modify storage deadfish command set string storage deadfish code_internal 0 1 execute if data storage deadfish code_internal unless data storage deadfish {code_internal:""} run data modify storage deadfish code_internal set string storage deadfish code_internal 1 # evaluate the command, if it exists and is a valid command execute if data storage deadfish {command:"i"} run scoreboard players add $accumulator deadfish 1 execute if data storage deadfish {command:"d"} run scoreboard players remove $accumulator deadfish 1 execute if data storage deadfish {command:"s"} run scoreboard players operation $accumulator deadfish *= $accumulator deadfish execute if data storage deadfish {command:"o"} run tellraw @a {"score":{"name":"$accumulator","objective":"deadfish"}} data remove storage deadfish command # zero the accumulator as appropriate execute if score $accumulator deadfish matches -1 run scoreboard players set $accumulator deadfish 0 execute if score $accumulator deadfish matches 256 run scoreboard players set $accumulator deadfish 0 # recurse if there's a non-empty program being run execute if data storage deadfish code_internal unless data storage deadfish {code_internal:""} run function deadfish:deadfish
MineFriff
` [MineFriff Deadfish Interpreter] 0,` [The first item in the stack will always be the accumulator] >Ca*62,a*62, oo i` [Output the interpreter prompt and then accept input] r.rI, Cffc, $` [Switch the stack around, adding a star on] v ^>r:Cffc,=?#v!~ >r:I8*8*4,= ?#v.*0,` [Check the 256 requirement] v >:I1-2,=?#~.*0,~ [Check the -1 requirement] ^ >r:Cf*7,=?#v!rI1,+~ [i(ncrement the accumulator)] ^ >:Ca*a,=?#v!rI1,-1~ [d(ecrement the accumulator)] ^ >:Ca*b1,=?#v!r:oCa,o~ [o(utput the accumulator)] ^ >:Ca*b5,=?#v!r:*~ [s(quare the accumulator)] ;
minigolf
0i,nWT*+1,;,nB=,:_n0=,T+_n5=,1+_nF=,:*__::V=sT=+,0*__,_
MIPS Assembly
This code only accepts one lowercase letter at a time as a valid Deadfish command.
.data readable: .asciiz ">> " character: .space 2 # 1 bit + \0 new_line: .asciiz "\n" .text li $t0, 0 # character li $t1, 0 # numeral start_deadfish_loop: la $a0, readable li $v0, 4 syscall la $a0, character li $a1, 2 li $v0, 8 syscall lbu $t0, ($a0) bne $t0, 100, not_d addi $t1, $t1, -1 j end_chars not_d: bne $t0, 105, not_i addi $t1, $t1, 1 j end_chars not_i: bne $t0, 111, not_o la $a0, new_line li $v0, 4 syscall move $a0, $t1 li $v0, 1 syscall j end_chars not_o: bne $t0, 115, end_chars # s mul $t1, $t1, $t1 end_chars: la $a0, new_line li $v0, 4 syscall blt $t1, $zero, set_to_zero beq $t1, 256, set_to_zero end_number_checking: j start_deadfish_loop set_to_zero: li $t1, 0 j end_number_checking
Mirah
no=0 while true do if no==-1 or no==256 then no=0 end print ">> " the_cmd = System.console.readLine() if the_cmd.equals("d") then no=no-1 elsif the_cmd.equals("i") then no=no+1 elsif the_cmd.equals("s") then no=no*no end if the_cmd.equals("o") then puts "#{no}" end end
MIX (Knuth)
Assembly code (the MIXPC assembler; not quite the same as MIXAL):
* DEADFISH ON MIX * PUBLIC DOMAIN * CHANGE TO 64 FOR BINARY COMPUTERS BASE 100 START * STORE CURRENT VALUE IN ACCUMULATOR RESET ENTA 0 * DISPLAY PROMPT AND REQUEST INPUT MAIN CMPA =256= JE RESET OUT PROMPT(19) IN INBUF(19) JBUS *(19) * DISPATCH BY INPUT LD1 INBUF(1:1) DEC1 'D' J1Z OP_D DEC1 'I'-'D' J1Z OP_I DEC1 'O'-'I' J1Z OP_O DEC1 'S'-'O' J1Z OP_S JMP MAIN * DECREMENT OP_D JAZ MAIN DECA 1 JMP MAIN * INCREMENT OP_I INCA 1 JMP MAIN * SQUARE OP_S STA 0 MUL 0 SLAX 5 JMP MAIN * OUTPUT OP_O STA 0 CHAR 1H CMPA ='0'(1:1)=(1:1) JNE 1F SLAX 1 JMP 1B 1H JANZ 1F LDA ='0'(1:1),0(2:5)= 1H STA INBUF STX INBUF+1 OUT INBUF(19) LDA 0 JMP MAIN PROMPT TEXT ">>" FILL PROMPT+14 INBUF FILL *+14 END
Deck (for use with decimal versions of MIX) (note that each card has a space in the first character position):
N O6 A O4 H N ENX E K BU I OALH A. PAEN D LB E AEU ABG G 9 5 7 5 2487 5 5 53971 25 193671 25 9 97 665 1417 695 1417 755 141 5171165 5567 885 19377 555 19347 45 1497 55 1497 75 1497 65 149 647 715 1417 515 14 7 515 397 515 397 5 5 37 515 397 5 1 5 657 515 397 15 1487 15 487 5 5247 55 2 67 5 52471175 956 787 815 8397 775 3971185 5 871 35 5317 5 5 821515 7 5 797 15 2 67 835 44 71 25 52471 25 19377 515 397 5 7 5 927 5 7 5 7 5 7 5 7 5 7 5 7 5 937 5 7 5 7 5 7 5 7 5 7 5 7 5 1 67 5 7 5 7 5 7 5 7 5 7 5 2560 5 1 77 5 7 5 7 5 7 5 7 5 0 5 147 5 5 39
This is the version of the deck for binary computers:
N O6 A O4 H N ENX E K BU I OALH A. PAEN D LB E AEU ABG G 9 5 7 5 1767 136 75597 2623994 7 262392737 178 16 97 18588 417 1916 9 5 517 3 9 9 8 7 235699257 1491917 7 15486897 181 8337 13351217 1072977 647 181123297 138694487 138693837 138693837 5 3237 138693837 5 69 657 138693837 7622567 7621927 5 3447 181 8547 5 3447 3 17148 787 217342157 2 6851277 3 43332 7 275 11837 5 32878695 736 7 5 797 7622787 212582487 26239 327 262399417 138693837 5 7 5 927 5 7 5 7 5 7 5 7 5 7 5 7 5 937 5 7 5 7 5 7 5 7 5 7 5 7 5 1 67 5 7 5 7 5 7 5 7 5 7 5 25675 381648 1 77 5 7 5 7 5 7 5 7 5 75 381648 147 136 7239
MMIX
v GREG 0 LOC Data_Segment buf OCTA 0,0,0,0 buf2 BYTE 0,10,0 arg OCTA buf,1 GREG buf LOC #100 BYTE ">> ",0 G256 GREG #100 % Prompt for and read input Main LDA $255,#100 TRAP 0,Fputs,1 LDA $255,arg TRAP 0,Fread,0 % Set to zero if -1 or 256 ZSP v,v,v CMP $0,v,G256 CSZ v,$0,0 % Check what command has been specified LDBU $0,buf SUB $0,$0,10 BZ $0,Main SUB $0,$0,'d'-10 PBNZ $0,1F % Decrement SUB v,v,1 PBZ $0,2F 1H SUB $0,$0,'i'-'d' PBNZ $0,1F % Increment ADD v,v,1 PBZ $0,2F 1H SUB $0,$0,'o'-'i' PBNZ $0,1F % Output LDA $255,buf2 DIV $1,v,10 3H GET $0,rR ADDU $0,$0,'0' STBU $0,$255 BZ $1,3F SUBU $255,$255,1 DIV $1,$1,10 PBNZ $255,3B 3H TRAP 0,Fputs,1 PBZ $1,2F 1H SUB $0,$0,'s'-'o' PBNZ $0,1F % Square MUL v,v,v PBZ $0,2F 1H ADD $0,$0,'s'-'h' BNZ $0,2F % Halt TRAP 0 % Skip the rest of the input line 2H LDA $255,arg TRAP 0,Fread,0 LDBU $0,buf SUB $0,$0,10 PBNZ $0,2B PBZ $0,Main
MNNBFSL
Currently, all instructions must be on a single line.
[ _ <[<[-"]++++++">>[<[-"]<<-[>"<-"][]>[[-<<<+>>>"][]"][]<[<_[->+<"][]>"+_ ]_+">++++]_checked if acc = 1 under 0> <"[<[-"]++++"">>>[<[-"]<<-[>"<-"][]<-[>>>[<[-"]<<-[>"<-"][]>[[-<<<+>>>"][]"][]<<-"][][->+<"][][->-<"]_ [<[-"]++++++">>[<[-"]<<-[>"<-"][]>[[-<<<+>>>"][]"][]<[<_[->+<"][]>[]_ ][-"]">++++] checked if acc = 256 >_ ,_+[-"][][<[-"]++++++++++">>[<[-"]<<-[>"<-"][]>[[-<<<+>>>"][]"][]<[->-<"] [++++++++++">>[<[-"]<<-[>"<-"][]>[[-<<<+>>>"][]"][]<<[->+<"][]>"_ ]<->++">] checked if command = d _ _ -----_ [<[-"][++++++++++">>[<[-"]<<-[>"<-"][]>[[-<<<+>>>"][]"][]<<[->+<"][]>"_ ]<+>++">] checked if command = i _ _ ------_ [<[-"][++++++++++">>[<[-"]<<-[>"<-"][]>[[-<<<+>>>"][]"][]<<[->+<"][]>"_ ]<".>++">] checked if command = o_ _ ----_ [<[-"][++++++++++">>[<[-"]<<-[>"<-"][]>[[-<<<+>>>"][]"][]<<[->+<"][]>"_ ]<">>[<[-"]<<-[>"<-"][]>[[-<<<+>>>"][]"][]<>++">] checked if command = ^2
Nim
var a = 0 while true: if a == -1 or a == 256: a = 0 write(stdout, ">> ") case readLine(stdin) of "d": a -= 1 of "i": a += 1 of "o": echo(a) of "s": a = a * a
Nqubl
Implementation by User:David.werecat, interprets only one instruction per line.
# " >>"E GT3S3T0T0T0T0S0 #G~10~=KX}{# "i"=!KX}S2MS0# "d"=!KX}S2DS0# "s"=!KX}S2T3S4~0~]#S3T0S0~0~=KX}S3DS2T0S4T0S0+T4{#S4T2S0# "o"=!KX}S2NS0~10~P# S2T0T0S0 ~256~=!KX}S2~0~S0# ~-1~=!KX}S2~0~S0# [[[[[[[[{
Numbers
20 0 20 100 35 11 24 40 42 17 20 1 21 11 42 44 20 5 25 11 24 40 42 31 20 1 21 10 42 44 20 6 25 11 24 40 42 42 30 42 44 26 12 42 3
OASYS (OAC)
class player {} property int dummy int value method check { if value == -1 or value == 256 value = 0 } method increment verbs {{i} {x}} { value = value + 1 this check } method decrement verbs {{d}} { value = value - 1 this check } method square verbs {{s} {k}} { value = value * value this check } method output verbs {{o} {c}} { print value print "\n" } method init { player = create player }
OASYS Assembler
[&]%@*> ['I'X]%#%#<UP>+&CHK ['D]%#%#<DN>+&CHK ['S'K]%#%#<%#<MUL>+&CHK ['O'C]%#<PI CR [&CHK]%#<-1EQ/%#<256EQ/ RP:%#0>
Obfuscated C
Implementation by User:David.werecat, interprets only one instruction per line.
#include <stdio.h> #define A case #define B(x,y) A x:;y;R; #define C "%c" #define D(x) O(S,x);S(x) #define E(x) O(while,x){ #define F(x,y,z) x(y,z); #define G getchar() #define H char #define I "%i" #define J main #define K(x,y,z) x y z #define L printf #define M }}}} #define N "\n" #define O(x,y) x(y) #define P(x) F(L,I N,x) #define Q(x,y) K(x,=,y) #define R break #define S(x) F(L,C,x) #define T(x) O(if,x){ #define U(x) O(switch,x){ #define V void #define W int #define X(x,y) x y #define Y(x) K(x,!=,10) #define Z(x) Q(x,0); V J(){W Z(a)H m;E(1)D(K((K(30,+,1)),<<,1))F(Q,m,G)U(m)B(K(3,*,K(5,*,7)),X(a,++))B(K((K(5,*,5)),<<,2),X(a,--))B(111,P(a))B(K(5,*,23),K(a,*=,K(a,^,0)))}T(K((K(a,<,0)),|,(K(a,==,(K(1,<<,8))))))Z(a)}T(Y(m))E(Y(G))M
OCaml
let rec loop (x', s) : (int * string) -> unit = print_string (s ^ ">> "); let line = read_line () in let c = if String.length line > 0 then line.[0] else '?' in let x = match x' with (-1 | 256) -> 0 | _ -> x' in loop (match c with | 'i' -> (x+1, "") | 'd' -> (x-1, "") | 'o' -> (x, string_of_int x ^ "\n") | 's' -> (x*x, "") | _ -> (x, "\n") ) let _ = loop (0, "")
OLNMLN
j0006A?p0000#p0000ij0006Fcˇi=GIGcˇd=HDHcˇs=JSJcˇo=KOKp0000=LALˇ{^rj0007Zr@p-001=QWQ@p0256=EREj0006YFI.ZD,ZS@@*#ZO&ZW.YRp0000#Y
ONE WAY![](/w/images/thumb/2/2c/Oneway.png/100px-Oneway.png)
second push 0 push true push type push true while push ">> print input split dupe push type equal not while dupe push "h equal if drop push true while push type equal not push false else dupe push "d equal if second dupe push 0 equal not if dupe push 257 equal if drop push 0 else push -1 add else dupe push "i equal if second dupe push 255 equal if drop push 0 else push 1 add else dupe push "o equal if second dupe repr print push "\n print else second dupe push 16 equal if drop push 0 else dupe multiply drop dupe push type equal not dupe push type equal
OOLANG
In this interpreter added instruction "h", to end execution.
x.0.set; a.label; a.Input code:..in; x>256.31.5.ifa; x<0.31.7.ifa; a==i.9.12.ifa; x.inc; a.goto; a==d.14.17.ifa; x.dec; a.goto; a==s.19.22.ifa; x.x.mul; a.goto; a==o.24.27.ifa; x.get; a.goto; a==h.29.29.ifa; .halt; x.0.set; a.goto;
Pair
Set output_as_string
to true
if you want unicode output instead of integer list.
output_as_string = false main src = format_output | reverse | index 1 | exec_state (map_m run src) [int_0, ""] format_output = ite output_as_string (map | dot int_val abs) | show_list show_int run x = index (elem_index' x "idso") inst_funcs inst_funcs = [increment, decrement, square, output] normalize n = ite (elem n [int_neg_1, mk_int 0 256]) int_0 n modify_val f = modify' 0 | dot normalize f increment = modify_val inc_int decrement = modify_val dec_int square = modify_val | pow_int' | mk_int 0 2 output = bind (get' 0) | dot (modify' 1) cons
Parse this sic
Prompts the user to input a one-line idso Deadfish program. Outputs are separated by spaces (" ").
-((dominate&&(*)))/(**)(&)|/(&*) |&((ditto&(times&G&G&)(*)))/(**)(&) /*&(((p&(dominate&p&1&)&)p&))((ditto&H&(*)))/= /*((ditto&(c&(*)I&)iI&))/(**)((ameliorate&*1&))| /*((ditto&(c&(*)D&)dD&))/(**)((dominate&*1&))_|&| /*((ditto&(c&(*)S&)sS&))/(**)((times&(*)*))_|&| /*((ditto&(c&(*)O&)oO&))/(**)(walking&(651&&)&)*_|&| /(**)_|&(2&)+((*))&/|/( &)/**( &)=/**(0 &)= |((dominate&(*)(times&(spaces&(*)A&)A&)))/| /*( &0& &)|((dominate&(*)1&))/*( &* &)_|&|/**( &1& &) |&((spaces&*A&))_+(((()&%&deeccus)))(&1&&p)&H%
Pascal
PROGRAM deadfish (INPUT, OUTPUT); VAR cmd: CHAR; acc: INTEGER; BEGIN acc := 0; REPEAT WRITE(‘>>’); READLN(cmd); CASE cmd OF ‘i’ : acc := acc+1; ‘d’ : acc := acc-1; ‘s’ : acc := SQR(acc); ‘o’ : WRITELN(acc); END; IF acc<0 THEN acc := 0; IF acc=256 THEN acc := 0; UNTIL cmd=‘h’; END.
Path
┐ ┌$$$┐ ├256JJ=1^┐ ├~:001jj±-&-%v$$$$:501jj±-&-%v$$$$:111jj±-&-%v$$$$:115JJ±-&-%v┐ │ ┌─┘ 0 ┌-$v1$$$$$┘ │ │ ││ │ └$$$$┘ │ │ │ │ ││ └──────────────┤ └─$─$─0─┬────────+$$$$$┘ │ ││ └──────────┤ ┌─────────p.:$$$$$┘ ││ └────────────┤ ┌──────────×:$$$$$┘│ └───────────────┤ │ └─────────────$$$$$┘
Perl
#!/usr/bin/perl -w my $acc=0; while (1) { print ">> "; $_ = <>; if ($acc==-1 or $acc==256) { $acc=0; } if (/^i$/) { $acc++; } elsif (/^d$/) { $acc--; } elsif (/^o$/) { print $acc, "\n"; } elsif (/^s$/) { $acc*=$acc; } else { print "\n"; } }
Pike
A terrible oversight (that of not having a Pike Deadfish) has now been corrected. ;)
// Deadfish in Pike (Pike v8.0 release 702), version 1 -- dnm 2023-11-08 int a = 0; int main() { while(1) { write(">> "); string in = Stdio.stdin->gets(); array(string) chars = in/""; foreach(chars ;; string char) { switch(char) { case "i": a = a + 1; break; case "d": a = a - 1; break; case "s": a = a * a; break; case "o": write(a + "\n"); break; } if((a == 256) || (a < 0)) { a = 0; } } } }
Plurple
xkcd only.
ooc:Used targets as input. create ranged number acc. fight:@targets. attack (acc<0 or acc==256); hit: acc is 0. done. menu target. option:"x". acc up. option:"d". acc down. option:"k". acc is (acc ^ 2). option:"c". say acc. done. grind yes. ooc:this is valid. done.
Postrado
And now it's time to pack everything up Thanks for 0 ac Oh. And don't forget the. BOOKFISH Three, two, one 1 I remember some memories with it £ [Thanks for I think the bus is titled in Why? Because in is i Everybody down the stairs ac [ac + 1] £ Why? Because in is d Everybody down the stairs ac [ac - 1] £ Why? Because in is s Everybody down the stairs ac [ac * ac] £ Why? Because in is o Oh. And don't forget the. ac] £ I'M QUIT
PostScript
% Run with: gs -q -dNODISPLAY deadfish.ps /C << (i) {1 add} (d) {1 sub} (h) {quit} (o) {dup =} (s) {dup mul} >> def 0 { (>> ) print flush C (%lineedit) (r) file 1 string readstring pop get exec dup 256 eq {pop 0} if dup 0 lt {pop 0} if } loop
PowerShell
$instructions = Read-Host "Commands" $accumulator = 0 $outputaschar = $true $instruction = 0 while ($instruction -le $instructions.Length) { if ($instructions[$instruction] -eq "i") {$accumulator = ($accumulator + 1) % 255} if ($instructions[$instruction] -eq "d") {$accumulator = ($accumulator - 1) % 255} if ($instructions[$instruction] -eq "s") {$accumulator = ($accumulator * $accumulator) % 255} if ($instructions[$instruction] -eq "o") { if ($outputaschar -eq $true) { [char]$characcumulator = [char]$accumulator Write-Host -NoNewline -Object $characcumulator } else { Write-Host $accumulator } } $instruction = $instruction + 1 }
PowerShell deadfish interpreter, made by Yurkapotam
Prolog
deadfish(Prog, I) :- when((ground(Prog);ground(ProgList)), atom_chars(Prog, ProgList)), when((ground(I);ground(Digits)), number_chars(I, [Digit | Digits])), phrase(deadfish(ProgList, 0), [Digit | Digits]). deadfish([], _) --> []. deadfish([o | Prog], I) --> { I >= 0, number_chars(I, Digits) }, Digits, deadfish(Prog, I). deadfish([i | Prog], I) --> { I1 is I + 1, deadfish_(I1, I2) }, deadfish(Prog, I2). deadfish([d | Prog], I) --> { I1 is I - 1, deadfish_(I1, I2) }, deadfish(Prog, I2). deadfish([s | Prog], I) --> { I1 is I * I, deadfish_(I1, I2) }, deadfish(Prog, I2). deadfish_(I, I) :- dif(I, -1), dif(I, 256). deadfish_(-1, 0). deadfish_(256, 0).
This prolog implementation is fully pure and can be used to evaluate, generate and test deadfish programs.
Pure
using system; fish a "i" = a+1; fish a "d" = a-1; fish a "s" = a*a; fish a "o" = a when puts (str a) end; limit a = if a == 256 || a < 0 then 0 else a; main a = (printf "%s " ">>") $$ (main (fish (limit a) (gets))); main 0;
Python
""" Deadfish Programming Language Interpreter Programmed by Jonathan Todd Skinner This code is hereby released into the public domain Harry eased the mess """ # Initialization accumulator = 0 # Main program loop while True: # Get user input cmd = raw_input('>> ') if accumulator == 256 or accumulator == -1: # Overflow, reset accumulator accumulator = 0 # Process input if cmd == 'i': accumulator += 1 # Increment elif cmd == 'd': accumulator += -1 # Decrement elif cmd == 'o': print accumulator # Output elif cmd == 's': accumulator *= accumulator # Square else: print 'Unrecognized command.'
A shorter one by User:None1 that uses the built-in function exec()
:
exec('x=0\n'+'\n'.join([{'i':'x+=1','d':'x-=1','s':'x*=x','o':'print(x%256)'}[i] for i in input()]))
Python 3.x
#!/bin/env python3 ''' Deadfish Interpreter written in python3. Written by chill0r. Everything is free to use - no restrictions. Startup arguments: -strict: Output errors (and abort) on invalid characters and Overflow -p program: Execute program (does not exit if not told so) Accepted characters (case sensitive!): i / x: increment by 1 d: decrement by 1 s / k: square o / c: print accumulator h: exit interpreter (and stop program) (non standard) r: reset accumulator to 0 (non standard) ''' import sys class DeadfishError(Exception): def __init__(self, message): print(message) sys.exit(1) prog = sys.argv[sys.argv.index('-p')+1] if '-p' in sys.argv else None strict = '-strict' in sys.argv acc = 0 i = 0 print('''Python3 Deadfish interpreter version 0.1''') while True: if not bool(prog): prog = input('>>') for char in prog: if strict and not char in ['i', 'x', 'd', 's', 'k', 'h', 'o', 'c', 'r']: raise DeadfishError('Invalid character {} at index {}'.format(char, i)) if char in ['i','x']: acc += 1 elif char == 'd': acc -= 1 elif char in ['s', 'k']: acc *= acc elif char == 'h': print('Long live the fish!') sys.exit(0) elif char == 'r': acc = 0 if acc < 0 or acc == 256: if strict: raise DeadfishError('Overflow at char {} (Index {}) accumulator = {}'.format(char, i, acc)) else: acc = 0 if char in ['o', 'c']: print(acc) i += 1 prog = None i = 0
another one:
#Deadfish Interpreter by User:Asdf (Prints X when error) a=0 while 1: c=input() if a==256 or a<0: a=0 if c=='i': a+=1 elif c=='d': a-=1 elif c=='o': print(a) elif c=='s': a*=a else: print('X')
Yet another one by User:Tux1
accumulator = 0 while True: command = input(">> ") if accumulator == 256 or accumulator == -1: accumulator = 0 if command == "i": accumulator += 1 elif command == "d": accumulator -= 1 elif command == "s": accumulator **= 2 elif command == "o": print(accumulator)
And another one with built in halting... -User:Myoitzi
string = input() run = 1 a = 0 num = 0 maxnum = len(string) while run == 1: if a == -1: a = 0 if a == 256: a = 0 if num < maxnum: if string[num] == 'i': a = a+1 num = num+1 elif string[num] == 'd': a = a-1 num = num+1 elif string[num] == 's': a = a*a num = num+1 elif string[num] == 'o': print(a) num = num+1 else: num = num+1 else: run = 0
QuickBasic/QBasic/QB64
Takes input as arguments from the command-line.
PRG$ = COMMAND$ FOR I& = 0 TO LEN(PRG$) SELECT CASE MID$(PRG$, I&, 1) CASE "i": A% = A% + 1 CASE "d": A% = A% - 1 CASE "s": A% = A% * A% CASE "o": PRINT CHR$(A%); CASE "h": SYSTEM CASE ELSE: PRINT END SELECT IF (A% AND 255) <> A% THEN A% = 0 'A less resource-intensive way of checking if it is not equal to NEXT
R
n <- 0 while(TRUE) { if(n==-1 || n==256) n <- 0 cmd <- scan(n=1,what='character') fun <- switch(cmd, d=function(x) x-1, i=function(x) x+1, o=function(x) { cat(x,"\n"); x }, s=function(x) x*x) if(!is.null(fun)) n <- fun(n) }
Another interpreter:
#This uses normal commands, xkcd commands, and h. num <- 0 # accumulator keep_going <- TRUE # indicates to keep going while(keep_going){ # Cat prints formatted strings. cat('Enter code:') # You can add one whole line of code. # The line can include spaces and ends at a newline entered_code <- scan(nlines=1,what='character') # This allows the members of the character vector # to be interpreted as a single string. entered_code <- paste(entered_code, collapse = " ") # This for-loop analyses each command. for(pointer in 1:nchar(entered_code)){ letter <- substr(entered_code,pointer,pointer) # This outputs each input command. cat(paste('>> ',letter,'\n',sep='')) if(letter %in% c("i","x")){num <- num + 1} else if(letter %in% c("s","k")){num <- num * num} else if(letter %in% c("o","c")){cat(paste(num,'\n',sep=''))} else if(letter == "d"){num <- num - 1} else if(letter == "h"){keep_going <- FALSE;break} if(num == -1 | num == 256){num <- 0} } }
Raku
use v6.d; # set accumulator as a defined integer my Int:D $acc = 0; # loop forever loop { # get a line of input with a prompt of >> my Str:D $input = prompt ">> "; # iterate and map a function over each character $input.comb.map(-> $command { # switch statement with pattern matching and no fallthrough given $command { # check if command is either "i" or "x" and increment acc when "i" | "x" { ++$acc } # decrement acc when "d" { --$acc } # square acc when "s" | "k" { $acc **= 2 } # print acc with newline when "o" | "c" { say $acc } # exit with exit status 0 when "h" { exit } } # set acc to 0 if it is -1 or 256 after command $acc = $acc == -1 | 256 ?? 0 !! $acc }) }
REBOL 3
f: does [if a = -1 or (a = 256) [a: 0]] d: [ any [ ["i"|"x"] (++ a f) | ["d"] (-- a f) | ["s"|"k"] (a: a * a f) | ["o"|"c"] (print a) | skip ] ] a: 0 forever [parse (ask ">>") d]
Rexx
Derived from Deadfish in Zeno (in turn derived from Deadfish in Turing, a.k.a. "Deadfish in Deadfish"), then modified slightly with respect to whitespace to make it "reasonably" compact.
/* Deadfish in Rexx -- dnm 2021-06-04 */ accumulator = 0 do forever if (accumulator = 256) | (accumulator < 0) then accumulator = 0 call charout ,">> " ; parse pull command select when command == "i" then accumulator = accumulator + 1 when command == "d" then accumulator = accumulator - 1 when command == "s" then accumulator = accumulator * accumulator when command == "o" then say accumulator otherwise say "Unrecognized command" end end
Ruby
#!/usr/bin/env ruby n = 0 while true print '>> ' gets.chomp.each_char do |c| n = 0 if [-1, 256].include?(n) case c when 'd' then n -= 1 when 'i' then n += 1 when 'o' then puts n when 's' then n *= n end end end
Here is an implementation that doesn't return an error, and produces more clear output, by Areallycoolusername.
acc = 0 i = nil while i != 'h' print '>> ' i = gets.chomp if i == 'i' then acc += 1 puts "\n" end if i == 'd' then acc -= 1 puts "\n" end if i == 's' then acc *= acc puts "\n" end if i == 'o' then puts "#{acc}\n" end if acc < 0 || acc == 256 then acc = 0 end end
Rust
use std::io::{self, Write}; fn main() -> io::Result<()> { let stdin = io::stdin(); let mut input = String::new(); let mut acc: i64 = 0; loop { print!(">> "); io::stdout().flush()?; input.clear(); stdin.read_line(&mut input)?; for ch in input.chars() { match ch { 'i' => acc += 1, 'd' => acc -= 1, 'o' => println!("{acc}"), 's' => acc *= acc, _ => println!(), } } if acc < 0 || acc == 256 { acc = 0; } } }
Robin
Runs under Robin 0.3 to (at least) Robin 0.7. Requires stdlib to be loaded before running. Does not accept more than one command per line.
(reactor (line-terminal) 0 (macro (self args env) (bind event (head args) (bind event-type (head event) (bind event-payload (head (tail event)) (bind prev-state (head (tail args)) (bind state (if (equal? prev-state (subtract 0 1)) 0 (if (equal? prev-state 256) 0 prev-state)) (bind prompt (macro (self args env) (bind show (eval env (head args)) (bind state (eval env (head (tail args))) (if show (list state (list (literal writeln) (itoa state)) (list (literal write) (literal ''>> ''))) (list state (list (literal write) (literal ''>> ''))))))) (choose ((equal? event-type (literal init)) (prompt #f state)) ((equal? event-type (literal readln)) (bind letter event-payload (choose ((equal? letter (literal ''d'')) (prompt #f (subtract state 1))) ((equal? letter (literal ''i'')) (prompt #f (subtract state (subtract 0 1)))) ((equal? letter (literal ''s'')) (prompt #f (multiply state state))) ((equal? letter (literal ''o'')) (prompt #t state)) (else (prompt state))))) (else (list state)))))))))))
Rockstar
The beginning is perfection. Perfection is an alert fisher. The end is perfection. Desperate is a mysterious individual. Burn it. Innocent is a respectful horse. Burn it. Savage are a contestant's words. Burn it. Honest is a proposition unfulfilled. Burn it. Listen to the fish. Cut it. The man is respectful. While the man is weaker than the fish, let the story be the fish at the man if the story is innocent build the end up if the story is desperate knock the end down if the story is savage let the end be of the end if the story is honest say the end if the end is weaker than the beginning the end is perfection if the end is perfection the end is perfection Build the man up
Röda
{i=0;chars|{|k|i++if[k="i"];i--if[k="d"];i*=i if[k="s"];print i if[k="o"];i=0 if[i=-1 or i=256]}_}
Sakana
i増作d減作s乗作o出作コ魚繰作
The language defined by the Revised Revised Revised Revised Revised Report on the Algorithmic Language Scheme
(define (execute n cmd) (case cmd ((#\i) (+ n 1)) ((#\d) (- n 1)) ((#\s) (* n n)) ((#\o) (display n) (newline) n) (else n))) (define (deadfish n) (let ((char (read-char))) (cond ((or (= n -1) (= n 256)) (deadfish 0)) ((eof-object? char) n) (else (deadfish (execute n char)))))) (deadfish 0)
Scratch 3.0
Seabass
iisibCmbCZbmbbCZbmbbbCZbmbbbbCbcazZZxnzZaCaczciZxbbIIIIZnzZaCaczciiiZxaxzcaxziibIIIIbIIIZTaxzcaxziiibIIIIbIIIZTaxzcaxziiiibIIIIbIIIZTaxzcaxzbbIIIIZTzZaCaczcbIZxbIbIIIIZnzZaCaczcibIZxbbIIIIZnzZaCaczciibIZxbIIIbIIIIZnzZaCaczciiibIZxibIIbIIIIZnzZaCaczciiiibIZxnzZaCaczcbIIZxnzZaCaczcibIIZxbIbbIIZnzZaCaczciibIIZxaxzcaxziibIIbIIZTaxzcaxziibIIbIIZTzZaCaczciiibIZ;zZaCaczciibIIZxiiiZQzZaCaczciibIZ;zZaCaczcixlxaaxzcxlaaxz{zZaCaczciiiiZxnzZaCaczcxlaCzxiii#aCzxiiiiad=i>.izxT>zZaCaczcbIZxlxaaxzciiiixlaaxz=zZaCaczciiiibIZxlinzZaCaczc>zZaCaczcibIZxlxaaxzciiiixlaaxz=zZaCaczciiiibIZxldnzZaCaczc>zZaCaczciibIZxlxaaxzciiiixlaaxz=zZaCaczciiiibIZxlsfzZaCaczc>zZaCaczciiibIZxlxaaxzciiiixlaaxz=zZaCaczciiiibIgOzZaCaczc>zZaCaczcbIIZxlxaaxzciiiibIZxlaaxz=zZaCaczcbIIZxlaCzxiiiibIZxfzZaCaczc>zZaCaczcibIIZxlxaaxzciiiibIZxlaaxz=zZaCaczcibIIZxlaCzxiiiibIZxfzZaCaczc>zZaCaczcZxlinzZaCaczciibIZjzZaCaczc>zZaCaczcZxnzZaCaczciiibIZjzZaCaczc
(GNU) sed
Takes input on separate lines.
G s/i./;/ s/d.;\?// /o/{g :b;s/\n\?;\{10\}/;\n/;tb s/$/0123456789w/mg :a;s/;\w//;ta s/\B\w*\n*//gp x} /s/{g;:c;/^;/G;s///;tc;s/\n//g} s/^;\{256\}$//;x;d
Seed7
This version includes the optional halt command (for if this was not included, you would need to press Ctrl+C, then *
, to exit the interpreter. Or enter a blank line to make it crash.) This is not really conformant as the spec says that errors are ignored
$ include "seed7_05.s7i"; include "stdio.s7i"; var boolean: keep_going is TRUE; var integer: accumulator is 0; var string: command is ""; const proc: main is func begin while keep_going do if accumulator = 256 or accumulator < 0 then accumulator := 0; end if; write(">> "); readln(command); case command[1] of when {'s'}: accumulator := accumulator * accumulator; when {'o'}: writeln(accumulator); when {'i'}: accumulator := accumulator + 1; when {'d'}: accumulator := accumulator - 1; when {'h'}: keep_going := FALSE; otherwise: writeln("STOP CONFUSING ME"); end case; end while; end func;
A more awesome version of this implementation would use Seed7's ability to create new program structures.
S-Lang
#!/usr/bin/env slsh variable l=" ", n=0, r; forever { if (n==-1||n==256) n=0; r=fputs(">> ", stdout); r=fgets(&l, stdin); switch (l[0]) { case 'd': n--; } { case 'i': n++; } { case 'o': print(n); } { case 's': n=n*n; } } }
Protip 1: if you do not do something with the result of fputs
and fgets
(assign them to the scratch variable r
in this case), slsh
eventually runs out of stack space.
Protip 2: the braces in the above program are not matched correctly. slsh
does not seem to care.
Selt
# https://esolangs.org/wiki/Deadfish loop: print \>\>\ input = @stdin index = 0 goto inloop~(@input != `) # jump to end when input is empty inloop1: goto @input.@index # go to the label corresponding to each command i:val = @val+1 goto end d:val = @val-1 goto end s:val = @val*@val goto end o:println @val goto end end:goto reset~((@val == \-1) || (@val == 256)) reset1:val = 0 reset0: index = @index+1 goto inloop~(@index < ?@input) inloop0: goto loop index:0 val:0 input:
Shakespeare
Tested on the tio.run implementation. Written by User:BoundedBeans
A Shakespearean Depiction of a Deceased Fish; ---------------------------------------------------- This is a Deadfish interpreter written in Shakespeare; End the program with a pipe character ('|'); Methinks this is the end of this wretched commentary. Romeo, the program stack. Lady Macbeth, a helper stack. Juliet, the register. Hamlet, for checking ASCII codes. Act I: The lone wolf act (other than halting). Scene I: Startup. [Enter Romeo and Lady Macbeth] Lady Macbeth: You are nothing! Remember yourself! Romeo: You are nothing! Remember yourself! [Exit Lady Macbeth] [Enter Juliet] Romeo: You are nothing! Let us proceed to Scene II. Scene II: The input loop. [Exeunt] [Enter Romeo and Lady Macbeth] Romeo: Open your mind! [Exit Romeo] [Enter Hamlet] Lady Macbeth: You are the difference between a big big big big big big big cat and a big big cat! Am I as good as you? Hamlet: If so, let us proceed to Scene III. Remember yourself! Lady Macbeth: Let us proceed to Scene II. Scene III: Transfer stack from Lady Macbeth to Romeo to reverse the input data. [Exeunt] [Enter Romeo and Lady Macbeth] Romeo: Recall your wretched nightmare! Lady Macbeth: Am I as good as nothing? Romeo: If so, let us proceed to Scene IV. Lady Macbeth: Remember me! Let us proceed to Scene III. Scene IV: Main interpretation. [Exeunt] [Enter Romeo and Hamlet] Hamlet: Recall the king's treason! Romeo: Am I as good as nothing? Hamlet: If so, let us proceed to Act II. Romeo: You are the sum of a cat and a big big big cat! You are the sum of thyself and a big big big big big cat. You are the sum of thyself and a big big big big big big cat. Am I as good as you? Hamlet: If so, let us proceed to Scene V. Romeo: You are the square of the sum of a big big big cat and a big cat! Am I as good as you? Hamlet: If so, let us proceed to Scene VI. Romeo: You are the sum of a cat and a big cat! You are the sum of thyself and a big big big big cat! You are the sum of thyself and a big big big big big cat! You are the sum of thyself and a big big big big big big cat! Am I as good as you? Hamlet: If so, let us proceed to Scene VII. Romeo: You are the difference between yourself and a big big cat! Am I as good as you? Hamlet: If so, let us proceed to Scene VIII. Romeo: Let us proceed to Scene IV. Scene V: The 'i' command. [Exeunt] [Enter Romeo and Juliet] Romeo: You are the sum of yourself and a cat! Let us proceed to Scene IX. Scene VI: The 'd' command. [Exeunt] [Enter Romeo and Juliet] Romeo: You are the difference between yourself and a cat! Let us proceed to Scene IX. Scene VII: The 's' command. [Exeunt] [Enter Romeo and Juliet] Romeo: You are the product of yourself and yourself! Let us proceed to Scene IX. Scene VIII: The 'o' command. [Exeunt] [Enter Romeo and Juliet] Romeo: Open your heart! Remember yourself. You are the sum of a big big big cat and a big cat. Speak your mind! Recall yourself. Let us proceed to Scene IX. Scene IX: 256 or -1 checker. [Exeunt] [Enter Hamlet and Juliet] Juliet: You are a big big big big big big big big cat! Am I as good as you? If so, let us proceed to Scene X. You are the difference between nothing and a cat! Am I as good as you? If so, let us proceed to Scene X. Let us proceed to Scene IV. Scene X: Casting Juliet into the abyss. [Exeunt] [Enter Hamlet and Juliet] Hamlet: You are nothing! Let us proceed to Scene IV. Act II: The Halting. Scene I: The only scene in The Halting. [Exeunt]
SmileBASIC
Takes a line from stdin and runs all characters in said line. Unrecognized commands print a newline. Commands are case-sensitive, lowercase. Implements h
and proper x==0||x==256
behavior.
OPTION STRICT 'declare vars VAR X% VAR S$,C$ 'REPL loop REPEAT LINPUT ">> ";S$ 'get line from stdin 'exec all chrs in line WHILE LEN(S$)!=0 C$=SHIFT(S$) 'pop chr from front of string IF C$=="i" THEN INC X% ELSEIF C$=="d" THEN DEC X% ELSEIF C$=="s" THEN 'square x X%=X%*X% ELSEIF C$=="o" THEN 'output x PRINT X% ELSEIF C$=="h" THEN BREAK ELSE PRINT 'adds a newline ENDIF IF X%<0||X%>255 THEN X%=0 'zero behavior WEND UNTIL C$=="h"
SNUSP
/@@@=@@@=++++# 100 = 5*5*4 = 'd' / | \! \ $=!\>,+?!#-=>@/=!/?!\<?\>!/?\<</ | eof? 'd' \->| -/ \-/ | \<?\==!=== < -/ 'i'/ +++++>/ | ! \ !/?!\<?\> / | \->| -/ ! | \<?\==|== < +/ 'o'/ ++++++>/ | ! \ !/?!\<?\> / | \->| -/ ! | \<?\==|== < ./ 's'/ ++++>/ | ! \ !/?!\<?\> / | \->| -/ | /= square = < = /?</ | | /======= > =!\ noop =!/== < / | | / ++<+<\ | \?!/>>+<<-?\>!/>-?/<<+>?!/>+<\ \ up2 / \ \?- /
SOAP
This will only run in the copied implementation. You will need to follow the steps listed on the SOAP page, it's not as simple as inputting the program.
This supports numbers up to 299. Suffix with a period.
*1*102011⊇{102011}[ ~ 'i/*%:*%⊇{100112}[*%;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*%]\ 'd/*%;*%⊇{100112}[*%;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*%]\ 's/ *102012 ⊇{10,102012}[*%::*%*102012] ⊇{11,102012}[*%::::::*%*102012] ⊇{12,102012}[*%::::::::::::*%*102012] ⊇{20,102012}[*%::::::::::::::::::::*%*102012] ⊇{21,102012}[*%::::::::::::::::::::::::::::::*%*102012] ⊇{22,102012}[*%::::::::::::::::::::::::::::::::::::::::::*%*102012] ⊇{100,102012}[*%::::::::::::::::::::::::::::::::::::::::::::::::::::::::*%*102012] ⊇{101,102012}[*%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*%*102012] ⊇{102,102012}[*%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*%*102012] ⊇{110,102012}[*%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*%*102012] ⊇{111,102012}[*%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*%*102012] ⊇{112,102012}[*%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*%*102012] ⊇{120,102012}[*%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*%*102012] ⊇{121,102012}[*%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*%*102012] ⊇{122,102012}[*%;;;;;;;;;;;;;;;;*%*102012] ⊇{200,102012}[*%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*%*102012] ⊇{102012}[*102012] \ 'o/ *102012 ⊇{1,102012}["0*102012] ⊇{2,102012}["1*102012] ⊇{10,102012}["2*102012] ⊇{11,102012}["3*102012] ⊇{12,102012}["4*102012] ⊇{20,102012}["5*102012] ⊇{21,102012}["6*102012] ⊇{22,102012}["7*102012] ⊇{100,102012}["8*102012] ⊇{101,102012}["9*102012] ⊇{102,102012}["1"0*102012] ⊇{110,102012}["1"1*102012] ⊇{111,102012}["1"2*102012] ⊇{112,102012}["1"3*102012] ⊇{120,102012}["1"4*102012] ⊇{121,102012}["1"5*102012] ⊇{122,102012}["1"6*102012] ⊇{200,102012}["1"7*102012] ⊇{201,102012}["1"8*102012] ⊇{202,102012}["1"9*102012] ⊇{210,102012}["2"0*102012] ⊇{211,102012}["2"1*102012] ⊇{212,102012}["2"2*102012] ⊇{220,102012}["2"3*102012] ⊇{221,102012}["2"4*102012] ⊇{222,102012}["2"5*102012] ⊇{1000,102012}["2"6*102012] ⊇{1001,102012}["2"7*102012] ⊇{1002,102012}["2"8*102012] ⊇{1010,102012}["2"9*102012] ⊇{1011,102012}["3"0*102012] ⊇{1012,102012}["3"1*102012] ⊇{1020,102012}["3"2*102012] ⊇{1021,102012}["3"3*102012] ⊇{1022,102012}["3"4*102012] ⊇{1100,102012}["3"5*102012] ⊇{1101,102012}["3"6*102012] ⊇{1102,102012}["3"7*102012] ⊇{1110,102012}["3"8*102012] ⊇{1111,102012}["3"9*102012] ⊇{1112,102012}["4"0*102012] ⊇{1120,102012}["4"1*102012] ⊇{1121,102012}["4"2*102012] ⊇{1122,102012}["4"3*102012] ⊇{1200,102012}["4"4*102012] ⊇{1201,102012}["4"5*102012] ⊇{1202,102012}["4"6*102012] ⊇{1210,102012}["4"7*102012] ⊇{1211,102012}["4"8*102012] ⊇{1212,102012}["4"9*102012] ⊇{1220,102012}["5"0*102012] ⊇{1221,102012}["5"1*102012] ⊇{1222,102012}["5"2*102012] ⊇{2000,102012}["5"3*102012] ⊇{2001,102012}["5"4*102012] ⊇{2002,102012}["5"5*102012] ⊇{2010,102012}["5"6*102012] ⊇{2011,102012}["5"7*102012] ⊇{2012,102012}["5"8*102012] ⊇{2020,102012}["5"9*102012] ⊇{2021,102012}["6"0*102012] ⊇{2022,102012}["6"1*102012] ⊇{2100,102012}["6"2*102012] ⊇{2101,102012}["6"3*102012] ⊇{2102,102012}["6"4*102012] ⊇{2110,102012}["6"5*102012] ⊇{2111,102012}["6"6*102012] ⊇{2112,102012}["6"7*102012] ⊇{2120,102012}["6"8*102012] ⊇{2121,102012}["6"9*102012] ⊇{2122,102012}["7"0*102012] ⊇{2200,102012}["7"1*102012] ⊇{2201,102012}["7"2*102012] ⊇{2202,102012}["7"3*102012] ⊇{2210,102012}["7"4*102012] ⊇{2211,102012}["7"5*102012] ⊇{2212,102012}["7"6*102012] ⊇{2220,102012}["7"7*102012] ⊇{2221,102012}["7"8*102012] ⊇{2222,102012}["7"9*102012] ⊇{10000,102012}["8"0*102012] ⊇{10001,102012}["8"1*102012] ⊇{10002,102012}["8"2*102012] ⊇{10010,102012}["8"3*102012] ⊇{10011,102012}["8"4*102012] ⊇{10012,102012}["8"5*102012] ⊇{10020,102012}["8"6*102012] ⊇{10021,102012}["8"7*102012] ⊇{10022,102012}["8"8*102012] ⊇{10100,102012}["8"9*102012] ⊇{10101,102012}["9"0*102012] ⊇{10102,102012}["9"1*102012] ⊇{10110,102012}["9"2*102012] ⊇{10111,102012}["9"3*102012] ⊇{10112,102012}["9"4*102012] ⊇{10120,102012}["9"5*102012] ⊇{10121,102012}["9"6*102012] ⊇{10122,102012}["9"7*102012] ⊇{10200,102012}["9"8*102012] ⊇{10201,102012}["9"9*102012] ⊇{10202,102012}["1"0"0*102012] ⊇{10210,102012}["1"0"1*102012] ⊇{10211,102012}["1"0"2*102012] ⊇{10212,102012}["1"0"3*102012] ⊇{10220,102012}["1"0"4*102012] ⊇{10221,102012}["1"0"5*102012] ⊇{10222,102012}["1"0"6*102012] ⊇{11000,102012}["1"0"7*102012] ⊇{11001,102012}["1"0"8*102012] ⊇{11002,102012}["1"0"9*102012] ⊇{11010,102012}["1"1"0*102012] ⊇{11011,102012}["1"1"1*102012] ⊇{11012,102012}["1"1"2*102012] ⊇{11020,102012}["1"1"3*102012] ⊇{11021,102012}["1"1"4*102012] ⊇{11022,102012}["1"1"5*102012] ⊇{11100,102012}["1"1"6*102012] ⊇{11101,102012}["1"1"7*102012] ⊇{11102,102012}["1"1"8*102012] ⊇{11110,102012}["1"1"9*102012] ⊇{11111,102012}["1"2"0*102012] ⊇{11112,102012}["1"2"1*102012] ⊇{11120,102012}["1"2"2*102012] ⊇{11121,102012}["1"2"3*102012] ⊇{11122,102012}["1"2"4*102012] ⊇{11200,102012}["1"2"5*102012] ⊇{11201,102012}["1"2"6*102012] ⊇{11202,102012}["1"2"7*102012] ⊇{11210,102012}["1"2"8*102012] ⊇{11211,102012}["1"2"9*102012] ⊇{11212,102012}["1"3"0*102012] ⊇{11220,102012}["1"3"1*102012] ⊇{11221,102012}["1"3"2*102012] ⊇{11222,102012}["1"3"3*102012] ⊇{12000,102012}["1"3"4*102012] ⊇{12001,102012}["1"3"5*102012] ⊇{12002,102012}["1"3"6*102012] ⊇{12010,102012}["1"3"7*102012] ⊇{12011,102012}["1"3"8*102012] ⊇{12012,102012}["1"3"9*102012] ⊇{12020,102012}["1"4"0*102012] ⊇{12021,102012}["1"4"1*102012] ⊇{12022,102012}["1"4"2*102012] ⊇{12100,102012}["1"4"3*102012] ⊇{12101,102012}["1"4"4*102012] ⊇{12102,102012}["1"4"5*102012] ⊇{12110,102012}["1"4"6*102012] ⊇{12111,102012}["1"4"7*102012] ⊇{12112,102012}["1"4"8*102012] ⊇{12120,102012}["1"4"9*102012] ⊇{12121,102012}["1"5"0*102012] ⊇{12122,102012}["1"5"1*102012] ⊇{12200,102012}["1"5"2*102012] ⊇{12201,102012}["1"5"3*102012] ⊇{12202,102012}["1"5"4*102012] ⊇{12210,102012}["1"5"5*102012] ⊇{12211,102012}["1"5"6*102012] ⊇{12212,102012}["1"5"7*102012] ⊇{12220,102012}["1"5"8*102012] ⊇{12221,102012}["1"5"9*102012] ⊇{12222,102012}["1"6"0*102012] ⊇{20000,102012}["1"6"1*102012] ⊇{20001,102012}["1"6"2*102012] ⊇{20002,102012}["1"6"3*102012] ⊇{20010,102012}["1"6"4*102012] ⊇{20011,102012}["1"6"5*102012] ⊇{20012,102012}["1"6"6*102012] ⊇{20020,102012}["1"6"7*102012] ⊇{20021,102012}["1"6"8*102012] ⊇{20022,102012}["1"6"9*102012] ⊇{20100,102012}["1"7"0*102012] ⊇{20101,102012}["1"7"1*102012] ⊇{20102,102012}["1"7"2*102012] ⊇{20110,102012}["1"7"3*102012] ⊇{20111,102012}["1"7"4*102012] ⊇{20112,102012}["1"7"5*102012] ⊇{20120,102012}["1"7"6*102012] ⊇{20121,102012}["1"7"7*102012] ⊇{20122,102012}["1"7"8*102012] ⊇{20200,102012}["1"7"9*102012] ⊇{20201,102012}["1"8"0*102012] ⊇{20202,102012}["1"8"1*102012] ⊇{20210,102012}["1"8"2*102012] ⊇{20211,102012}["1"8"3*102012] ⊇{20212,102012}["1"8"4*102012] ⊇{20220,102012}["1"8"5*102012] ⊇{20221,102012}["1"8"6*102012] ⊇{20222,102012}["1"8"7*102012] ⊇{21000,102012}["1"8"8*102012] ⊇{21001,102012}["1"8"9*102012] ⊇{21002,102012}["1"9"0*102012] ⊇{21010,102012}["1"9"1*102012] ⊇{21011,102012}["1"9"2*102012] ⊇{21012,102012}["1"9"3*102012] ⊇{21020,102012}["1"9"4*102012] ⊇{21021,102012}["1"9"5*102012] ⊇{21022,102012}["1"9"6*102012] ⊇{21100,102012}["1"9"7*102012] ⊇{21101,102012}["1"9"8*102012] ⊇{21102,102012}["1"9"9*102012] ⊇{21110,102012}["2"0"0*102012] ⊇{21111,102012}["2"0"1*102012] ⊇{21112,102012}["2"0"2*102012] ⊇{21120,102012}["2"0"3*102012] ⊇{21121,102012}["2"0"4*102012] ⊇{21122,102012}["2"0"5*102012] ⊇{21200,102012}["2"0"6*102012] ⊇{21201,102012}["2"0"7*102012] ⊇{21202,102012}["2"0"8*102012] ⊇{21210,102012}["2"0"9*102012] ⊇{21211,102012}["2"1"0*102012] ⊇{21212,102012}["2"1"1*102012] ⊇{21220,102012}["2"1"2*102012] ⊇{21221,102012}["2"1"3*102012] ⊇{21222,102012}["2"1"4*102012] ⊇{22000,102012}["2"1"5*102012] ⊇{22001,102012}["2"1"6*102012] ⊇{22002,102012}["2"1"7*102012] ⊇{22010,102012}["2"1"8*102012] ⊇{22011,102012}["2"1"9*102012] ⊇{22012,102012}["2"2"0*102012] ⊇{22020,102012}["2"2"1*102012] ⊇{22021,102012}["2"2"2*102012] ⊇{22022,102012}["2"2"3*102012] ⊇{22100,102012}["2"2"4*102012] ⊇{22101,102012}["2"2"5*102012] ⊇{22102,102012}["2"2"6*102012] ⊇{22110,102012}["2"2"7*102012] ⊇{22111,102012}["2"2"8*102012] ⊇{22112,102012}["2"2"9*102012] ⊇{22120,102012}["2"3"0*102012] ⊇{22121,102012}["2"3"1*102012] ⊇{22122,102012}["2"3"2*102012] ⊇{22200,102012}["2"3"3*102012] ⊇{22201,102012}["2"3"4*102012] ⊇{22202,102012}["2"3"5*102012] ⊇{22210,102012}["2"3"6*102012] ⊇{22211,102012}["2"3"7*102012] ⊇{22212,102012}["2"3"8*102012] ⊇{22220,102012}["2"3"9*102012] ⊇{22221,102012}["2"4"0*102012] ⊇{22222,102012}["2"4"1*102012] ⊇{100000,102012}["2"4"2*102012] ⊇{100001,102012}["2"4"3*102012] ⊇{100002,102012}["2"4"4*102012] ⊇{100010,102012}["2"4"5*102012] ⊇{100011,102012}["2"4"6*102012] ⊇{100012,102012}["2"4"7*102012] ⊇{100020,102012}["2"4"8*102012] ⊇{100021,102012}["2"4"9*102012] ⊇{100022,102012}["2"5"0*102012] ⊇{100100,102012}["2"5"1*102012] ⊇{100101,102012}["2"5"2*102012] ⊇{100102,102012}["2"5"3*102012] ⊇{100110,102012}["2"5"4*102012] ⊇{100111,102012}["2"5"5*102012] ⊇{100112,102012}["2"5"6*102012] ⊇{100120,102012}["2"5"7*102012] ⊇{100121,102012}["2"5"8*102012] ⊇{100122,102012}["2"5"9*102012] ⊇{100200,102012}["2"6"0*102012] ⊇{100201,102012}["2"6"1*102012] ⊇{100202,102012}["2"6"2*102012] ⊇{100210,102012}["2"6"3*102012] ⊇{100211,102012}["2"6"4*102012] ⊇{100212,102012}["2"6"5*102012] ⊇{100220,102012}["2"6"6*102012] ⊇{100221,102012}["2"6"7*102012] ⊇{100222,102012}["2"6"8*102012] ⊇{101000,102012}["2"6"9*102012] ⊇{101001,102012}["2"7"0*102012] ⊇{101002,102012}["2"7"1*102012] ⊇{101010,102012}["2"7"2*102012] ⊇{101011,102012}["2"7"3*102012] ⊇{101012,102012}["2"7"4*102012] ⊇{101020,102012}["2"7"5*102012] ⊇{101021,102012}["2"7"6*102012] ⊇{101022,102012}["2"7"7*102012] ⊇{101100,102012}["2"7"8*102012] ⊇{101101,102012}["2"7"9*102012] ⊇{101102,102012}["2"8"0*102012] ⊇{101110,102012}["2"8"1*102012] ⊇{101111,102012}["2"8"2*102012] ⊇{101112,102012}["2"8"3*102012] ⊇{101120,102012}["2"8"4*102012] ⊇{101121,102012}["2"8"5*102012] ⊇{101122,102012}["2"8"6*102012] ⊇{101200,102012}["2"8"7*102012] ⊇{101201,102012}["2"8"8*102012] ⊇{101202,102012}["2"8"9*102012] ⊇{101210,102012}["2"9"0*102012] ⊇{101211,102012}["2"9"1*102012] ⊇{101212,102012}["2"9"2*102012] ⊇{101220,102012}["2"9"3*102012] ⊇{101221,102012}["2"9"4*102012] ⊇{101222,102012}["2"9"5*102012] ⊇{102000,102012}["2"9"6*102012] ⊇{102001,102012}["2"9"7*102012] ⊇{102002,102012}["2"9"8*102012] ⊇{102010,102012}["2"9"9*102012] ⊇{102012}[*102012] \ './*102011\ ]
SQL
In order to use this program, another program (possibly written in C or some other programming language) must make the INPUT and OUTPUT views to do the necessary things.
PRAGMA RECURSIVE TRIGGERS = 1; CREATE TABLE `DEADFISH` (`VALUE` INT); INSERT INTO `DEADFISH` VALUES (0); CREATE VIEW `INPUT` AS SELECT '' AS `INPUT`; CREATE VIEW `OUTPUT` AS SELECT '' AS `OUTPUT`; CREATE TRIGGER `INCREMENT` INSTEAD OF INSERT ON `INPUT` WHEN NEW.`INPUT` = 'i' BEGIN UPDATE `DEADFISH` SET `VALUE` = `VALUE` + 1; UPDATE `DEADFISH` SET `VALUE` = 0 WHERE `VALUE` = 256; END; CREATE TRIGGER `DECREMENT` INSTEAD OF INSERT ON `INPUT` WHEN NEW.`INPUT` = 'd' BEGIN UPDATE `DEADFISH` SET `VALUE` = `VALUE` - 1 WHERE `VALUE` > 0; UPDATE `DEADFISH` SET `VALUE` = 0 WHERE `VALUE` = 256; END; CREATE TRIGGER `SQUARE` INSTEAD OF INSERT ON `INPUT` WHEN NEW.`INPUT` = 's' BEGIN UPDATE `DEADFISH` SET `VALUE` = `VALUE` * `VALUE`; UPDATE `DEADFISH` SET `VALUE` = 0 WHERE `VALUE` = 256; END; CREATE TRIGGER `OUTPUT` INSTEAD OF INSERT ON `INPUT` WHEN NEW.`INPUT` = 'o' BEGIN INSERT INTO `OUTPUT` SELECT `VALUE` AS `OUTPUT` FROM `DEADFISH`; END;
Stackstack
0 ">> " dup while dup print swap inputstr dup "d" eq if swap 1 - endif dup "i" eq if swap 1 + endif dup "s" eq if swap dup * endif dup "o" eq if swap dup tostring 10 char concat print endif dup -1 eq if pop 0 endif dup 256 eq if pop 0 endif -3 roll pop dup endwhile
Standard ML
Supports both the IDSO and XKCD variants. Use ^D or ^C to quit.
(* deadfish.sml: Simple Deadfish interpreter in Standard ML. *) fun id x = x fun apply (f, x) = f(x) fun fixAcc ~1 = 0 | fixAcc 256 = 0 | fixAcc n = n fun inc (output, acc) = (output, fixAcc(acc + 1)) fun dec (output, acc) = (output, fixAcc(acc - 1)) fun square (output, acc) = (output, fixAcc(acc * acc)) fun output (output, acc) = (acc::output, acc) fun charToFun #"i" = inc | charToFun #"x" = inc | charToFun #"d" = dec | charToFun #"s" = square | charToFun #"k" = square | charToFun #"o" = output | charToFun #"c" = output | charToFun _ = id local fun interpret seed program = foldl apply seed (map charToFun (explode program)) in fun main _ = let val is = TextIO.stdIn and acc = ref 0 fun display (output, acc) = ((app (fn n => print(Int.toString n ^ "\n")) (rev output)); (output, acc)) in while (print ">> "; not (TextIO.endOfStream is)) do acc := #2 (display (interpret ([], !acc) (valOf(TextIO.inputLine is)))) end val interpret = rev o #1 o interpret ([], 0) end
StaPLe
eval;dup; [eval;dup;if;swap;[R0;];||;!;+;1;swap;!;-;256;dup;pop;dup;push;ife;swap; [drop;pop;+;1;push;];swap;[ife;swap;[drop;pop;-;1;push;];swap;[ife;swap; [drop;pop;*;dup;push;];swap;[ife;swap;[putc;10;put;pop;dup;push;]; swap;[putc;10;];==;"o;];==;"s;dup;];==;"d;dup;];==;"i;dup;getc;];R0;
Staq
&iiqqq&{o:&iiiqi;@X}{T-!@_x}{i_iT}{D_d}{d?DT}{sqT}{ks}{xi}{co}{>id}
Allows the command sets of both variations.
*><>
r01[D63. >:884**= ?!\~0v ^v0~u!?=-10:<u < ^> OD~l0=?!\; ^+1I/!?="i":/ ^ \:"d"=?!\I1- ^*:I/!?="s":/ ^ \:"o"=?!;I:aon
Stlang
Reads one line of input.
M 0 (i /r f \ fn f .<+;h d ;t f \ fn f: .$ \ fn d \ fn d:i .$<>I c <> \ fn d:d .$<>D c <> \ fn d:s .$<><+* c <> \ fn d:o .$<><+@<> \ fn c \ fn c:256 .$0(i \ fn c:-1 .$0(i \
stupidc
Input is defined as %PGM.
system(&BE6502); include(&lcd); include(&stupidc); mem(%pgm, "Your program here"); def(%pos); def(%a); onreset({ set(%pos, #0); set(%a, #0); $lcd.init(&2line); forever({ choose(%pgm@%pos, #'i', { inc(%a); }, <255 rolls over to 0 so we don't need to check> #'d', { if (%a, { dec(%a); }); <Only allow it to be decremented if it's NOT equal to zero> }, #'s', { if (?lt(%a, #16), { <Only allow it to be squared if it is less than 16, because 16*16=256.> set(%a, *mult(%a, %a)); }, { set(%a, #0); }); }, #'p', { $lcd.printchar(%a); }, &else, { $lcd.locate(&l2); } ); inc(%a); }); });
stupidExpr
(result = { def: inp, str, c, [str: 1], pos, ulong, a, ubyte.zero /* automatically does zero-out behavior */ ; (i = [input]); loop: { (c = [charof: inp, pos]); (pos ++ 1); choose: (c = "i"), { (a ++ 1); }, (c = "d"), { (a -- 1); }, (c = "s"), { (a = (a * a)); }, (c = "p"), { print: [chr: a]; }, { print: "\n"; } ; if: (pos > [len: inp]), { stop; }; }; });
Super ZZ Zero (assembly)
TA $E0 EQ A,256 TLET A,0 LET C,W AND C,$5F SUB C,'I' JNZ C,1F ADD A,1 LET S,0 1H ADD C,'I'-'D' JNZ C,1F JZ A,0 SUB A,1 LET S,0 1H SUB C,'S'-'D' JNZ C,1F MUL A,A LET S,0 1H ADD C,'S'-'O' JNZ C,0 TEXT E,0 MESS D,A LET S,0
Surtic
I chose to have the deadfish code be stored within the string at the very beginning (between the single quotes), though simply accepting an input of a whole program would work with little modification. This example uses the test case that prints 288.
s0'diissisdo'c9-c10++++fc10[fc10[c10++]]c8++++++++++fc8[fc8[c3+c4+c5+c6+]c10+++c5+c6+]fc8[c8-]c3+++++fc4[c10-]c10++c6+c5+++++lc7:s0?b1(c1<c7)wb1[gc0:s0(c1)?b3(c0==c3)?b4(c0==c4)?b5(c0==c5)?b6(c0==c6)ib3{c2+}ib4{c2-}ib5{fc2[fc2[c8+]]fc2[c2-]fc8[c2+c8-]}ib6{noc2}?b7(c2==c9)?b8(c2==c10)ib7{c2+}ib8{fc2[c2-]}c1+?b1(c1<c7)]
TailDot
Accepts one command at the time
c,x,>>,v,x,i,x,v,x,e,x,i,28,e,x,d,37,e,x,s,46,e,x,o,53,j,1,a,a,1,e,a,256,57,j,1,s,a,1,e,a,-1,57,j,1,o,a,e,a,256,57,j,1,v,a,j,1,a,a,1,e,a,0,1,s,a,1,e,a,0,1,j,64
TAVERN
INCLUDE standard.inc <RAM> 0 VARIABLE VALUE HERE CONSTANT INPUT-TABLE 1 , 4 ALLOT <ROM> :START BEGIN || >> | INPUT-TABLE ACCEPT INPUT-TABLE 1 + @ IF INPUT-TABLE 2 + @ ?DUP IF EXECUTE ELSE CR THEN ELSE CR THEN VALUE @ 256 = VALUE @ -1 = OR IF 0 VALUE ! THEN AGAIN ; :: VALUE INCR ; VOCAB I :: VALUE DECR ; VOCAB D :: VALUE @ DUP * VALUE ! ; VOCAB S :: VALUE @ . CR ; VOCAB O :: QUIT ; VOCAB H
TeX
% Deadfish interpreter in TeX \catcode32=9\endlinechar=-1 \newcount\accumulator \def\checkwrapping{ \ifnum\accumulator=256\accumulator=0\fi \relax \ifnum\accumulator=-1\accumulator=0\fi } \def\I{ \advance\accumulator by 1 \checkwrapping } \def\D{ \advance\accumulator by -1 \checkwrapping } \def\S{ \multiply\accumulator by \accumulator \checkwrapping } \def\O{ \message{\the\accumulator} } \tracingonline=-1 \scrollmode \def\Activate{ \catcode105=13 \catcode100=13 \catcode115=13 \catcode111=13 } \catcode62=11 \def\Start{ \escapechar=-1 \loop \read16 to \>> \>> \iftrue\repeat } \Activate \leti=\I \letd=\D \lets=\S \leto=\O \Start
TeXnicard
(Note: This is the old version of TeXnicard. The new version is entirely different; it is like a combination of SQL and PostScript, but using the mechanisms like TeX for text rendering rather than those of PostScript.)
To use this program, save it in the file called "deadfish.cards" and then type in "@I deadfish.cards" at the "E>" prompt. And then it change to "C>" prompt and it is ready for typing in commands of deadfish.
@. Deadfish implementation in TeXnicard. [d[c0][]dixd256-[][0*][]ix[]]s0 (patterns)sP0 @S i 1+`0x @S d 1-`0x @S s d*`0x @S o ?s[] @P patterns <i : i; <d : d; <s : s; <o : o; @C main
This=That
shell=>> flag=1 while loop x=flag~~flag print shell input i if loop a=i~~i ac=ac plus 1 if loop a=end if loop b=i~~d ac=ac minus 1 if loop b=end if loop c=i~~s ac=ac times ac if loop c=end if loop d=i~~o print ac if loop d=end if loop e=ac<0 ac=0 if loop e=end if loop f=ac~~256 ac=0 if loop f=end while loop x=end
Thue
Deadfish in Thue by Amb ::= This implementation represents the value in binary. ::= It does not convert binary to decimal for output. ::= Fixed to support 256->0 by Oerjan ::= | ::=| $<00::=$<0 $<01::=$<1 $<0|::=$0*| $<11::=$11* $<1|::=$1*| $<101::=$101* $<10|::=$10*| $<1001::=$1001* $<100|::=$100*| $<10001::=$10001* $<1000|::=$1000*| $<100001::=$100001* $<10000|::=$10000*| $<1000001::=$1000001* $<100000|::=$100000*| $<10000001::=$10000001* $<1000000|::=$1000000*| $<100000001::=$100000001* $<10000000|::=$10000000*| $<1000000000::=$1000000000* $<1000000001::=$1000000001* $<100000000|::=$0*| ><::=>* 0<::=<0 1<::=<1 *|i::=i| *|d::=d| *|s::=s| *|o::=o| *0::=0* *1::=1* 0i::=<1 1i::=i0 $i::=$<1 1d::=<0 0d::=d1 $d1::=$d $d|::=$0*| 0o::=o0 1o::=o1 $o::=$*#o #::=~ *o0::=0*[o [::=~0 *o1::=1*]o ]::=~1 *o|::=*| 0s::=s0 1s::=s1 0-::=-0 0+::=+0 1-::=-1 1+::=+1 $-::=0$ $+::=1$ $s::=$*s *s0::=-0*s *s1::=+1*s *s|::=t| 0t::=t(0) 1t::=t(1) $t::=$u $u::=d$ >d1::=>d >d$::=>$w *$::=$uv v(0)::=(0)v v(1)::=(1)1v v0::=0v v1::=1v v|::=| w(0)::=%w w(1)::=%w w1::=1w w|::=x| %x::=x0 %1x::=x1 11x::=yx 1y::=y1 %y::=1% $y::=$1% $1x::=$<1 $x::=$< ?::=::: ::= >$0*|?
Thutu
This stores data in unary, which explains its inefficiency and the length of one of the lines.
/=>=> =x/z=x/ * /=>=> =x/> /=1/=n=>=> =xse/ /^i=xs(a*)e/=>=> =xs$1ae/ /^d=xsa?(a*?)e/=>=> =xs$1e/ /^s=xs(a*)a(b*)e/s=xs$1b$2e$1$2b/ /^s=xs(b*)e(a*)b/s=xs$1e$2a/ /^s=xs(b*)e(a*)$/=>=> =xs$2e/ /^o=xs(a*)e$/o=xs$1v/ /(=x.*[sbc])v/$1w0/ /(=x.*[sbc])av/$1cw1/ /(=x.*[sbc])aav/$1ccw2/ /(=x.*[sbc])aaav/$1cccw3/ /(=x.*[sbc])aaaav/$1ccccw4/ /(=x.*[sbc])aaaaav/$1cccccw5/ /(=x.*[sbc])aaaaaav/$1ccccccw6/ /(=x.*[sbc])aaaaaaav/$1cccccccw7/ /(=x.*[sbc])aaaaaaaav/$1ccccccccw8/ /(=x.*[sbc])aaaaaaaaav/$1cccccccccw9/ /(=x.*[sbc])aaaaaaaaaa(a*)v/$1bbbbbbbbbb$2v/ /(=xsc*)bbbbbbbbbb(.*)w/$1ccccccccca$2w/ /(=x.*)ab(.*w)/$1ba$2/ /(=x.*)ac(.*w)/$1ca$2/ /(=x.*)bc(.*w)/$1cb$2/ /=xs([ca]*)aw/=xs$1av/ /=xs(c*)w/=xs$1x/ /=xs(c*)c(a*)x/=xs$1a$2x/ /^o=xs(a*)x(.*)$/$2=n=>=> =xs$1e/ /^.*=x/=n=>=> =x/ . * /=xsaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaae/se/ .
TI-68k
deadfish(src) Prgm Local acc 0->acc Loop Local cmd left(src,1)->cmd If acc=256 or acc<0 Then 0->acc EndIf If cmd="i" Then acc+1->acc ElseIf cmd="d" Then acc-1->acc ElseIf cmd="s" Then acc^2->acc ElseIf cmd="o" Then Disp acc EndIf If dim(src)=1 or cmd="h" Then Exit EndIf right(src,dim(src)-1)->src EndLoop EndPrgm
TI-BASIC
ClrHome Disp "REGULAR DEADFISH","IDSO INTERPRETER DelVar AInput Str1 //DelVar doesn't need a colon or newline after its argument; this is the same as "DelVar A:Input Str1" For(B,1,length(Str1 sub(Str1,B,1 If Ans="O Disp A A(not(Ans="S")+A(Ans="S"))+(Ans="I")-(Ans="D Ans(Ans<256 and Ans->A End
Ti-Nspire Basic
Note: Since Ti-Nspire Basic doesn't support printing without making a new line, it stores the output then displays it at the end.
Define deadfish(program)=Prgm Local program,pos,acc,command,line line:="" acc:=0 For pos,1,dim(program) command:=Mid(program,pos,1) If command="i" Then acc:=acc + 1 ElseIf command="d" Then acc:=acc - 1 ElseIf command="s" Then acc:=acc<sup>2</sup> ElseIf command="o" Then line:=line&char(acc) Else line:=line&char(13) EndIf If (acc<0) Or (acc>255) acc:=0 EndFor Disp line EndPrgm
Timers
~~ call deadfish ,(deadfish~) ~~ display prompt, get input and call process '>> '{([.:]~)-128(^,~).(@process~)} ~~ process the input 'process'{ 1(;^<!| check256 checkneg default ?) 1(;^< |~) ~~ exit process check256 {(^:#)256(^=!:|`~)256($$~)} checkneg {(^:#)2(^).(^\/<!:|`~).($$~)} default {(:[?]~)'idos'($~)-($"~)} i {(^:#)1(^+`~)} d {(^:#)1(^-`~)} o {(^#."~)} s {(^:#)?(^*`~)} } ~~ setting up deadfish deadfish { 0(^loop) ~~ set initial value loop{('>> ')} ~~ loop prompt }
Tosh
when flag clicked delete all of Console set accumulator to 0 set Read to 0 ask Code: and wait repeat until <Read > (length of answer)> if <(letter Read of answer) = 'i'> or <(letter Read of answer) = 'x'> then change accumulator by 1 end if <(letter Read of answer) = 'd'> then change accumulator by -1 end if <<(letter Read of answer) = 's'> or <(letter Read of answer) = 'k'>> then set accumulator to (accumulator * accumulator) end if <<(letter Read of answer) = 'o'> or <(letter Read of answer) = 'c'>> then add accumulator to Console end if <<(accumulator) < 0> or <(accumulator) = 256>> then set accumulator to 0 end change Read by 1 end
Turing
% Deadfish in Turing % Implemented by Chris Pressey on August 4 2012, % in the Deadfish Cafe in Winnipeg, Manitoba, Canada % (Thus, this is also "Deadfish in Deadfish") var accumulator : int var command : string (1) accumulator := 0 loop if accumulator = 256 or accumulator < 0 then accumulator := 0 end if put ">> " .. get command if command = "i" then accumulator := accumulator + 1 elsif command = "d" then accumulator := accumulator - 1 elsif command = "s" then accumulator := accumulator * accumulator elsif command = "o" then put accumulator else put "Unrecognized command." end if end loop
Uiua
# Experimental! quote(⊂ : "0" /⊂⇌ ≡(⊂ "⌵(×≠256.×≠¯1.)" ⟨"+1 "|"-1 "|"×. "|"⟜&p"⟩)⊗:"idso" &sc)
Umka
This version has three main changes from the previous Umka (0.6) version: slightly shortened names, a small for...in
syntax change so that the code works in Umka 1.2, and an (optional) default
statement inside the switch
to explicitly report unrecognized commands.
// Deadfish in Umka (1.2), version 2 -- dnm 2022-02-17, 2023-10-16 import "std.um" var acc: int = 0 fn getIn(): str { s := "" for true { c := std.getchar() if c == '\n' { break } s += c } return s } fn main() { for true { printf(">> ") input := getIn() for i, cmd in input { switch cmd { case 'i': acc++ case 'd': acc-- case 's': acc = acc * acc case 'o': printf("%i\n", acc) default : printf("Unrecognized command\n") } if acc == 256 || acc < 0 { acc = 0 } } } }
Unlambda
This implementation uses Church numerals, which are essentially unary. Use large ones at your own risk.
````sii ``s``s`ks ``s``s`kskk `k ``s``s `d`k `````.>.>. @ic `k ``s``s``s``s`k?i`kii`k ``s``s`ks ``s`k`s`ks ``s`k`s`kk i `ki ``s``s``s``s`k?d`kii`k ``s``s``si `k ``s``s`ks ``s`k`si ``s`kk ``s``s`ks ``s`k`s`ks ``s`k`s`kk ``si`kk `ki ``s`kk ``si`kk `k`k`ki `k`ki ``s``s``s``s`k?o`kii`k ``sk ``s`kr ``s`k ```sii ``s `k `s``s``si `k ``s``s``si`kk ``s`k`s``si`k `k``si`k `k``si`k `k``si`k `k``si`k `k``si`k `k``si`k `k``si`k `k``si`k `k``si`k k ``s`kk ``s``s`ks``s`k`s`ks ``s`k`s`kk ``si`k`ki `ki ``s`k`s``s`ks``s`k`sik ``s`kk``s`kk``si`k`ki `ki ``s`kk ``s``s`ks ``s`k`s`ks ``s`k`s`kk `k ``s``si`k.9 `k ``s``si`k.8 `k ``s``si`k.7 `k ``s``si`k.6 `k ``s``si`k.5 `k ``s``si`k.4 `k ``s``si`k.3 `k ``s``si`k.2 `k ``s``si`k.1 `k `k.0 ``s`kk ``s``s`ks``s``s`ks `k ``s`kc ``s`k`s`k`k`ki ``s``s`ks``s``s`ksk `k`k``si`ki `kk ``s``s`kskk `ki ``s `k`s``s`ks k i ``s``s``s``s`k?s`kii`k ``s``s`ks k i ``si`kr ``s``s`kc ``s`k`s`k`ki ``s``s`ks ``s``s`ks ``s``s`ks k `k``s`k`sik `k `k ``````s``s`ks k ``s``s`ks k i ``s``s`ks k i ``s``s`ks k i k ``si`ki `k ``s`kd ``si `k`k`ki i `ki
Unofficial MagicKit Assembler =
This is probably the longest one (due to so many things that aren't built-in, so it has to implement all of them). Note, it contains tabs which are necessary to compile properly. You can download the compiled file, source codes, and ".NES.INI" in the external resources section.
To use, push a key "I", "D", "S", or "O" at the prompt. A line break is automatically added after each command; all keys other than "I", "D", "S" and "O" (including the DELETE and RETURN key) are ignored; all buttons on both gamepads are also ignored, and so is the microphone. (If you want to restart the program, push the RESET button on the console.)
; Deadfish implementation for Nintendo Famicom inesprg 1 ; 16K PRG ROM ineschr 1 ; 8K CHR ROM inesmir 1 ; vertical mirroring inesmap 0 ; NROM zp digits ds 8 spare ds 1 scroll1 ds 1 scroll2 ds 1 blink1 ds 1 blink2 ds 1 csrlin ds 1 temp2 ds 1 temp3 ds 1 temp4 ds 1 multacc ds 17 code bank 0 ; Sprites org $C000 oamdata db 215,16,0,32 ; Cursor db 223,15,0,$08, 223,15,0,$10, 223,15,0,$18, 223,15,0,$20 ; First hidden row db 223,15,0,$28, 223,15,0,$30, 223,15,0,$38, 223,15,0,$40 db 231,15,0,$08, 231,15,0,$10, 231,15,0,$18, 231,15,0,$20 ; Second hidden row db 231,15,0,$28, 231,15,0,$30, 231,15,0,$38, 231,15,0,$40 ; Multiplication table org $C100 muones db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 db 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5 db 0,2,4,6,8,0,2,4,6,8,0,2,4,6,8,0 db 0,3,6,9,2,5,8,1,4,7,0,3,6,9,2,5 db 0,4,8,2,6,0,4,8,2,6,0,4,8,2,6,0 db 0,5,0,5,0,5,0,5,0,5,0,5,0,5,0,5 db 0,6,2,8,4,0,6,2,8,4,0,6,2,8,4,0 db 0,7,4,1,8,5,2,9,6,3,0,7,4,1,8,5 db 0,8,6,4,2,0,8,6,4,2,0,8,6,4,2,0 db 0,9,8,7,6,5,4,3,2,1,0,9,8,7,6,5 mutens db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;0 db 0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1 ;1 db 0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,3 ;2 db 0,0,0,0,1,1,1,2,2,2,3,3,3,3,4,4 ;3 db 0,0,0,1,1,2,2,2,3,3,4,4,4,5,5,6 ;4 db 0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7 ;5 db 0,0,1,1,2,3,3,4,4,5,6,6,7,8,9,9 ;6 db 0,0,1,2,2,3,4,4,5,6,7,7,8,9,9,0 ;7 db 0,0,1,2,3,4,4,5,6,7,8,8,9,0,1,2 ;8 db 0,0,1,2,3,4,5,6,7,8,9,9,0,1,2,3 ;9 ;; 0 1 2 3 4 5 6 7 8 9 A B C D E F ; Addition table adones db 0,1,2,3,4,5,6,7,8,9 db 0,1,2,3,4,5,6,7,8,9 db 0,1,2,3,4,5,6,7,8,9 db 0,1,2,3,4,5,6,7,8,9 db 0,1,2,3,4,5,6,7,8,9 db 0,1,2,3,4,5,6,7,8,9 db 0,1,2,3,4,5,6,7,8,9 db 0,1,2,3,4,5,6,7,8,9 db 0,1,2,3,4,5,6,7,8,9 db 0,1,2,3,4,5,6,7,8,9 adtens db 0,0,0,0,0,0,0,0,0,0 db 1,1,1,1,1,1,1,1,1,1 db 2,2,2,2,2,2,2,2,2,2 db 3,3,3,3,3,3,3,3,3,3 db 4,4,4,4,4,4,4,4,4,4 db 5,5,5,5,5,5,5,5,5,5 db 6,6,6,6,6,6,6,6,6,6 db 7,7,7,7,7,7,7,7,7,7 db 8,8,8,8,8,8,8,8,8,8 db 9,9,9,9,9,9,9,9,9,9 ; =256 table eq256 db 6,5,2,0,0,0,0,0 bank 1 org $E000 ; Initialize APU/PPU/CPU reset sei ldx #$FF txs inx stx $2000 stx $4015 bit $2002 ; Clear VBL vwait1 bit $2002 bpl vwait1 vwait2 bit $2002 bpl vwait2 stx $2000 stx $2001 ; Disable PPU ; Initialize RAM ldy #csrlin initram stx <0,y dey bpl initram lda #216 sta <scroll2 ; Initialize palette lda #$3F sta $2006 stx $2006 ldy #$0A initpal sta $2007 stx $2007 dey bne initpal ; Clear screen lda #$20 sta $2006 stx $2006 lda #$0F clrscr sta $2007 sta $2007 sta $2007 sta $2007 dex bne clrscr ; Display prompt prompt ldx #$00 stx $2000 stx $2001 jsr newline lda #$0A sta $2007 sta $2007 lda #$0F sta $2007 sta $2007 sta $2007 sta $2007 sta $2007 sta $2007 lda #$80 sta $2000 ; Wait until all keys are not pushed keywait lda #8 sta <csrlin ldy #$05 ldx #$04 sty $4016 iny keyw1 stx $4016 lda $4017 and #$1E eor #$1E bne keywait sty $4016 lda $4017 and #$1E eor #$1E bne keywait dec <csrlin bne keyw1 ; Read keyboard keyloop ldy #$05 ldx #$04 sty $4016 iny stx $4016 sty $4016 stx $4016 ; Skip row 0 sty $4016 stx $4016 ; Skip row 1 lda $4017 and #$04 beq keyo sty $4016 stx $4016 ; Skip row 2 lda $4017 and #$04 beq keyi sty $4016 stx $4016 ; Skip row 3 sty $4016 stx $4016 ; Skip row 4 lda $4017 and #$10 beq keyd sty $4016 stx $4016 ; Skip row 5 lda $4017 and #$08 beq keys jmp keyloop keyo lda #$0E jsr letter jmp cmdo keyi lda #$0B jsr letter jmp cmdi keyd lda #$0C jsr letter jmp cmdd keys lda #$0D jsr letter jmp cmds ; Output cmdo jsr newline lda #$0F sta <csrlin ldy #7 out1 lda 0,y cpy #0 beq out2 cmp #0 beq out3 out2 stx <csrlin out3 eor <csrlin sta $2007 dey bpl out1 jmp prompt ; Increment cmdi stx <spare ; Clear guard digit incr1 inc <0,x lda <0,x cmp #10 bne chk256 lda #0 sta <0,x inx bne incr1 chk256 ldx #0 incr2 lda <0,x cmp eq256,x bne incr3 ; It isn't "256" inx cpx #8 bne incr2 sta <0 sta <1 sta <2 incr3 jmp prompt ; Decrement cmdd lda <0,x bne decr1 inx cpx #$08 bne cmdd jmp prompt ; It is already zero decr1 ldx #$00 decr2 lda <0,x beq decr3 dec <0,x jmp chk256 ; Now check if equal to 256 decr3 lda #9 sta <0,x inx bne decr2 ; Square cmds stx <spare ; Clear guard digit ldy #16 squ1 stx <multacc,y ; Clear multiplication accumulator memory dey bpl squ1 ldy #7 squ2 ldx #7 squ3 lda <0,x sta <csrlin lda 0,y asl a asl a asl a asl a eor <csrlin sty <csrlin tay lda muones,y sta <temp2 ; Ones digit lda mutens,y sta <temp4 ; Tens digit stx <temp3 lda <csrlin ; Position of a digit clc adc <temp3 ; Position of another digit tay lda <temp2 adc multacc,y sta multacc,y lda <temp4 clc adc multacc+1,y sta multacc+1,y ldy <csrlin dex bpl squ3 dey bpl squ2 ; Now conversion into base ten proper digits inx stx <temp2 ; Carry squ4 lda <multacc,x clc adc <temp2 tay lda adones,y sta <0,x lda adtens,y sta <temp2 inx cpx #8 bne squ4 jmp chk256 ; Check if equal to 256 ; New line routine (expects X=0) newline lda <scroll1 clc adc #8 cmp #240 bne nscrz1 txa nscrz1 sta <scroll1 lda <scroll2 clc adc #8 cmp #240 bne nscrz2 txa nscrz2 sta <scroll2 ldy #$08 sty <csrlin asl a rol <csrlin asl a rol <csrlin ldy <csrlin sty $2006 ora #$01 sta $2006 rts ; Write letter to screen (A=letter to write) letter pha ldx #$00 stx $2000 stx $2001 lda <scroll2 jsr nscrz2 lda #$0A sta $2007 sta $2007 lda #$0F sta $2007 pla sta $2007 rts ; NMI handler nmi pha ; Reset latch bit $2002 ; Cursor blink lda #$3F sta $2006 lda #$13 sta $2006 inc <blink1 cmp <blink1 bne noblink lda <blink2 eor #$1D sta $2007 sta <blink2 lda #$00 sta <blink1 ; Scroll noblink lda #$00 sta $2006 sta $2006 sta $2005 lda <scroll1 sta $2005 ; OAM lda #$C0 sta $4014 ; Enable rendering lda #$1E sta $2001 ; Done pla rti ; Vectors org $FFFA dw nmi,reset,0 ; Pattern table bank 2 org $0000 ;0 defchr $00011100,\ $00100110,\ $01100011,\ $01100011,\ $01100011,\ $00110010,\ $00011100,\ $00000000 ;1 defchr $00001100,\ $00011100,\ $00001100,\ $00001100,\ $00001100,\ $00001100,\ $00111111,\ $00000000 ;2 defchr $00111110,\ $01100011,\ $00000111,\ $00011110,\ $00111100,\ $01110000,\ $01111111,\ $00000000 ;3 defchr $00111111,\ $00000110,\ $00001100,\ $00011110,\ $00000011,\ $01100011,\ $00111110,\ $00000000 ;4 defchr $00001110,\ $00011110,\ $00110110,\ $01100110,\ $01111111,\ $00000110,\ $00000110,\ $00000000 ;5 defchr $01111110,\ $01100000,\ $01111110,\ $00000011,\ $00000011,\ $01100011,\ $00111110,\ $00000000 ;6 defchr $00011110,\ $00110000,\ $01100000,\ $01111110,\ $01100011,\ $01100011,\ $00111110,\ $00000000 ;7 defchr $01111111,\ $01100011,\ $00000110,\ $00001100,\ $00011000,\ $00011000,\ $00011000,\ $00000000 ;8 defchr $00111100,\ $01100010,\ $01110010,\ $00111100,\ $01001111,\ $01000011,\ $00111110,\ $00000000 ;9 defchr $00111110,\ $01100011,\ $01100011,\ $00111111,\ $00000011,\ $00000110,\ $00111100,\ $00000000 ;> defchr $00110000,\ $00011000,\ $00001100,\ $00000110,\ $00001100,\ $00011000,\ $00110000,\ $00000000 ;I defchr $01111110,\ $00011000,\ $00011000,\ $00011000,\ $00011000,\ $00011000,\ $01111110,\ $00000000 ;D defchr $01111100,\ $01100110,\ $01100011,\ $01100011,\ $01100011,\ $01100110,\ $01111100,\ $00000000 ;S defchr $00111110,\ $01100011,\ $01100000,\ $00111110,\ $00000011,\ $01100011,\ $00111110,\ $00000000 ;O defchr $00111110,\ $01100011,\ $01100011,\ $01100011,\ $01100011,\ $01100011,\ $00111110,\ $00000000 ;blank defchr $22222222,\ $22222222,\ $22222222,\ $22222222,\ $22222222,\ $22222222,\ $22222222,\ $22222222 ;cursor defchr $00000000,\ $00303030,\ $00030300,\ $00303030,\ $00030300,\ $00303030,\ $00000000,\ $00000000
Uxn
\\ Deadfish in Uxn \\ (use in non-GUI mode) |0100 #0000 STH2k [; #10 DEO2 BRK ]@ \\ Change 256 to 0 DUP2 #0100 NEQ2 [? POP2 STH2rk ]@ \\ Check input #12 DEI DUP LIT "i EQU ,i JCN DUP LIT "d EQU ,d JCN DUP LIT "s EQU ,s JCN LIT "o EQU ,o JCN BRK @i POP INC2 BRK @d POP ORAk STHrk NEQk ROT POP SUB2 BRK @s POP DUP2 MUL2 BRK @o DUP2 [@ #000a DIV2k STH2k MUL2 SUB2 STH2 SWP2r STH2r NIPr LITr 30 ADDr ORAk ]? POP2 [@ LITr 18 DEOr STHrk ]? #0a18 DEO BRK
Hex dump:
a0 00 00 af a0 01 0b 80 10 37 00 26 a0 01 00 29 20 00 02 22 ef 80 12 16 06 80 69 08 80 15 0d 06 80 64 08 80 11 0d 06 80 73 08 80 12 0d 80 6f 08 80 10 0d 00 02 21 00 02 9d cf 89 05 02 39 00 02 26 3a 00 26 a0 00 0a bb af 3a 39 2f 64 6f 43 c0 30 58 9d 20 ff ee 22 c0 18 57 cf 20 ff f9 a0 0a 18 17 00
Uyjhmn n
DECLARE THE NEW VARIABLE x OPEN THE VARIABLE x ASSIGN 0 TO THE OPEN VARIABLE DECLARE THE NEW VARIABLE i OPEN THE VARIABLE i ASSIGN 105 TO THE OPEN VARIABLE DECLARE THE NEW VARIABLE d OPEN THE VARIABLE d ASSIGN 100 TO THE OPEN VARIABLE DECLARE THE NEW VARIABLE s OPEN THE VARIABLE s ASSIGN 115 TO THE OPEN VARIABLE DECLARE THE NEW VARIABLE o OPEN THE VARIABLE o ASSIGN 111 TO THE OPEN VARIABLE DECLARE THE NEW VARIABLE one OPEN THE VARIABLE one ASSIGN 1 TO THE OPEN VARIABLE DECLARE THE NEW VARIABLE minusone OPEN THE VARIABLE minusone ASSIGN -1 TO THE OPEN VARIABLE DECLARE THE NEW VARIABLE twohundredfiftysix OPEN THE VARIABLE twohundredfiftysix ASSIGN 256 TO THE OPEN VARIABLE DECLARE THE NEW VARIABLE cmd DEFINE THE NEW LABEL main OPEN THE VARIABLE x JUMP TO nottwohundredfiftysix IF x IS GREATER THAN twohundredfiftysix JUMP TO nottwohundredfiftysix IF x IS LESS THAN twohundredfiftysix ASSIGN 0 TO THE OPEN VARIABLE DEFINE THE NEW LABEL nottwohundredfiftysix JUMP TO notminusone IF x IS GREATER THAN minusone ASSIGN 0 TO THE OPEN VARIABLE DEFINE THE NEW LABEL notminusone PRINT THE CHARACTER WITH THE ASCII VALUE 62 PRINT THE CHARACTER WITH THE ASCII VALUE 62 PRINT THE CHARACTER WITH THE ASCII VALUE 32 OPEN THE VARIABLE cmd GET INPUT AND STORE INTO OPEN VARIABLE AS A CHARACTER JUMP TO increment IF cmd IS EQUAL TO i JUMP TO decrement IF cmd IS EQUAL TO d JUMP TO square IF cmd IS EQUAL TO s JUMP TO output IF cmd IS EQUAL TO o PRINT THE CHARACTER WITH THE ASCII VALUE 10 JUMP TO main if x IS EQUAL TO x DEFINE THE NEW LABEL increment OPEN THE VARIABLE x ADD one TO THE OPEN VARIABLE JUMP TO main IF x IS EQUAL TO x DEFINE THE NEW LABEL decrement OPEN THE VARIABLE x ADD minusone TO THE OPEN VARIABLE JUMP TO main IF x IS EQUAL TO x DEFINE THE NEW LABEL square OPEN THE VARIABLE x MULTIPLY THE OPEN VARIABLE BY x JUMP TO main IF x IS EQUAL TO x DEFINE THE NEW LABEL output OPEN THE VARIABLE x PRINT THE OPEN VARIABLE'S VALUE PRINT THE CHARACTER WITH THE ASCII VALUE 10 JUMP TO main IF x IS EQUAL TO x
V3i
def x 0; iloop if input = o; print x; else if input = i; def x x+1; else if input = d; def x x-1; else if input = s; def x x*x; else; print "Invalid command";
var'aq
Notes:
Will only allow one command per line
Can only be stopped by killing the process
The way var'aq is currently implemented (interpreter-wise), any program using 'lj
will not run correctly unless the code is copied into the command-line directly
(* QopghotI' mughwI' var'aq *) 0 "toD" cher ~ QopghotI'mughwI' { ">> " cha' 'Ij "Doch" cher Doch 0 1 tlheghpe' "Doch" cher Doch "i" tlheghrap'a' { toD 1 boq "toD" cher } HIja'chugh Doch "d" tlheghrap'a' { toD 1 boqHa' "toD" cher } HIja'chugh Doch "o" tlheghrap'a' { toD cha' } HIja'chugh Doch "s" tlheghrap'a' { toD toD boq'egh "toD" cher } HIja'chugh toD -1 rap'a' { 0 "toD" cher } HIja'chugh toD 256 rap'a' { 0 "toD" cher } HIja'chugh QopghotI'mughwI' } pong QopghotI'mughwI'
WeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeBasic++
See WeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeBasic++#Deadfish.
Visual Basic .NET
Implementation by User:David.werecat which allows a program file to be specified as a command line parameter.
Option Explicit On Option Strict On Module Deadfish Dim Val As Integer = 0 Sub Main() Dim ProgCode As String = "" Try : ProgCode = My.Computer.FileSystem.ReadAllText(Command().Trim(""""c)) Catch : End Try For Each C As Char In ProgCode Interpret(C) Next While True Console.Write(">> ") : Interpret(Console.ReadKey.KeyChar) End While End Sub Sub Interpret(ByVal C As Char) Select Case C Case "d"c : Val -= 1 : Console.WriteLine() Case "i"c : Val += 1 : Console.WriteLine() Case "o"c : Console.WriteLine() : Console.WriteLine(Val.ToString()) Case "s"c : Val = Val ^ 2 : Console.WriteLine() End Select If (Val < 0) Or (Val = 256) Then Val = 0 End Sub End Module
Vorpal
method() { acc = 0 while (1 > 0) { input = '>> '.input() if ((acc == 256) || (acc < 0)) { acc = 0 } if (input == "i") { acc = acc + 1 } else { if (input == "d") { acc = acc - 1 } else { if (input == "s") { acc = acc * acc } else { if (input == "o") { acc.print() } } } } } }
WARP
+A@s,l=li!:li:0?0?^.p%li@m}pc>pc1^_m|^.s@p=espc=pc0@r{pc=cc! :"i":cc?0?>xx1:"d":cc?0?<xx1:"s":cc?0?&xxxx:"o":cc?0?)xx :256:xx?0?=xx0:es:pc?0?^.e>pc1^.r@e
Whitespace
The first is with syntax highlighting, the second is a hexdump for recreating as the wiki software really can't cope.
000000: 20 20 20 20 0a 0a 20 20 09 0a 20 20 20 09 09 09 ␊␊ ␉␊ ␉␉␉ 000010: 09 09 20 0a 20 0a 20 09 0a 20 20 09 0a 20 20 20 ␉␉ ␊ ␊ ␉␊ ␉␊ 000020: 20 20 09 20 20 20 20 20 0a 09 0a 20 20 20 0a 20 ␉ ␊␉␊ ␊ 000030: 20 20 20 09 20 20 20 20 20 20 20 20 0a 09 20 20 ␉ ␊␉ 000040: 09 0a 09 20 09 20 0a 20 0a 20 20 20 09 09 0a 09 ␉␊␉ ␉ ␊ ␊ ␉␉␊␉ 000050: 20 20 09 0a 09 20 09 20 0a 0a 20 20 09 09 0a 20 ␉␊␉ ␉ ␊␊ ␉␉␊ 000060: 20 20 20 0a 09 0a 09 20 20 20 20 20 0a 09 09 09 ␊␉␊␉ ␊␉␉␉ 000070: 20 0a 20 20 20 20 09 09 20 09 20 20 09 0a 09 20 ␊ ␉␉ ␉ ␉␊␉ 000080: 20 09 0a 09 20 09 20 09 0a 20 0a 20 20 20 20 09 ␉␊␉ ␉ ␉␊ ␊ ␉ 000090: 09 20 20 09 20 20 0a 09 20 20 09 0a 09 20 09 09 ␉ ␉ ␊␉ ␉␊␉ ␉␉ 0000a0: 20 0a 20 0a 20 20 20 20 09 09 09 20 20 09 09 0a ␊ ␊ ␉␉␉ ␉␉␊ 0000b0: 09 20 20 09 0a 09 20 09 09 09 0a 20 0a 20 20 20 ␉ ␉␊␉ ␉␉␉␊ ␊ 0000c0: 20 09 09 20 09 09 09 09 0a 09 20 20 09 0a 09 20 ␉␉ ␉␉␉␉␊␉ ␉␊␉ 0000d0: 09 20 20 20 0a 20 0a 0a 20 20 20 09 20 09 20 0a ␉ ␊ ␊␊ ␉ ␉ ␊ 0000e0: 09 0a 20 20 0a 20 0a 09 0a 0a 20 20 09 20 0a 20 ␉␊ ␊ ␊␉␊␊ ␉ ␊ 0000f0: 0a 0a 20 20 20 20 0a 0a 20 0a 09 09 0a 0a 20 20 ␊␊ ␊␊ ␊␉␉␊␊ 000100: 09 20 09 0a 20 0a 0a 20 20 20 09 0a 09 20 20 20 ␉ ␉␊ ␊␊ ␉␊␉ 000110: 0a 20 0a 09 0a 0a 20 20 09 09 20 0a 20 0a 0a 20 ␊ ␊␉␊␊ ␉␉ ␊ ␊␊ 000120: 20 09 09 0a 09 20 20 20 0a 20 0a 09 0a 0a 20 20 ␉␉␊␉ ␊ ␊␉␊␊ 000130: 09 09 09 0a 20 0a 0a 20 0a 20 09 20 20 0a 0a 20 ␉␉␉␊ ␊␊ ␊ ␉ ␊␊ 000140: 0a 09 0a 0a 20 20 09 20 20 20 0a 20 0a 0a 20 0a ␊␉␊␊ ␉ ␊ ␊␊ ␊ 000150: 20 09 0a 20 09 20 20 20 09 20 09 20 0a 09 0a 20 ␉␊ ␉ ␉ ␉ ␊␉␊ 000160: 20 0a 20 0a 09 0a 0a 0a 0a ␊ ␊␉␊␊␊␊
WTFZOMFG
'>> " _2 + ( _0 %4 _4 ~-256 | { _0 =0 } _3 > + > > ^ & > @i | { _0 + _3 } < & > @d | { _0 - _3 } < & > @s | { _0 & m _3 } < & > @o | { _0 \ '\n" _3 } < & > ~-10 | { '>> " } < + )
XPL0
Tested and works with EXPL (a.k.a. EXPL-32) on Windows, "legacy" 16-bit integer XPL0 on DOS (DOSBox), and 32-bit integer XPL0 (with XPLPX optimizing compiler) on DOS (DOSBox). Not yet tested with the 32-bit XPL0 versions on Raspberry Pi (XPLR/XPL0).
\ Deadfish in XPL0, version 2 -- dnm 2022-04-05, 2022-04-11, 2022-04-12 \ Thanks & greetz to: Loren Blaney (Boreal/6502) and Larry Fish \ Uncomment the next line if using 16-bit XPL0 (not XPLPX/XPLP, EXPL, XPLR/XPL0) \\include C:\CXPL\CODESI.XPL; int Acc, Cmd; [ Acc:= 0; loop [ Text(0, ">> "); Cmd:= ChIn(1); ChOut(0, Cmd); case Cmd of ^i: Acc:= Acc + 1; ^d: Acc:= Acc - 1; ^s: Acc:= Acc * Acc; ^o: [CrLf(0); IntOut(0, Acc)] other [CrLf(0); Text(0, "Unrecognized command")]; CrLf(0); if Acc = 256 ! Acc < 0 then Acc:= 0; ] ]
Zeno
% Deadfish in Zeno (nearly a copy of Deadfish in Turing) -- dnm 2021-05-08 var accumulator : int := 0 var command : string program while true if (accumulator = 256) or (accumulator < 0) then accumulator := 0 end if get command % Uses Zeno's default Output window "? " prompt vs. ">> " if command = "i" then accumulator := accumulator + 1 elsif command = "d" then accumulator := accumulator -1 elsif command = "s" then accumulator := accumulator * accumulator elsif command = "o" then put accumulator else put "Unrecognized command." end if end while end program
ZiziQue
[Start] !i^inc"Increment !d^dec"Decrement !s^sqr"Square !o^out"Output . [out] "{number} ^Start [inc] +number ^Start [dec] -number ^Start [sqr] =number,{{number}*{number}} ^Start
ZZ Zero
* Deadfish in ZZ Zero !INIT G,0 !INIT H,0 !KIND $00 !NAME EMPTY !FLAG $0000 !APP $020 !KIND $01 !NAME MAIN !FLAG $0020 !APP \> !UPD @ EQ H,256 TLET H,G JZ D,-1 TONE A,-200 EQ D,\I JT D,II EQ D,\D JT D,DD EQ D,\S JT D,SS EQ D,\O JT D,OO END A,A II INC H,H END H,H DD JZ H,-1 DEC H,H END H,H SS MUL H,H END H,H OO TEXT A,G APND A,H END H,H !END
Create a board containing a single piece of kind MAIN with speed 1.