Comment detail

与えられた文字列でピラミッド (Nested Flatten)

適当。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
fun pyramid s =
let
  fun loop s' NONE = []
    | loop s' (SOME c) =
    let
      val ns = subst (str c) "" s'
    in
      loop ns (CharVector.find Char.isGraph ns) @ [s']
    end

  val ss = (String.concatWith " " o global_slice ".") s
in
  (app println o loop ss o SOME o sub) (ss, 0)
end

val _ = pyramid "hoge"
val _ = pyramid "abracadabra"

Index

Feed

Other

Link

Pathtraq

loading...