time-to-botec/squiggle/node_modules/@stdlib/utils/curry/docs/repl.txt
NunoSempere b6addc7f05 feat: add the node modules
Necessary in order to clearly see the squiggle hotwiring.
2022-12-03 12:44:49 +00:00

52 lines
1.1 KiB
Plaintext

{{alias}}( fcn[, arity][, thisArg] )
Transforms a function into a sequence of functions each accepting a single
argument.
Until return value resolution, each invocation returns a new partially
applied curry function.
Parameters
----------
fcn: Function
Function to curry.
arity: integer (optional)
Number of parameters. Default: `fcn.length`.
thisArg: any (optional)
Evaluation context.
Returns
-------
out: Function
Curry function.
Examples
--------
> function add( x, y ) { return x + y; };
> var f = {{alias}}( add );
> var sum = f( 2 )( 3 )
5
// Supply arity:
> function add() { return arguments[ 0 ] + arguments[ 1 ]; };
> f = {{alias}}( add, 2 );
> sum = f( 2 )( 3 )
5
// Provide function context:
> var obj = {
... 'name': 'Ada',
... 'greet': function greet( word1, word2 ) {
... return word1 + ' ' + word2 + ', ' + this.name + '!'
... }
... };
> f = {{alias}}( obj.greet, obj );
> var str = f( 'Hello' )( 'there' )
'Hello there, Ada!'
See Also
--------