あみだくじ
Posted feedbacks - StandardML
とりあえず。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | val s = [
"A B C D E",
"| | |-| |",
"|-| | |-|",
"| |-| |-|",
"|-| |-| |",
"|-| | | |"
]
fun amida [] = []
| amida (a as (x::xs)) =
let
fun loop [] y = y
| loop (s::ss) y =
let
fun f ((i, _), v) =
substring (v, 0, i - 1) ^
(implode o rev o explode o substring) (v, i - 1, 3) ^
String.extract (v, i + 2, NONE)
in
loop ss (foldl f y (global_find "-" s))
end
in
a @ [loop xs x]
end
val _ = app println (amida s)
|


greentea #4476() Rating4/6=0.67
[ reply ]