Munge()

From TinyMUX
Jump to navigation Jump to search


munge([<object>/]<attribute>,<list 1>,<list 2>[,<delimiter>])

This function takes two lists of equal length. It passes the entirety of <list 1> to the user-defined function as %0 and the delimiter as %1. Then, this resulting list is matched with elements in <list 2>, and the rearranged <list 2> is returned. This is useful for doing things like sorting a list, and then returning the corresponding elements in the other list. If a resulting element from the user-defined function doesn't match an element in the original <list 1>, a corresponding element from <list 2> does not appear in the final result.

For example: Consider attribute PLACES, which contains "Fort Benden Ista", and another attribute DBREFS contains the dbrefs of the main JUMP_OK location of these areas, "#20 #9000 #5000". We want to return a list of dbrefs, corresponding to the names of the places sorted alphabetically. The places sorted this way would be "Benden Fort Ista", so we want the final list to be "#9000 #20 #5000". The functions, using munge(), are simple:

Example

> &sort_alpha me=[sort(%0)]

> say [munge(sort_alpha,v(places),v(dbrefs))]

You say, "#9000 #20 #5000"

Related Topics

sortby()