Minor performance hack. Don't do this is real life kids, use macros instead.
This commit is contained in:
parent
9544bf41d5
commit
82696a1f61
|
@ -36,13 +36,12 @@ ConsList = ->
|
||||||
|
|
||||||
nil = (-> new ConsList())()
|
nil = (-> new ConsList())()
|
||||||
|
|
||||||
|
|
||||||
vectorp = (c) -> toString.call(c) == '[object Array]'
|
vectorp = (c) -> toString.call(c) == '[object Array]'
|
||||||
cellp = (c) -> !!c.isList
|
cellp = (c) -> !!c.isList
|
||||||
pairp = (c) -> c.isList and (c.length == 2)
|
pairp = (c) -> !!c.isList and (c.length == 2)
|
||||||
listp = (c) -> c.isList and (c.length == 2) and (cellp cdr c)
|
listp = (c) -> !!c.isList and (c.length == 2) and (cellp cdr c)
|
||||||
recordp = (c) -> Object.prototype.toString.call(c) == '[object Object]'
|
recordp = (c) -> Object.prototype.toString.call(c) == '[object Object]'
|
||||||
nilp = (c) -> cellp(c) and c.length == 0
|
nilp = (c) -> !!c.isList and c.length == 0
|
||||||
|
|
||||||
cons = (a = nil, b = nil) ->
|
cons = (a = nil, b = nil) ->
|
||||||
return nil if (nilp a) and (nilp b)
|
return nil if (nilp a) and (nilp b)
|
||||||
|
|
Loading…
Reference in New Issue