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

m
Categorization now in master page
m (adding links)
m (Categorization now in master page)
Line 1:
{{implementation|Brainf***}}{{collection|RCBF}}[[Category:Erlang]]
Implementation of a [[Brainfuck]] interpreter in [[Erlang]].
 
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.
 
<lang erlang>-module(brainfuck).
-module(brainfuck).
-export([run/1]).
 
Line 66 ⟶ 65:
find_end(Ins, N+1, Pos+1);
find_end(<<_, Ins/binary>>, N, Pos) ->
find_end(Ins, N, Pos+1).</lang>
 
</lang>
 
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 '@'):
Anonymous user