Method Function.splice_call()


Method splice_call

mixed splice_call(array args, function(:void) f, mixed|void ... extra)

Description

Calls the given function with the args array plus the optional extra arguments as its arguments and returns the result.

Most useful in conjunction with map, and particularly in combination with sscanf with "...%{...%}..." scan strings (which indeed was what it was invented for in the first place).

Parameter args

The first arguments the function f expects.

Parameter f

The function to apply the arguments on.

Parameter extra

Optional extra arguments to send to f.

Returns

Whatever the supplied function f returns.

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)
  })