Map
  • 27 May 2022
  • 1 Minute to read
  • Dark
    Light
  • PDF

Map

  • Dark
    Light
  • PDF

Goes through each item in the given list and evaluates an formula for each of them. Returns a list with the evaluated values.

The returned list has the same length than the original list, and the order of its items correspond the order in the original list.

Function signature

MAP(list: Array, transformformula: Function) => Array
Parameter Description
List List of items to transform
Transform formula Formula to be evaluated for each item

Examples

animals = [
  {
    "name": "dog",
    "weight": 123
  },
  {
    "name": "cat",
    "weight": 48
  },
  {
    "name": "rat",
    "weight": 10
  }
]
products = [{"name":"Duct tape","price":5},{"name":"Swiss army knife","price":60}]
Formula Return value
MAP(animals, item.name) ["dog","cat","rat"]
MAP(products, index + ": " + item.name) ["0: Duct tape","1: Swiss army knife"]
MAP<product>(products, product.name + " (" + product.price + "€)") ["Duct tape (5€)","Swiss army knife (60€)"]
MAP<product, position>(products, position + ": " + product.name + " (" + product.price + "€)") ["0: Duct tape (5€)","1: Swiss army knife (60€)"]

Was this article helpful?

What's Next