> For the complete documentation index, see [llms.txt](https://docs.openbrim.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.openbrim.org/developers/paramml-developer-guide/functions/custom-function/maploopxparameter-or-maplistxparameter.md).

# map(Loop,x.parameter) or map(List,x.parameter)

This function is a versatile tool in programming that simplifies list manipulation. With `map()`, you can swiftly apply an operation to every element in a list, creating a new list that holds the results. This function is particularly useful when you want to transform a list's contents without manually iterating through each element. In addition, `map()` is also used for extracting parameters from a loop, creating a new list with the same length as loop that returns the value of specified parameter for each iteration.

**Example1:**

```xml
<O N="mapFunctionObject1" T="Project" Category="Functions" TransAlignRule="1">
    <!-- created by ParamML Examples on 8/10/2023 -->
    <P N="List1" V="[1,2,3,4,5,6]" />
    <!-- add +1 to each value in the list -->
    <P N="map1" V="map(List1, x+1)" />
    <!-- get index number of each item in the list -->
    <P N="map2" V="map(List1, xi)" />
    <!-- change default counter -->
    <P N="map3" V="map(List1, k=> k+1)" />
    <!-- create list of list -->
    <P N="map4" V="map(List1, List1)" />
    <!-- get value of first item in each list in a list of list -->
    <P N="map5" V="map(map4, x[0])" />
    <!-- usage of map() inside map() -->
    <!-- y represents each list item in the list of list  -->
    <P N="map6" V="map(map4, y=>map(y, x-1))" />
    <!-- manipulation of list count in a list of list -->
    <P N="map7" V="map(map4, y=> filter(y,x.LT.3))" />
    <!-- extract value from loop -->
    <O N="Loop1" T="Repeat" S="0" E="9" I="1" CTRL="index" index="0">
        <O N="Line1" T="Line">
            <O N="PT1" T="Point" X="0" Y="0" Z="0" />
            <O N="PT2" T="Point" X="10 * index + 1" Y="0" Z="0" />
        </O>
    </O>
    <!-- extract parameter value -->
    <P N="map8" V="map(Loop1, x.Line1.PT2.X)" />
    <!-- extract object  -->
    <P N="map9" V="map(Loop1, x.Line1.PT2)" />
</O>
```

![](https://openbrim.atlassian.net/wiki/download/attachments/2167734358/image-20230810-111157.png?api=v2) The provided ParamML code defines a "Project" object that showcases various parameter manipulation techniques. It initializes a list, performs mappings such as value incrementation and index extraction, generates a list of lists, and applies nested mappings and filtering. Additionally, the code extracts X coordinates and entire point objects from loop iterations. These examples illustrate ParamML's capacity to simplify complex data transformations, rendering it an invaluable tool for parametric modeling and aiding in the comprehension of mapping, manipulation, and object interaction concepts.

Also, please keep in mind that utilizing the map() function instead of T="Repeat" object for operations consisting solely of parameters, not objects, will enhance computational performance. To view this example in the library, see (<https://openbrim.org/app/?incubator=1&author=ParamML_Examples_OpenBrIM+Platform&obj=objidhrchfgy1jum2pvuvof91ip> )


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.openbrim.org/developers/paramml-developer-guide/functions/custom-function/maploopxparameter-or-maplistxparameter.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
