# map()

### Description

`map()` is used to perform the same action on each individual value in a list.

That way, it lets you transform a list of values into another list, which comes in especially handy when working with user-provided values like `nationalities` or `sources_of_income`.

Also see [MAP](/rule-language/operators/list-operators/map-1.md) for a non-method version.

### Example: Double some numbers

```
SUM(
  [1, 2, 3].map(number => number * 2)
)
```

* We call map on a list, here the list of numbers `[1, 2, 3]`.
* The argument within map is the function we use on each element, here `number * 2`. It takes each number from that array and multiplies it by 2. With each calculation, the variable `number` is replaced by the next value from the list, until the last value has been dealt with. We chose the name to be `number` as the variable before `=>`. We could have also chosen `n` or `x` if we would have wanted to.
* Since a SUM operator encloses the MAP function, the final output will be the added total of all doubled values - in this case: 12.

The calculations step-by-step:

* 1 \* 2 = 2
* 2 \* 2 = 4
* 3 \* 2 = 6
* The intermediate result of MAP is the new list \[2, 4, 6]
* SUM adds these new values: 2 + 4 + 6 = 12.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.atfinity.io/rule-language/operators/list-operators/map.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
