Skip to content

Commit

Permalink
Define NULL on Lua
Browse files Browse the repository at this point in the history
  • Loading branch information
shawwn committed Sep 13, 2018
1 parent aedf2fd commit 022be97
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
29 changes: 15 additions & 14 deletions bin/lumen.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
environment = {{}}
target = "lua"
null = {"%null"}
function nil63(x)
return x == nil
return x == nil or x == null
end
function is63(x)
return not nil63(x)
Expand Down Expand Up @@ -178,10 +179,10 @@ end
function join(...)
local __ls = unstash({...})
local __r37 = {}
local ____x2 = __ls
local ____x3 = __ls
local ____i4 = 0
while ____i4 < _35(____x2) do
local __l11 = ____x2[____i4 + 1]
while ____i4 < _35(____x3) do
local __l11 = ____x3[____i4 + 1]
if __l11 then
local __n3 = _35(__r37)
local ____o2 = __l11
Expand All @@ -202,19 +203,19 @@ function find(f, t)
local ____o3 = t
local ____i6 = nil
for ____i6 in next, ____o3 do
local __x3 = ____o3[____i6]
local __y = f(__x3)
local __x4 = ____o3[____i6]
local __y = f(__x4)
if __y then
return __y
end
end
end
function first(f, l)
local ____x4 = l
local ____x5 = l
local ____i7 = 0
while ____i7 < _35(____x4) do
local __x5 = ____x4[____i7 + 1]
local __y1 = f(__x5)
while ____i7 < _35(____x5) do
local __x6 = ____x5[____i7 + 1]
local __y1 = f(__x6)
if __y1 then
return __y1
end
Expand Down Expand Up @@ -242,10 +243,10 @@ function sort(l, f)
end
function map(f, x)
local __t1 = {}
local ____x7 = x
local ____x8 = x
local ____i9 = 0
while ____i9 < _35(____x7) do
local __v3 = ____x7[____i9 + 1]
while ____i9 < _35(____x8) do
local __v3 = ____x8[____i9 + 1]
local __y2 = f(__v3)
if is63(__y2) then
add(__t1, __y2)
Expand Down Expand Up @@ -287,7 +288,7 @@ function empty63(t)
local ____o6 = t
local ____i12 = nil
for ____i12 in next, ____o6 do
local __x8 = ____o6[____i12]
local __x9 = ____o6[____i12]
return false
end
return true
Expand Down
6 changes: 3 additions & 3 deletions runtime.l
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
(define-global environment (list (obj)))
(define-global target (language))

(target lua: (define-global null '(%null)))

(define-global nil? (x)
(target
js: (or (= x nil) (= x null))
lua: (= x nil)))
(or (= x nil) (= x null)))

(define-global is? (x) (not (nil? x)))

Expand Down

0 comments on commit 022be97

Please sign in to comment.