pike.git / lib / modules / Function.pmod

version» Context lines:

pike.git/lib/modules/Function.pmod:123:   //! (Approximately, since call_callback also calls handle_error   //! if 0 were thrown.)   void call_callback(function f,mixed ... args)   {    if (!f) return;    mixed err=catch { f(@args); return; };    handle_error(err);   }      private function handle_error = master()->handle_error; +  + //! Creates a composite function of the provided functions. The + //! composition function of f() and g(), q(x)=f(g(x)), is created by + //! @expr{function q = Function.composite(f, g);@}. + //! + //! @example + //! @code + //! map(input/",", + //! Function.composite(String.trim_all_whites, upper_case)); + //! @endcode + function composite(function ... f) + { +  return lambda(mixed args) +  { +  for(int i; i<sizeof(f); i++) +  args = f[-i-1](args); +  return args; +  }; + }