From 255a79680b7d4f85e4e5862254dd1c3c98f8be86 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 3 Apr 2024 22:47:11 -0500 Subject: Add eqv?, eq? --- core.lua | 15 +++++++++++++++ eval.lua | 1 + 2 files changed, 16 insertions(+) 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) end m.env = { -- all functions here take R, which is the list of arguments + ------- equivalence + ["eqv?"] = + function (r) + assert_arity(r, 2, 2) + return r[1] == r[2][1] + end, + ["eq?"] = + function (r) + assert_arity(r, 2, 2) + -- from how i understand the Scheme spec, it's okay to + -- make `eqv?' and `eq?' the same. + return r[1] == r[2][1] + end, + -- equal? can be done in-library ------- numbers + -- todo: assert all of these are numbers ["number?"] = function (r) 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 @@ local m = {} local core = require "core" local type = require "type" +local assert_arity = require("util").assert_arity function m.environ (inner, outer) local mt = { -- cgit 1.4.1-21-gabe81