adds if and filter
This commit is contained in:
@@ -66,6 +66,10 @@ function Library (ronin) {
|
||||
return arr.map(fn)
|
||||
}
|
||||
|
||||
this.filter = (fn, arr) => {
|
||||
return arr.filter(fn)
|
||||
}
|
||||
|
||||
this.first = (arr) => {
|
||||
return arr[0]
|
||||
}
|
||||
@@ -155,7 +159,12 @@ function Library (ronin) {
|
||||
this.mul = function (a, b) {
|
||||
return a * b
|
||||
}
|
||||
|
||||
this.div = function (a, b) {
|
||||
return a / b
|
||||
}
|
||||
|
||||
this.mod = function (a, b) {
|
||||
return a % b
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,13 @@ function Lisp (input, lib) {
|
||||
|
||||
return interpret(input[2], new Context(lambdaScope, context))
|
||||
}
|
||||
},
|
||||
|
||||
if: function (input, context) {
|
||||
if (interpret(input[1], context)) {
|
||||
return interpret(input[2], context)
|
||||
}
|
||||
return interpret(input[3], context)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user