Comment detail
LL Golf Hole 8 - 横向きのピラミッドを作る (Nested Flatten)#7419で投稿しましたが、push, popという関数名がそぐわない感じがしたので、 別のスタイルで書いてみました。 改行を含む文字列を前後両側に伸ばしていく感じです。 実行方法は#7419同様です。
1 2 3 4 5 6 7 8 9 10 11 12 13 | -module(pyramid).
-export([main/1]).
main([N])->
Len=list_to_integer(atom_to_list(N)),
s(Len,p(Len)).
s(0,_)->0;
s(1,S)->io:format("~s", [S]);
s(N,S)->s(N - 1, p(N - 1) ++ S ++ p(N - 1)).
p(0)-> [$\n];
p(N)-> "*" ++ p(N - 1).
|



kgbu #7419() [ Erlang ] Rating0/0=0.00
-module(pyramid). -export([main/1]). main([N])-> push(list_to_integer(atom_to_list(N)),[]). push(0,_)->0; push(1,L)->io:format("~s~n",[L ++ "*"]), pop(L ++ "*"); push(N,L)->io:format("~s~n",[L ++ "*"]), push(N - 1, L ++ "*"). pop("*")-> 0; pop([_|L])-> io:format("~s~n",[L]), pop(L).Rating0/0=0.00-0+
1 reply [ reply ]