Piping another parameter into the line in F#

后端 未结 3 1731
逝去的感伤
逝去的感伤 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:03

    The example you suggested should work fine, a la

    let add x y = x + y
    
    41
    |> add 1
    |> printfn "%d"
    

    If filesUnderFolder takes two curried args, and you partially apply it to one arg, you can use it in the pipeline for the other.

    (Note also the lesser known pipeline operator ||>

    (41,1)
    ||> add
    |> printfn "%d"
    

    which takes a 2-tuple and feed them sequentially into what follows.)

提交回复
热议问题