いげ太 #2683(2007/08/30 08:52 GMT) [ OCaml ] Rating0/0=0.00
みなさんの投稿を参考にしつつ初投稿。
1 2 3 4 5 6 7 8 9 10
let pyramid str = let rec letters = function | "" -> [] | s -> (String.sub s 0 1) :: (letters (String.sub s 1 (String.length s - 1))) in fst (List.fold_right (fun s t -> let x = s ^ snd t in (x :: (fst t), " " ^ x)) (letters str) ([], "")) |> List.mapi (fun i s -> (String.make i ' ') ^ s) |> List.rev |> String.concat "\n";; let _ = pyramid "abracadabra" |> printf "%s\n";;
Rating0/0=0.00-0+
[ reply ]
いげ太
#2683()
[
OCaml
]
Rating0/0=0.00
Rating0/0=0.00-0+
[ reply ]