Nix (language): Difference between revisions

imported>Malteneuss
m Improve function explanation
imported>Malteneuss
m small typo
Line 93: Line 93:
So, <code>f(3)</code> in math, is <code>f 3</code> in Nix.
So, <code>f(3)</code> in math, is <code>f 3</code> in Nix.


If you want multiple arguments, you can add arguments like this: <code>arg1: arg2: nixExpression</code>, e.g. <code>f x: y: x*y</code>. Applying that function to multiple values is easy: <code>f(3,4)</code> in math, is <code>f 3 4</code> in Nix.
If you want multiple arguments, you can add arguments like this: <code>arg1: arg2: nixExpression</code>, e.g. <code>f = x: y: x*y</code>. Applying that function to multiple values is easy: <code>f(3,4)</code> in math, is <code>f 3 4</code> in Nix.
If you apply one argument <code>f 3</code>, a partial function <code>y: 3*y</code>is returned.
If you apply one argument <code>f 3</code>only, a partial function <code>y: 3*y</code>is returned.


If the <code>argument</code> is a set like <code>{ hello="world"; a="text"; }</code>, you can pattern-match/destructure it:
If the <code>argument</code> is a set like <code>{ hello="world"; a="text"; }</code>, you can pattern-match/destructure it: