From f321a85d65fbc80946f746f96da36c66584c732c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Sundstr=C3=B6m?= <oyasumi@gmail.com> Date: Tue, 21 Nov 2000 18:22:09 +0100 Subject: [PATCH] added Function.splice_call Rev: lib/modules/Function.pmod:1.4 --- lib/modules/Function.pmod | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/lib/modules/Function.pmod b/lib/modules/Function.pmod index 8dd28cfab3..1005626938 100644 --- a/lib/modules/Function.pmod +++ b/lib/modules/Function.pmod @@ -1,3 +1,40 @@ #pike __REAL_VERSION__ constant defined = __builtin.function_defined; + +//! Calls the given function with the @tt{args@} array plus the optional +//! extra arguments as its arguments and returns the result. +//! +//! Most useful in conjunction with @ref{map@}, and particularly in combination +//! with @ref{sscanf@} with @tt{"...%{...%}..."@} scan strings (which indeed +//! was what it was invented for in the first place). +//! +//! @example +//! class Product(string name, string version) +//! { +//! string _sprintf() +//! { +//! return sprintf("Product(%s/%s)", name, version); +//! } +//! } +//! map(({ ({ "pike", "7.1.11" }), +//! ({ "whitefish", "0.1" }) }), +//! Function.splice_call, Product); +//! ({ /* 2 elements */ +//! Product(pike/7.1.11), +//! Product(whitefish/0.1) +//! }) +//! @endexample +//! +//! @param args +//! the first arguments the function @tt{f@} expects +//! @param f +//! the function to apply the arguments on +//! @param extra +//! optional extra arguments to send to @tt{f@} +//! @returns +//! whatever the supplied function @tt{f@} returns +mixed splice_call(array args, function f, mixed|void ... extra) +{ + return f(@args, @extra); +} -- GitLab