3 ms·
interesting. how named arguments work with currying?
by codesnik 11mo ago
interesting. how named arguments work with currying?
- octachron 11mo agoNearly the same as with positional argument: Partially applying a function to a named argument creates a closure with this argument filled in, and you can apply the argument in whichever order you want: let f a ~x ~y b = a + x + y + b let g = f ~y:1 (* g is closure with the argument named ~y filled in *) let h = g 2 (* another closure with the first positional argument filled in *) let int_15 = h 8 ~x:4 (* = g 2 8 ~y:4 = f ~y:1 2 8 ~x:4 *) The more complex interaction is rather with type inference and currying, or the interaction between currying and optional arguments.