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)
omoikani
#4693()
[
StandardML
]
Rating0/0=0.00
とりあえず。
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)Rating0/0=0.00-0+
[ reply ]