%mathpiper,def="MapSingle"

TemplateFunction("MapSingle",{func,list})
[
  Local(mapsingleresult);
  mapsingleresult:={};

  ForEach(mapsingleitem,list)
  [
    DestructiveInsert(mapsingleresult,1,
      Apply(func,{mapsingleitem}));
  ];
  DestructiveReverse(mapsingleresult);
];
UnFence("MapSingle",2);
HoldArgument("MapSingle",func);

%/mathpiper



%mathpiper_docs,name="MapSingle",categories="User Functions;Lists (Operations)"
*CMD MapSingle --- apply a unary function to all entries in a list
*STD
*CALL
	MapSingle(fn, list)

*PARMS

{fn} -- function to apply

{list} -- list of arguments

*DESC

The function "fn" is successively applied to all entries in
"list", and a list containing the respective results is
returned. The function can be given either as a string or as a pure
function (see Apply for more information on pure functions).

The {/@} operator provides a shorthand for
{MapSingle}.

*E.G.

In> MapSingle("Sin",{a,b,c});
Result: {Sin(a),Sin(b),Sin(c)};
In> MapSingle({{x},x^2}, {a,2,c});
Result: {a^2,4,c^2};

*SEE Map, MapArgs, /@, Apply
%/mathpiper_docs