2022-04-09 10:17:36 -05:00
|
|
|
fun map_ (vec: [int]) (fn: |int| -> int) (current: int): void = do
|
2022-03-21 18:31:45 -05:00
|
|
|
if current == @len(vec) then
|
2022-04-03 03:07:25 -05:00
|
|
|
do end
|
2022-03-21 18:31:45 -05:00
|
|
|
else
|
|
|
|
do
|
2022-04-09 09:04:08 -05:00
|
|
|
@get(vec, current)
|
|
|
|
|> fn(_)
|
|
|
|
|> @write(_)
|
2022-04-03 03:07:25 -05:00
|
|
|
@write("\n")
|
2022-03-22 20:34:20 -05:00
|
|
|
|
2022-04-09 10:17:36 -05:00
|
|
|
map_(vec, fn, current + 1)
|
2022-04-03 03:07:25 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2022-03-21 18:31:45 -05:00
|
|
|
|
2022-04-09 10:17:36 -05:00
|
|
|
fun map (vec: [int]) (fn: |int| -> int): void = map_(vec, fn, 0)
|
2022-04-09 09:04:08 -05:00
|
|
|
|
|
|
|
fun mul10 (x: int): int = x * 10
|
2022-03-21 18:31:45 -05:00
|
|
|
|
|
|
|
fun main: void = do
|
2022-04-09 09:04:08 -05:00
|
|
|
let foo: [int] = [69, 420, 727, 1337, 42069, 69420]
|
2022-04-09 10:17:36 -05:00
|
|
|
map(foo, mul10)
|
|
|
|
end
|