日期:2014-05-20 浏览次数:21130 次
let print (text : string) offset =
text.ToCharArray()
|> Array.mapi (fun i c -> (i, c))
|> Seq.groupBy (fun (i, _) -> i % offset)
|> Seq.map (fun (_, s) -> s |> Seq.map (fun (_, c) -> c.ToString()) |> Seq.reduce (fun c1 c2 -> c2 + "|" + c1))
|> Seq.iter (fun str -> printfn "%s" str)
print "床前明月光疑似地上霜举头望明月低头思故乡" 5
//低|举|疑|床
//头|头|似|前
//思|望|地|明
//故|明|上|月
//乡|月|霜|光