ldmud-3.2.9/doc/
ldmud-3.2.9/doc/efun/
ldmud-3.2.9/mud/
ldmud-3.2.9/mud/heaven7/
ldmud-3.2.9/mud/heaven7/lib/
ldmud-3.2.9/mud/lp-245/
ldmud-3.2.9/mud/lp-245/banish/
ldmud-3.2.9/mud/lp-245/doc/
ldmud-3.2.9/mud/lp-245/doc/examples/
ldmud-3.2.9/mud/lp-245/doc/sefun/
ldmud-3.2.9/mud/lp-245/log/
ldmud-3.2.9/mud/lp-245/obj/Go/
ldmud-3.2.9/mud/lp-245/players/lars/
ldmud-3.2.9/mud/lp-245/room/death/
ldmud-3.2.9/mud/lp-245/room/maze1/
ldmud-3.2.9/mud/lp-245/room/sub/
ldmud-3.2.9/mud/lp-245/secure/
ldmud-3.2.9/mud/morgengrauen/
ldmud-3.2.9/mud/morgengrauen/lib/
ldmud-3.2.9/mud/sticklib/
ldmud-3.2.9/mud/sticklib/src/
ldmud-3.2.9/mudlib/uni-crasher/
ldmud-3.2.9/pkg/
ldmud-3.2.9/pkg/debugger/
ldmud-3.2.9/pkg/diff/
ldmud-3.2.9/pkg/misc/
ldmud-3.2.9/src/autoconf/
ldmud-3.2.9/src/bugs/
ldmud-3.2.9/src/bugs/MudCompress/
ldmud-3.2.9/src/bugs/b-020916-files/
ldmud-3.2.9/src/bugs/doomdark/
ldmud-3.2.9/src/bugs/ferrycode/ferry/
ldmud-3.2.9/src/bugs/ferrycode/obj/
ldmud-3.2.9/src/bugs/psql/
ldmud-3.2.9/src/done/
ldmud-3.2.9/src/done/order_alist/
ldmud-3.2.9/src/done/order_alist/obj/
ldmud-3.2.9/src/done/order_alist/room/
ldmud-3.2.9/src/gcc/
ldmud-3.2.9/src/gcc/2.7.0/
ldmud-3.2.9/src/gcc/2.7.1/
ldmud-3.2.9/src/hosts/
ldmud-3.2.9/src/hosts/GnuWin32/
ldmud-3.2.9/src/hosts/amiga/NetIncl/
ldmud-3.2.9/src/hosts/amiga/NetIncl/netinet/
ldmud-3.2.9/src/hosts/amiga/NetIncl/sys/
ldmud-3.2.9/src/hosts/i386/
ldmud-3.2.9/src/hosts/msdos/byacc/
ldmud-3.2.9/src/hosts/msdos/doc/
ldmud-3.2.9/src/hosts/os2/
ldmud-3.2.9/src/hosts/win32/
ldmud-3.2.9/src/util/
ldmud-3.2.9/src/util/erq/
ldmud-3.2.9/src/util/indent/hosts/next/
ldmud-3.2.9/src/util/xerq/
ldmud-3.2.9/src/util/xerq/lpc/
ldmud-3.2.9/src/util/xerq/lpc/www/
SYNOPSIS
        mixed * map(mixed *arg, string func, string|object ob
                                           , mixed extra...)
        mixed * map(mixed *arg, closure cl, mixed extra...)
        mixed * map(mixed *arg, mapping m)

        mapping map(mapping arg, string func, string|object ob
                                            , mixed extra...)
        mapping map(mapping arg, closure cl, mixed extra...)


DESCRIPTION
        Call the function <ob>-><func>() resp. the closure <cl> for
        every element of the array or mapping <arg>, and return a result
        made up from the returned values.

        If <ob> is omitted, or neither a string nor an object, it
        defaults to this_object().


        If <arg> is an array, the function will be called with each
        of the array elements as first parameter, followed by the
        <extra> arguments. The result of the efun is an array with
        all the results returned from the function calls. Thus the
        operation could be described as:

          foreach(index) result[index] = ob->func(arg[index], extra...)

        If <arg> is an array, and a mapping is specified instead
        of a function, the result is an array with the values found
        in the mapping for the original values, resp. with the original
        values for which no mapping entry exists. In other words:

          foreach(index)
             if (arg[index] exists as key in map)
                 result[index] = map[arg[index]]
             else
                 result[index] = arg[index]


        If <arg> is a mapping, the function will be called with
        each of the mapping keys as first, and (if existing) the
        associated values as second parameter, followed by the <extra>
        arguments (these must not be protected references like &(i[0]). The
        result of the efun is a mapping of all results of the function calls,
        stored under their corresponding key.

        Depending on the width of the mapping <arg>, the operation can
        be described as:

          foreach (key in arg)
            switch (widthof(arg))
            case 0:
              result[key] = ob->func(key, 0, extra...)
            case 1:
              result[key] = ob->func(key, arg[key], extra...)
            else  :
              result[key] = ob->func( key
                                    , ({ arg[key,0] ...arg[key,width-1] })
                                    , extra...)

        The advantage of this approach is that the two types of
        multi-dimensional mappings (mappings with multiple values
        per key, and mappings of arrays) can be treated in the same way.


        Note that map() used with arrays behaves like map_array(), but used
        with mappings generalises map_indices()!


EXAMPLES
        arr = ({ 1, 2, 3, 4 });
        m = ([ 1:-1, 3:-3 ]);

        map(arr, #'%, 2)  --> returns ({ 1, 0, 1, 0 })
        map(arr, m)       --> returns ([ -1, 2, -3, 4 })


HISTORY
        Introduced in LDMud 3.2.6, obsoletes map_array().
        LDMud 3.2.8 added the feature of mapping an array through a mapping.

SEE ALSO
        filter(E), filter_indices(E), map_indices(E), map_objects(E)