Much better toString() operatin for cons lists.
This commit is contained in:
parent
762e8a4393
commit
0d0430240d
|
@ -18,17 +18,13 @@ ConsList = ->
|
||||||
writeable: false
|
writeable: false
|
||||||
Object.defineProperty list, 'toString',
|
Object.defineProperty list, 'toString',
|
||||||
value: ->
|
value: ->
|
||||||
return '()' if this.length == 0
|
helper = (node) ->
|
||||||
rs = if this.length == 2
|
return "" if node.length == 0
|
||||||
if this[1].isList
|
return node[0].toString() if node.length == 1
|
||||||
if this[1].length == 1 then ""
|
return node[0].toString() + " . " + node[1].toString() if not node[1].isList
|
||||||
else
|
return node[0].toString() if node[1].length == 0
|
||||||
' ' + this[1].toString()
|
return node[0].toString() + " " + helper(node[1])
|
||||||
else
|
'(' + helper(this) + ')'
|
||||||
' . ' + this[1].toString()
|
|
||||||
else
|
|
||||||
' ' + this[1].toString()
|
|
||||||
'(' + this[0] + rs + ')'
|
|
||||||
configurable: false,
|
configurable: false,
|
||||||
enumerable: false,
|
enumerable: false,
|
||||||
writeable: false
|
writeable: false
|
||||||
|
|
Loading…
Reference in New Issue