Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
F#-反向管道顺序_F# - Fatal编程技术网

F#-反向管道顺序

F#-反向管道顺序,f#,F#,我怎么能做到: 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.

我怎么能做到:

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())
x:unit=
设rnd=new Random()
printTeamsRec''b但给出了一个
字符串列表->单位类型''a ->“b”与类型“unit”不匹配

错误发生在第三行的
printTeamsRec'


任何帮助都将不胜感激。

两件事:向前管道到向后管道的转换不正确,优先级不同

let printTeams x : unit = 
    let rnd = new Random()
    printTeamsRec' <| (List.sortBy(fun x -> rnd.Next()) <| Seq.toList x)
x:unit=
设rnd=new Random()

printTeamsRec'rnd.Next())我想我不能先对一个还不存在的列表进行排序,因此使翻译变得非常不同。。但你是对的谢谢如果您想省略括号,那么向后管道是很好的,但是当您有多个步骤时,您应该始终使用向前管道(这也更符合逻辑)。List.sortBy(fun x->rnd.Next())|>Seq.toList x |>printTeamsRec'@ebb-不客气!表达式
List.sortBy(fun x->rnd.Next())
是一个部分应用的函数,因此在向后管道操作符应用表达式
Seq.toList x
的值之前,不会执行排序。如果多次调用同一元素,则使用返回不同值的投影在F中是否有效?