Mix()

From TinyMUX
Jump to navigation Jump to search


mix([<object>/]<attribute>, <list 1>[, <list 2>[,<list N>]][,<delim>])

This function is similar to map(), except it takes the arguments in the lists and passes them into the attribute as %0 (for list1), %1 (for list2), up to %9 (for list10). <delim> is used as the delimiter to separate items in each of the lists. If the number of lists is 2 or less, the delimiter may be optional, otherwise you are forced to provide a delimiter. If no delimiter is specified, it defaults to a space but only for the above condition.

Note: The lists do NOT have to have the same number of elements.

Example

> &do_math me=[add(%0,%1)]

> &do_moremath me=[add(%0,%1,%2,%3,%4,%5,%6,%7,%8,%9)]

> say mix(do_math,1 2 3 4 5,2 4 6 8 10)

You say, "3 6 9 12 15"


> say mix(do_math,1@2@3@4@5,2@4@6@8@10,@)

You say, "3@6@9@12@15"


> say mix(do_math,1 2 3 4 5,7 9)

You say, "8 11 3 4 5"


> say mix(do_moremath,1,2,3,4,5,6,7 8,9 10 11 12,)

You say, "37 18 11 12"

Related Topics

elements(), iter(), list(), map(), merge(), step()