Name: Anonymous 2007-09-14 22:16 ID:OOJmieTX
Come up with the best toy language you can. Can be as simple or complex as you want.
Bonus points for making an interputer/compiler.
Bonus points for making an interputer/compiler.
brainfuck program = let ev ctx i j prog=let f n=ev(let(x,y:z)=splitAt i ctx in x++[y+n]++z)i(j+1)prog in(case (drop j prog) of[]->[];p:rog->(case p of '>'->ev ctx(1+i)(j+1)prog;'<'->ev ctx(i-1)(j+1)prog;'+'->f 1;'-'->f (-1);'.'->(Char.chr(ctx!!i)):ev ctx i(j+1)prog;']'->ev ctx i(if((ctx!!i)==0)then j+1 else(\(Just x)->x)$List.elemIndex '['$(take j prog))prog;_->ev ctx i(j+1)prog))in ev(repeat 0)0 0 program
Title: Looptest
In Memory of stdio
There once was a var, called a, and it had the value 8.
There was a loop, and the loop added 1 to var, until var became 10.
The End.
int x = 5;