Execute Brain****/Erlang: Difference between revisions

m
Fixed syntax highlighting.
(Added reading eof from input as -1 (some implementations use 0))
m (Fixed syntax highlighting.)
 
Line 6:
The opcodes also use a binary representation, which allows to jump through the loop structures. Note, however, that finding the end of the loop still requires linear time, which could be improved.
 
<langsyntaxhighlight lang="erlang">-module(brainfuck).
-export([run/1]).
 
Line 68:
find_end(Ins, N+1, Pos+1);
find_end(<<_, Ins/binary>>, N, Pos) ->
find_end(Ins, N, Pos+1).</langsyntaxhighlight>
 
Example output, the first one being the usual 'Hello World!' program and the second one testing nested loops to increment count to 64 and print the result (should be '@'):
9,483

edits