Map()

From TinyMUX
Revision as of 22:48, 25 November 2010 by Ihavenomouth (talk | contribs) (New page: Category:Functions {{Function|map([<obj>/]<attr>,<list>[,<input delim>[,<output delim>[,<arg1>[,<arg2>[,...]]]]])}} This function is nearly identical to an iter() operating on u() fu...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


map([<obj>/]<attr>,<list>[,<input delim>[,<output delim>[,<arg1>[,<arg2>[,...]]]]])

This function is nearly identical to an iter() operating on u() function. Each member of <list> is passed to the result of fetching <attr> as %0, and the results are used to form a new list. Arguments %1, %2, ... are taken from <arg1>, <arg2>, ... respectively, if present.

In addition to any single character, <output delim> can also be the null- delimiter, @@, or a newline, %r. By default, input and output delimiters are both space.

Example

> &ADD_ONE object=add(%0,1)

> say map(object/add_one,1 2 3 4 5)

You say, "2 3 4 5 6"

Related Topics

filter(), fold(), ilev(), iter(), itext(), inum(), u()