aocla/examples/map.aocla

18 lines
405 B
Text
Raw Permalink Normal View History

2022-12-22 18:30:57 +01:00
// This is a commented version of the implementation of 'map' inside
// the standard library.
2022-12-22 11:08:16 +01:00
[(l f) // list and function to apply
$l len (e) // Get list len in "e"
0 (j) // j is our current index
[] // We will populate this empty list
[$j $e <] [
$l $j get@
2022-12-22 18:30:57 +01:00
$f upeval
2022-12-22 11:08:16 +01:00
swap ->
$j 1 + (j)
] while
] 'map def
[1 2 3] [dup *] map
2022-12-22 18:30:57 +01:00
printnl