Anonymous user
Execute HQ9+: Difference between revisions
m
→{{header|Erlang}}
No edit summary |
|||
Line 299:
<lang Erlang>% hq9+ Erlang implementation (JWL)
% http://www.erlang.org/
-module(hq9p).
-export([main/1]).
hello() ->
bottle(N) -> ▼
1 -> io:format("One bottle ");▼
▲ _ -> io:format("~w bottles ", [N])
end.▼
prog(Prog) ->▼
io:format("~s~n", [Prog]).
bottle(N) when N > 0 ->
▲prog(Prog) ->
beer(0) ->
bottle(0), io:format("on the wall~nGo to the store and buy some more~n"),
io:format("99 bottles of beer on the wall.~n");
beer(N) ->
▲ bottle(N-1), io:format("of beer on the wall~n"),
▲ beer(N-1).
inc(Acc) ->
execute(Instruction, Prog, Acc) ->
main([], _Prog, Acc) ->
main([Instruction | Rest], Prog, Acc) ->
main(Prog) ->
}</lang>▼
=={{header|Forth}}==
|