Skip to main content

map

map(
@llll ? ## required
@modfunction ? ## required
@askfunction null
@depth null
@mindepth 1
@maxdepth 1
) -> llll/null
note

map is a built-in function in the bell programming language and is not unique or exclusive to bellplay~.

Transforms an llll element-wise, according to a given lambda function. The modification function actually receives three arguments: the element to be modified, its address in the original llll and its address in the new llll—the two may be different, as the modification function can remove or insert new elements. If a sublist is encountered and @maxdepth has not been received yet, it is possible to choose whether to enter it and run pass the modification function its elements one by one, or pass the whole sublist. This is accomplished through the @askfunction argument, that can be set to a function receiving the same arguments as the modification function.


Arguments

  • @llll [llll] (required)
  • @modfunction [function/null] (required)
  • @askfunction [function/null] (default: null)
  • @depth [int/llll/null] (default: null)
  • @mindepth [int] (default: 1)
  • @maxdepth [int] (default: 1)

Output

Modified llll [llll/null]

warning

map will return null without raising an error if required arguments are not provided.