Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

F# equivalent to Haskell's $ [duplicate]

Tags:

f#

What is the F# equivalent to Haskell's $?

The operator that does the parenthesis automagically.

Google didnt help :(

Something that allows me to write

printfn "%d" $ Seq.sum nums

Instead of this

printfn "%d" (Seq.sum nums)
like image 592
TheVTM Avatar asked Feb 13 '23 06:02

TheVTM


1 Answers

Use the forward/backward pipe operator. Backward pipe operator is used to maintain the orginal order and forward must me turned over. Function Application Operator ($) in F#?

Backward pipe operator

printfn "%d" <| Seq.sum nums

Forward pipe operator

Seq.sum nums |> printfn "%d"
like image 120
Martijn van Put Avatar answered Feb 16 '23 02:02

Martijn van Put