mirror of
https://github.com/azur1s/bobbylisp.git
synced 2024-10-16 02:37:40 -05:00
24 lines
598 B
Plaintext
24 lines
598 B
Plaintext
fun map_ (vec: [int]) (fn: |int| -> int) (current: int): [int] = do
|
|
if current == @len(vec) then
|
|
return []
|
|
else
|
|
do
|
|
let new : [int] = []
|
|
let x : int = @get(vec, current) |> fn(_)
|
|
@insert(new, x)
|
|
|
|
let y : [int] = map_(vec, fn, current + 1)
|
|
return @concat(new, y)
|
|
end
|
|
end
|
|
end
|
|
|
|
fun map (vec: [int]) (fn: |int| -> int): [int] = return map_(vec, fn, 0)
|
|
|
|
fun mul10 (x: int): int = return x * 10
|
|
|
|
fun main: void = do
|
|
let foo: [int] = [69, 420, 727, 1337, 42069, 69420]
|
|
map(foo, mul10) |> @write(_)
|
|
end
|