open System
let print (text : string) offset =
query {
for (c, i) in Seq.zip text (seq {0 .. text.Length - 1}) do
groupValBy (string c) (i % offset) into g
select (g |> Seq.reduce (fun c1 c2 -> c2 + "|" + c1))
} |> Seq.iter (printfn "%s")
print "床前明月光疑是地上霜举头望明月低头思故乡" 5
//低|举|疑|床
//头|头|是|前
//思|望|地|明
//故|明|上|月
//乡|月|霜|光
趣味编程:静夜思(F#3.0版)
最新推荐文章于 2024-01-20 20:18:06 发布
