map

Table of Contents

Function

map — apply a function to each element of an array or set

Synopsis

map(v: array|set, f: function) -> array|set

Description

The map function applies function f to every element in array or set v and returns an array or set of the results. Function f must be a function that takes only one argument. f may be a user-defined function.

Examples

Upper case each element of an array:

yield map(this, upper)
["foo","bar","baz"]
Loading...

Using a user-defined function to convert an epoch float to a time:

Error:
echo '[1697151533.41415,1697151540.716529]' |
  super -z -c '
    func floatToTime(x): (
      cast(x*1000000000, <time>)
    )
    yield map(this, floatToTime)
  ' -
Next: missing

SuperDB