我怎么能做到:
let printTeams x : unit =
let rnd = new Random()
Seq.toList x |> List.sortBy (fun x -> rnd.Next()) |> printTeams'
但不是:
let printTeams x : unit =
let rnd = new Random()
printTeamsRec' <| Seq.toList x <| List.sortBy(fun x -> rnd.Next())
我刚刚在最后一个错误中收到错误,其中显示:
Type mismatch. Expecting a string list -> 'a -> 'b but given a
string list -> unit The type ''a -> 'b' does not match the type 'unit'
错误发生在 printTeamsRec'
的第三行
如有任何帮助,我们将不胜感激。
最佳答案
有两件事:前向管道到后向管道的转换不正确,并且优先级不同。
let printTeams x : unit =
let rnd = new Random()
printTeamsRec' <| (List.sortBy(fun x -> rnd.Next()) <| Seq.toList x)
关于F# - 反向管道顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5290009/