diff --git a/src/lists.coffee b/src/lists.coffee index aa2585b..1778a8c 100644 --- a/src/lists.coffee +++ b/src/lists.coffee @@ -35,7 +35,7 @@ _annotate = (ConsList) -> cons = (a = nil, b = nil) -> return (new ConsList()) if (nilp a) and (nilp b) - if (a?) then (new ConsList(a, b)) else (new ConsList(b)) + if (a != undefined) then (new ConsList(a, b)) else (new ConsList(b)) nil = (-> new ConsList())() diff --git a/test/lists.coffee b/test/lists.coffee index a7f026a..a9167eb 100644 --- a/test/lists.coffee +++ b/test/lists.coffee @@ -57,6 +57,7 @@ describe 'List Building', -> for [t, v] in [ [cons(), []] [cons(nil), []] + [cons(0), [0]] [cons('a'), ['a']] [cons('a', cons('b')), ['a', 'b']] [cons('a', cons('b', cons(nil))), ['a', 'b']] @@ -105,3 +106,12 @@ describe 'Metacadr Complex', -> expect(mcadr mccomplex).to.equal(v) expect(mcadr mccomplex).to.equal(v) expect(mcadr mccomplex).to.equal(v) + +mcnested = ['a', 'b', ['c', 'd'], 'e'] +describe "Nested and not-nested VTOL:", -> + it "Should handle the nested case, as before", -> + t = vectorToList(mcnested) + expect(metacadr('cadaddr')(t)).to.equal('d') + it "Should handle a not-nested set", -> + t = vectorToList(mcnested, 0, false) + expect(metacadr('caddr')(t)[0]).to.equal("c")