{
"id": "fn-array-map",
"dataComponent": "array",
"heading": {
"title": "map",
"badges": ["Array", "PARTIAL"]
},
"synopsis": "Applies a function to each element of an array, returning a new array. Supports partial usage for the function or the data array.",
"codeBlocks": [
"extend(\"array\")\\n\\nsput( array:map(n => n * 2, [1,2,3,4]) )\\n// => [2,4,6,8]\\n\\n# Partial usage\\nmyMapper = array:map(n => n + 100)\\nsput( myMapper([5,10,20]) )\\n// => [105,110,120]\\n\\n# Placeholder => array known, function missing\\nmapArr = array:map(_, [3,9,12])\\nsput( mapArr(x => x / 3) )\\n// => [1,3,4]"
],
"notes": [
"If called with two arguments (function, array), it applies the function to each element of the array and returns a new array.",
"If only one argument is supplied, returns a partial function waiting for the other argument (function or data).",
"The array can be int[], str[], float[] (depending on environment). The function’s return type determines the type of the new array."
]
}