adds first and rest

This commit is contained in:
Quentin Leonetti 2019-07-13 18:18:35 +02:00
parent 805e9ccb28
commit 5de7d7fdc4
2 changed files with 14 additions and 0 deletions

View File

@ -28,10 +28,19 @@ function Library (ronin) {
console.log(...args) console.log(...args)
} }
// Arrays
this.map = (fn, arr) => { this.map = (fn, arr) => {
return arr.map(fn) return arr.map(fn)
} }
this.first = (arr) => {
return arr[0]
}
this.rest = ([_, ...arr]) => {
return arr
}
// Rects // Rects
this.pos = (x, y, t = 'pos') => { this.pos = (x, y, t = 'pos') => {

View File

@ -1,5 +1,10 @@
(print (map (lambda (a) (add a 1)) (1 2 3))) (print (map (lambda (a) (add a 1)) (1 2 3)))
(
(print (first (1 2 3)))
(print (rest (1 2 3)))
)
( (
(clear) (clear)
(map (lambda (a) (map (lambda (a)