Execute HQ9+: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 321:
%% Helper function printing bottles
bottle(N) ->
%% Implementation of machine instructions
hello() ->
prog(Prog) ->
beer(0) ->
beer(N) ->
bottle(N), io:format("of beer on the wall~n"),
bottle(N-1), io:format("of beer on the wall~n"),
beer(N-1).
inc(Acc) ->
%% Execute a single instruction
execute(Instruction, Prog, Acc) ->
%% Empty program, Program string, Accu
main([], _Prog, Acc) ->
%% Instruction, Rest of program, Program string, Accu
main([Instruction | Rest], Prog, Acc) ->
%% Compile and execute
main(Prog) ->
main(Compiled, Prog, 0).
}</lang>
|