Zesstra | 5481d49 | 2021-04-08 20:07:06 +0200 | [diff] [blame] | 1 | SYNOPSIS |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 2 | mapping map_indices(mapping m, string func, string|object ob, ...) |
| 3 | mapping map_indices(mapping m, closure cl, ...) |
Zesstra | 5481d49 | 2021-04-08 20:07:06 +0200 | [diff] [blame] | 4 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 5 | DESCRIPTION |
| 6 | ob->func() is called resp. cl applied to every element in the mapping, |
| 7 | with the key of the element as first argument, and then the extra args |
| 8 | that were given to map_indices (these args must not be protected |
| 9 | references like &(i[0])). The data item in the mapping is replaced by |
| 10 | the return value of the function. ob can also be a file_name of an |
| 11 | object. |
Zesstra | 5481d49 | 2021-04-08 20:07:06 +0200 | [diff] [blame] | 12 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 13 | If <ob> is omitted, or neither a string nor an object, it |
| 14 | defaults to this_object(). |
Zesstra | 5481d49 | 2021-04-08 20:07:06 +0200 | [diff] [blame] | 15 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 16 | Note that if mapping m has more than one value per key, these |
| 17 | are ignored: the resulting mapping always has one value per key. |
Zesstra | 5481d49 | 2021-04-08 20:07:06 +0200 | [diff] [blame] | 18 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 19 | Also note that the behaviour of this function is different from |
| 20 | map(<array>). |
| 21 | |
| 22 | EXAMPLES |
Zesstra | 5481d49 | 2021-04-08 20:07:06 +0200 | [diff] [blame] | 23 | m = mkmapping(users()); |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 24 | m = map_indices(m, #'environment); |
Zesstra | 5481d49 | 2021-04-08 20:07:06 +0200 | [diff] [blame] | 25 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 26 | HISTORY |
| 27 | In LDMud 3.2.6 renamed from map_mapping() and complemented by map(). |
Zesstra | 5481d49 | 2021-04-08 20:07:06 +0200 | [diff] [blame] | 28 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 29 | SEE ALSO |
Zesstra | 5481d49 | 2021-04-08 20:07:06 +0200 | [diff] [blame] | 30 | map(E), filter(E), filter_indices(E), walk_mapping(E), member(E), |
| 31 | m_contains(E) |