in reply to BF interpreter
Nice. You can make it a little bit shorter by not giving p any arguments, and by using ARGV:
#!/usr/bin/perl $/=\1;%p=('>',sub{$p++},'<',sub{$p--},'+',sub{$p[$p]++},'-',sub{$p[ $p]--},'.',sub{print chr$p[$p]},',',sub{$p[$p]=ord<>},'[',sub{&c}); sub p{exists$p{$_}&&&{$p{$_}}}p while<>;sub c{push@c,<>.!1until$c[@ c-1]eq']';do{p for@c}while$p[$p]}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: BF interpreter
by gustavderdrache (Acolyte) on Aug 30, 2006 at 20:42 UTC |