pike.git / lib / modules / Function.pmod

version» Context lines:

pike.git/lib/modules/Function.pmod:45:   //!   //! The Y combinator is useful when writing recursive lambdas. It   //! converts a lambda that expects a self-reference as its first argument   //! into one which can be called without this argument.   //!   //! @example   //! This example creates a lambda that computes the faculty function.   //! @code   //! Function.Y(lambda(function f, int n) { return n>1? n*f(n-1) : 1; })   //! @endcode + //! + //! @seealso + //! @[this_function]   function Y(function f)   {    return lambda(function p) {    return lambda(mixed ... args) {    return f(p(p), @args);    };    } (lambda(function p) {    return lambda(mixed ... args) {    return f(p(p), @args);    };
pike.git/lib/modules/Function.pmod:89:   }      //! 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. + //! @param f + //! 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.). + //! @param 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 funciton that limits the given argument + //! This example returns a function that limits the given argument   //! to between 0 and 99. - //! @code - //! import Function.Placeholder; - //! function clip = Function.bind(limit, 0, arg0, 100); - //! @endcode + //! + //! @code + //! import Function.Placeholder; + //! function clip = Function.bind(limit, 0, arg0, 100); + //! @endcode   class bind(function f, mixed ... bind_args)   { -  protected string _sprintf() { +  protected string _sprintf(int c) {    return sprintf("Function.bind(%O%{, %O%})",f,bind_args);    }       protected mixed `()(mixed ... args)    {    array processed = ({});    for(int i=0; i<sizeof(bind_args);i++)    {    if( objectp(bind_args[i]) && bind_args[i]->_is_placeholder )    {
pike.git/lib/modules/Function.pmod:193:    {    for(int i; i<sizeof(f); i++)    args = f[-i-1](args);    return args;    };   }         //! @module Placeholder   //! - //! Placeholder arguments for Function.bind + //! Placeholder arguments for @[Function.bind]      //! @ignore   object Placeholder = class   {   //! @endignore       class Base    {    constant _is_placeholder = true;    }       class Arg(int num)    //! Arg(x) returns the value of argument X    {    inherit Base; -  protected string _sprintf() { +  protected string _sprintf(int c) {    return sprintf("arg%d",num);    }       //! @decl mixed value(bind x, array args);    //!    //! The function that is called to return the argument value.    mixed value(bind x, array args)    {    if(num>=sizeof(args) || -num>sizeof(args))    error("No argument %d given\n",num);
pike.git/lib/modules/Function.pmod:304:    //! The function will be passed the list of arguments.    //!    //! If _splice is true, zero or more argument is returned in an array    //!    //! Function.Placeholder.arg1 is thus more or less equivalent to    //! @code    //! Expr(lambda(array args){return args[1];});    //! @endcode    {    inherit Base; -  protected string _sprintf() { +  protected string _sprintf(int c) {    return sprintf("Expr(%O)",value);    }    mixed value( bind x, array args )    {    return func(args);    }    }       private mapping _cache = ([]);    mixed `[](string name)