Map()

From TinyMUX
Jump to navigation Jump to search


20px-Function.png 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()