diff options
| author | s-ol <s+removethis@s-ol.nu> | 2025-09-14 15:37:55 +0000 |
|---|---|---|
| committer | s-ol <s+removethis@s-ol.nu> | 2025-09-14 16:19:37 +0000 |
| commit | 473030f60a3f15a961b67f5a162d3d7c46b79c05 (patch) | |
| tree | df279ba0ab89c81ab61aa2c8c4d4f76af184f531 | |
| parent | lib/love: fix text, add group (diff) | |
| download | alive-473030f60a3f15a961b67f5a162d3d7c46b79c05.tar.gz alive-473030f60a3f15a961b67f5a162d3d7c46b79c05.zip | |
lib/array: map passes index
| -rw-r--r-- | alv-lib/array.moon | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/alv-lib/array.moon b/alv-lib/array.moon index bbc1cbd..42eccee 100644 --- a/alv-lib/array.moon +++ b/alv-lib/array.moon @@ -246,7 +246,9 @@ map = Constant.meta examples: { '(map array fn)' } description: " Invokes `fn` once for each element in `array` and returns an array of the results. -`fn` must take one argument and return the same type consistently." +`fn` must take two the current element and index as arugments, and return the same type consistently. + + (map [1 2 3] (fn [x i] (* x 2)))" value: class extends Builtin eval: (scope, tail) => @@ -270,6 +272,7 @@ Invokes `fn` once for each element in `array` and returns an array of the result Dummy array\make_ref! Constant.num i-1 } + Constant.num i-1 } tag = @tag\clone Tag.parse '-1' |
