Posted By

wearetherock on 11/26/09


Tagged

erlang z


Versions (?)

Print Z


 / Published in: Clojure
 

  1. % Erlang
  2. % wearetherock# erlc zeez2.erl
  3. % wearetherock# erl -noshell -s zeez2 main 10
  4.  
  5.  
  6. -module(zeez2).
  7. -export([main/1]).
  8.  
  9. main([A]) ->
  10. L = list_to_integer(atom_to_list(A)),
  11. zeez( true ,L, L).
  12. zeez(true, 0, N) ->
  13. io:format("~p~n", [zeez(z, N)]),
  14. init:stop();
  15. zeez(false, M, N) ->
  16. io:format("~p~n", [zeez(space, M)]),
  17. zeez(M-1 rem N =:= 0, M-1, N );
  18. zeez(true, M, N) ->
  19. io:format("~p~n", [zeez(z, M)]),
  20. zeez(M-1 rem N =:= 0, M-1 , N ).
  21. zeez(space, 0) ->
  22. "Z";
  23. zeez(space, N) ->
  24. " " ++ zeez(space, N-1);
  25. zeez(z,0) ->
  26. "Z";
  27. zeez(z, N) ->
  28. "Z" ++ zeez(z, N-1).

Report this snippet  

You need to login to post a comment.