about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2024-04-03 22:47:11 -0500
committerCase Duckworth2024-04-03 22:47:25 -0500
commit255a79680b7d4f85e4e5862254dd1c3c98f8be86 (patch)
tree651c25d62cf4134c6835bab2a8bbdd20dcc447df
parentAdd logos (diff)
downloadlam-255a79680b7d4f85e4e5862254dd1c3c98f8be86.tar.gz
lam-255a79680b7d4f85e4e5862254dd1c3c98f8be86.zip
Add eqv?, eq?
-rw-r--r--core.lua15
-rw-r--r--eval.lua1
2 files changed, 16 insertions, 0 deletions
diff --git a/core.lua b/core.lua index 7891f3a..9563904 100644 --- a/core.lua +++ b/core.lua
@@ -18,7 +18,22 @@ local function fold (kons, knil, r)
18end 18end
19 19
20m.env = { -- all functions here take R, which is the list of arguments 20m.env = { -- all functions here take R, which is the list of arguments
21 ------- equivalence
22 ["eqv?"] =
23 function (r)
24 assert_arity(r, 2, 2)
25 return r[1] == r[2][1]
26 end,
27 ["eq?"] =
28 function (r)
29 assert_arity(r, 2, 2)
30 -- from how i understand the Scheme spec, it's okay to
31 -- make `eqv?' and `eq?' the same.
32 return r[1] == r[2][1]
33 end,
34 -- equal? can be done in-library
21 ------- numbers 35 ------- numbers
36 -- todo: assert all of these are numbers
22 ["number?"] = 37 ["number?"] =
23 function (r) 38 function (r)
24 assert_arity(r, 1, 1) 39 assert_arity(r, 1, 1)
diff --git a/eval.lua b/eval.lua index 60369a9..e3e21c3 100644 --- a/eval.lua +++ b/eval.lua
@@ -3,6 +3,7 @@
3local m = {} 3local m = {}
4local core = require "core" 4local core = require "core"
5local type = require "type" 5local type = require "type"
6local assert_arity = require("util").assert_arity
6 7
7function m.environ (inner, outer) 8function m.environ (inner, outer)
8 local mt = { 9 local mt = {