Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

F# parameter passing

I've always thought that F# had two different ways to pass arguments, curry style and tuple style. Is this actually correct?

Isn't it simply one style , curry style, and arguments can either be simple values or tuples.

e.g.

someFunc (a,b) =

isn't this a function with one curry style argument which happens to be a tuple ? Thus allowing me to pass tuples to this function using the pipleline operator? (where the elements of the tuple is named)

(1,2) |> someFunc

Is this correct?

like image 745
Roger Johansson Avatar asked Jul 09 '12 09:07

Roger Johansson


1 Answers

This will work just fine - the difference is when you have

let f (a,b) = ...
let f2 a b = ...

then you can create a partially applied f2 easily, but for f it doesn't work quite as nicely - you have to do

let partial = fun t -> f (1,t)
let partial2 = f2 1
like image 171
John Palmer Avatar answered Oct 08 '22 14:10

John Palmer