in reply to Re: BF Interpreter
in thread BF Interpreter
Although I prefer your version :)$cd .= $_ while <STDIN>; sub jump_ahead { (($ch_ptr = index($cd, ']', $ch_ptr))) if (!$cell[$cl_ptr]); } sub jump_behind { (($ch_ptr = rindex($cd, '[', $ch_ptr))) if ($cell[$cl_ptr]); } while (1) { exit if ($ch_ptr == length($cd)); $ch = substr($cd, $ch_ptr++, 1); ($ch eq '>') && $cl_ptr++; ($ch eq '<') && $cl_ptr--; ($ch eq '+') && $cell[$cl_ptr]++; ($ch eq '-') && $cell[$cl_ptr]--; ($ch eq '.') && (($_ = chr($cell[$cl_ptr])) && print); ($ch eq ',') && ($cell[$cl_ptr] = ord(getc)); ($ch eq '[') && jump_head; ($ch eq ']') && jump_behind; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: BF Interpreter
by aweeraman (Novice) on Mar 10, 2006 at 23:38 UTC |