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 //低|举|疑|床 //头|头|是|前 //思|望|地|明 //故|明|上|月 //乡|月|霜|光
时间: 2024-10-14 04:05:56