Pike v8.1 release 6

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.

The first argument is the function to be called.

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

Example

This example returns a funciton 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)