Previous Page Next Page Contents

fp::fixargs -- create function by fixing all but one argument

Introduction

fp::fixargs(f,1,y) returns the function x -> f(x,y).

Call(s)

fp::fixargs(f, n <, e...>)

Parameters

f - function
n - positive integer defining free argument
e - object used as fixed argument

Returns

An unary function.

Details

Example 1

Fix the first and third argument of f to x1 and x3:

>> fp::fixargs(f, 2, x1, x3)(y)
                               f(x1, y, x3)

Example 2

Create a function which increments its argument by one:

>> inc := fp::fixargs(_plus, 1, 1):
   inc(x)
                                   x + 1

Example 3

Create a function which tests the identifier x for a type:

>> type_of_x := fp::fixargs(testtype, 2, x):
   map([DOM_INT, DOM_IDENT], type_of_x)
                               [FALSE, TRUE]

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000