Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
考虑下面的代码来演示这个问题:
让序列 = Seq.initInfinite (fun _ -> "Element") Seq.iter (fun _ -> printf "Element no: ?") 序列
是否有可能获得当前的序列号(例如它的等级)来打印?
使用iteri函数:
let sequence = Seq.initInfinite (fun _ -> "Element") sequence |> Seq.iteri (fun i _ -> printfn "Element no. %d" i)