Brainfuck FIXED by xsd

let
a,i,s=Array.make
999
0,(let j=ref
47in
fun()->j:=!j+1;!j-
!j/58*58),let
rec(!)n=try!(n^read_line())with
_->n^"!"in!""let
rec(@)q?(r=q+1)p=let
rec
x
r
j
e
k=let($)=x(r+j)j
in
s.[r]=e.[0]&e$k+1||if s.[r]=e.[1]then(if k=0then r@p else e$k-1)else e$k
in
match
s.[q]with
'!'->r=r|'>'->r@p+1|'<'->r@p-1|'['when
a.(p)=0->x
r
1"[]"0|']'when
a.(p)>0->x(q-1)(-1)"]["0|'+'->a.(p)<-a.(p)+1;r@p|'-'->a.(p)<-a.(p)-1;r@p|'.'->Obj.magic
print_char
a.(p);r@p|','->a.(p)<-i();r@p|_->r@p;;Hashtbl.hash s mod 3=1&()=print_string"Hello, world!"||0@0

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page