Ar MapTo
From GECK
A function added by the New Vegas Script Extender version 6.1.6.
Contents
Description
Creates a new Array populated with the results of calling a provided function on every element in the calling array. The type of the new array will be the same as the source array.
Syntax
(array) Ar_MapTo Source:array MapFunction:function/lambda
Example
array_var aIter array_var aNumbers = ar_List 1, 4, 9, 16
array_var aResult = ar_MapTo aNumbers ({aIter} => *aIter * 2);
Content of aResult: 2, 8, 18, 32
Notes
- To see why the * operator is used and why aIter is an array_var, see Dereference/Unbox in NVSE Expressions.
- aIter["key"] will contain the index of aNumbers. If aNumbers was a String Map then it would contain the string key.