aocla/examples/map.aocla

18 lines
409 B
Text
Raw Normal View History

2022-12-22 11:08:16 +01:00
// This is an implementation of map. There is already one inside
// Aocla, but this will redefine it.
[(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@
$f eval
swap ->
$j 1 + (j)
] while
] 'map def
[1 2 3] [dup *] map
print