Previous Page Next Page Contents

fp::curry -- curry a n-ary function

Introduction

fp::curry(f) returns the higher-order function x -> (y -> f(x,y)).

Call(s)

fp::curry(f <, n>)

Parameters

f - n-ary function
n - nonnegative integer

Returns

A unary higher-order function.

Details

Example 1

Create curried versions of binary and 3-nary functions:

>> cf := fp::curry(f):
   cf(x)(y)
                                  f(x, y)
>> cg := fp::curry(g, 3):
   cg(x)(y)(z)
                                g(x, y, z)

Example 2

A curried version of _plus may be used to create a function which increments its argument by 1:

>> inc := fp::curry(_plus)(1):
   inc(x)
                                   x + 1

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000