I have noticed a function defined as such:

 f[x_][y_] := expr;

How is the argument y in 2nd pair of brackets being used? What is the difference from defining a function this way:

 f[x_, y_] := expr;
  • 1
    $\begingroup$ It allows you to work with and pass around f[something] as a separate object. You could for example Map it easily. See for example this question and the two answers: one uses subvalues ("double bracket") and the other uses downvalues (a single bracket) to achieve the same thing. The downvalues version needs to create new symbol names with extra definitions for each instance of the structure it's generating. The subvalues version doesn't. $\endgroup$
    – Szabolcs
    Dec 31, 2013 at 4:04
  • 1
    $\begingroup$ Related/duplicate: What is the distinction between DownValues, UpValues, SubValues, and OwnValues? $\endgroup$
    – rm -rf
    Dec 31, 2013 at 4:27

1 Answer 1


It allows partial function application. Observe how function test1 defined this way can be called with the first argument, resulting in the return of another function of the remaining argument. Function test2 does not, and simply returns unevaluated since no match to its pattern occurs.



(* 8 *)

(* 8 *)

(* test1[2] *)

(* 8 *)

(* test2[2] *)

(* test2[2][3] *)
  • $\begingroup$ To state it explicitly, you can define something like test3 = test1[2], and then call test3 /@ Range[4] $\endgroup$
    – Jason B.
    Nov 17, 2015 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.