[bug] Cons would fail if the first argument was falsy. Not what I wanted.

This commit is contained in:
Elf M. Sternberg 2016-05-02 19:37:50 -07:00
parent 0d0430240d
commit 1bd3f27d85
2 changed files with 2 additions and 1 deletions

View File

@ -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?) then (new ConsList(a, b)) else (new ConsList(b))
nil = (-> new ConsList())()

View File

@ -9,6 +9,7 @@ expect = chai.expect
describe "Basic list building", ->
for [t, v] in [
[cons(), cons()]
[cons(0), [0, nil]]
[cons(nil), cons(nil)]
[cons('a'), cons('a')]
[cons('a', cons('b', cons('c'))), cons('a', cons('b', cons('c')))]