Skip to content

Map functions

PeerHeer edited this page Dec 31, 2019 · 2 revisions

Description

Map functions can be used in the map operation to map elements in a list.

A map function can be specified using the $listutils.function listutils.in score. This score corresponds to the ID of the function.

Default functions

By default, there is currently one map function in the List Utils datapack. This is located in the listutils.custom/functions/map/functions/built_in directory:

ID Function Description
0 map_copy Copies the element to the map function output.

NOTE: IDs 0 to 99 should be reserverd for map functions native to the List Utils datapack, in case more functions are included in the future.

Custom functions

Users can create custom map functions for their own needs. These functions should adhere to the return values below. For more information, see the Custom functions page.

Parameters

The data element to map is located in the In field in the listutils:map storage. The current index of the iteration is stored in the $listutils.current_index listutils.in score.

Return values

The return value should be stored in the Out field in the listutils:map storage. The return value is appended to the output list.

Clone this wiki locally