diff options
author | Case Duckworth | 2024-04-11 23:02:40 -0500 |
---|---|---|
committer | Case Duckworth | 2024-04-11 23:02:40 -0500 |
commit | 06d499dd9479acd74d45542cc7bdda61a280653b (patch) | |
tree | 2356ae543204f1fa2f616cd3fb39bf69c18825a2 | |
parent | Add listp to assert_type (diff) | |
download | lam-06d499dd9479acd74d45542cc7bdda61a280653b.tar.gz lam-06d499dd9479acd74d45542cc7bdda61a280653b.zip |
Add values and string-append
-rw-r--r-- | core.lua | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/core.lua b/core.lua index 556b5d1..556866c 100644 --- a/core.lua +++ b/core.lua | |||
@@ -29,6 +29,12 @@ end | |||
29 | -- from what i understand of the spec, it's okay that eqv? and eq? are the same | 29 | -- from what i understand of the spec, it's okay that eqv? and eq? are the same |
30 | env["eq?"] = env["eqv?"] | 30 | env["eq?"] = env["eqv?"] |
31 | 31 | ||
32 | ---[[ VALUES ]]--- | ||
33 | |||
34 | env.values = function (r) | ||
35 | return table.unpack(type.totable(r)) | ||
36 | end | ||
37 | |||
32 | ---[[ TYPES ]]--- | 38 | ---[[ TYPES ]]--- |
33 | 39 | ||
34 | env["boolean?"] = function (r) | 40 | env["boolean?"] = function (r) |
@@ -192,6 +198,18 @@ env["/"] = function (r) | |||
192 | r[1], r[2]) | 198 | r[1], r[2]) |
193 | end | 199 | end |
194 | 200 | ||
201 | ---[[ STRINGS ]]--- | ||
202 | |||
203 | env["string-append"] = function (r) | ||
204 | assert_arity(r,1) | ||
205 | local ss = type.totable(r) | ||
206 | local new = {} | ||
207 | for i, s in ipairs(ss) do | ||
208 | new[i] = s.v | ||
209 | end | ||
210 | return type.string(table.concat(new)) | ||
211 | end | ||
212 | |||
195 | ---[[ INPUT / OUTPUT ]]--- | 213 | ---[[ INPUT / OUTPUT ]]--- |
196 | 214 | ||
197 | env.dump = function (r) | 215 | env.dump = function (r) |