Class Function.bind

Description

Partially evaluate a function call.

This function returns a function that when called will do the specified argument mapping. It is similar to curry, but allows more dynamic changes of the argument evaluation, you can leave the first argument unspecified while setting others, or simply change the argument order.

Parameter f

The first argument is the function to be called.

Parameter bind_args

All other arguments are either a generic value, which will be sent as-is to the function or one of the placeholder values defined in Function.Placeholder, or one of your own implementation (inherit Function.Placeholder.Base and implement the value function.).

Example

This example returns a function that limits the given argument to between 0 and 99.

import Function.Placeholder;
    function clip = Function.bind(limit, 0, arg0, 100);

Variable f
Variable bind_args

function(:void) Function.bind.f
array(mixed) Function.bind.bind_args


Method create

Function.bind Function.bind(function(:void) f, mixed ... bind_args)