On Thursday, 19 July 2012 at 14:33:49 UTC, q66 wrote:
On Thursday, 19 July 2012 at 14:31:41 UTC, Petr Janda wrote:
Array gets sorted, then doubles are removed (uniq) and then
everything is converted to a string (map).
Everything was recently introduced around 2.059.
Ok, but what is map!(). What's the point of the exclamation
mark, is it a template specialization?
stuff after ! specifies template arguments, in this case a
predicate; "map" is a standard function in many languages; what
it does basically is to go over an iterable object, apply the
predicate function given in the template argument to each
element and returns a new iterable containing the results of
the predicate call on each element.
for example, auto x = [ 5, 10, 15, 20 ]; assert(map!(x => x +
1)(x) == [ 6, 11, 16, 21 ])