Piping another parameter into the line in F#

后端 未结 3 1734
逝去的感伤
逝去的感伤 2021-01-12 13:11

Is piping parameter into line is working only for functions that accept one parameter? If we look at the example at Chris Smiths\' page,


// Using the Pipe-         


        
3条回答
  •  佛祖请我去吃肉
    2021-01-12 14:10

    It may be bad style (?), but you can add additional parameters to the pipeline 'from the right side'

    let h x y z = x + y - z
    
    let sub x y = x - y
    
    let sqr x = x * x
    
    3 |> h <| 2 <| 7
      |> sub <| 23
      |> sqr
    
    // is the same as
    sqr (sub (h 3 2 7) 23)
    

提交回复
热议问题