Created a secretive inheritance method for the compiler. You
don't need to see this, move along...
This commit is contained in:
parent
d23c849cf9
commit
950ea513c7
11
bin/activate
11
bin/activate
|
@ -6,3 +6,14 @@
|
||||||
PROJECT_ROOT=`pwd`
|
PROJECT_ROOT=`pwd`
|
||||||
PATH="$PROJECT_ROOT/bin:$PROJECT_ROOT/node_modules/.bin:$PATH"
|
PATH="$PROJECT_ROOT/bin:$PROJECT_ROOT/node_modules/.bin:$PATH"
|
||||||
export PATH
|
export PATH
|
||||||
|
|
||||||
|
if [ -z "$VIRTUAL_ENV_DISABLE_PROMPT" ] ; then
|
||||||
|
_OLD_VIRTUAL_PS1="$PS1"
|
||||||
|
if [ "x" != x ] ; then
|
||||||
|
PS1="$PS1"
|
||||||
|
else
|
||||||
|
PS1="(`basename \"$PROJECT_ROOT\"`)$PS1"
|
||||||
|
fi
|
||||||
|
export PS1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
|
@ -34,23 +34,25 @@ ConsList = ->
|
||||||
writeable: false
|
writeable: false
|
||||||
list
|
list
|
||||||
|
|
||||||
nil = (-> new ConsList())()
|
_annotate = (ConsList) ->
|
||||||
|
nilp = (c) -> !!c.isList and c.length == 0
|
||||||
|
|
||||||
vectorp = (c) -> toString.call(c) == '[object Array]'
|
cons = (a = nil, b = nil) ->
|
||||||
cellp = (c) -> !!c.isList
|
|
||||||
pairp = (c) -> !!c.isList and (c.length == 2)
|
|
||||||
listp = (c) -> !!c.isList and (c.length == 2) and (cellp cdr c)
|
|
||||||
recordp = (c) -> Object.prototype.toString.call(c) == '[object Object]'
|
|
||||||
nilp = (c) -> !!c.isList and c.length == 0
|
|
||||||
|
|
||||||
cons = (a = nil, b = nil) ->
|
|
||||||
return (new ConsList()) if (nilp a) and (nilp b)
|
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))
|
||||||
|
|
||||||
car = (c) -> c[0]
|
nil = (-> new ConsList())()
|
||||||
cdr = (c) -> c[1]
|
|
||||||
|
|
||||||
vectorToList = (v, p) ->
|
vectorp = (c) -> toString.call(c) == '[object Array]'
|
||||||
|
cellp = (c) -> !!c.isList
|
||||||
|
pairp = (c) -> !!c.isList and (c.length == 2)
|
||||||
|
listp = (c) -> !!c.isList and (c.length == 2) and (cellp cdr c)
|
||||||
|
recordp = (c) -> Object.prototype.toString.call(c) == '[object Object]'
|
||||||
|
|
||||||
|
car = (c) -> c[0]
|
||||||
|
cdr = (c) -> c[1]
|
||||||
|
|
||||||
|
vectorToList = (v, p) ->
|
||||||
p = if p? then p else 0
|
p = if p? then p else 0
|
||||||
if p >= v.length then return nil
|
if p >= v.length then return nil
|
||||||
# Annoying, but since lists are represented as nested arrays, they
|
# Annoying, but since lists are represented as nested arrays, they
|
||||||
|
@ -60,17 +62,17 @@ vectorToList = (v, p) ->
|
||||||
if vectorp(v[p]) then vectorToList(v[p]) else v[p]
|
if vectorp(v[p]) then vectorToList(v[p]) else v[p]
|
||||||
cons(item, vectorToList(v, p + 1))
|
cons(item, vectorToList(v, p + 1))
|
||||||
|
|
||||||
list = (v...) ->
|
list = (v...) ->
|
||||||
ln = v.length
|
ln = v.length
|
||||||
(nl = (a) ->
|
(nl = (a) ->
|
||||||
cons(v[a], if (a < ln) then (nl(a + 1)) else nil))(0)
|
cons(v[a], if (a < ln) then (nl(a + 1)) else nil))(0)
|
||||||
|
|
||||||
listToVector = (l, v = []) ->
|
listToVector = (l, v = []) ->
|
||||||
return v if nilp l
|
return v if nilp l
|
||||||
v.push if pairp (car l) then listToVector(car l) else (car l)
|
v.push if pairp (car l) then listToVector(car l) else (car l)
|
||||||
listToVector (cdr l), v
|
listToVector (cdr l), v
|
||||||
|
|
||||||
metacadr = (m) ->
|
metacadr = (m) ->
|
||||||
ops = {'a': car, 'd': cdr}
|
ops = {'a': car, 'd': cdr}
|
||||||
seq = vectorToList m.match(/c([ad]+)r/)[1].split('').reverse()
|
seq = vectorToList m.match(/c([ad]+)r/)[1].split('').reverse()
|
||||||
return (l) ->
|
return (l) ->
|
||||||
|
@ -79,7 +81,7 @@ metacadr = (m) ->
|
||||||
inner ops[(car s)](l), (cdr s)
|
inner ops[(car s)](l), (cdr s)
|
||||||
inner l, seq
|
inner l, seq
|
||||||
|
|
||||||
module.exports =
|
{
|
||||||
cons: cons
|
cons: cons
|
||||||
nil: nil
|
nil: nil
|
||||||
car: car
|
car: car
|
||||||
|
@ -104,3 +106,13 @@ module.exports =
|
||||||
caadr: (l) -> car (car (cdr l))
|
caadr: (l) -> car (car (cdr l))
|
||||||
cdadr: (l) -> cdr (car (cdr l))
|
cdadr: (l) -> cdr (car (cdr l))
|
||||||
metacadr: metacadr
|
metacadr: metacadr
|
||||||
|
}
|
||||||
|
|
||||||
|
_export = _annotate(ConsList)
|
||||||
|
Object.defineProperty _export, '_annotate',
|
||||||
|
value: _annotate
|
||||||
|
configurable: false,
|
||||||
|
enumerable: false,
|
||||||
|
writeable: false
|
||||||
|
|
||||||
|
module.exports = _export
|
||||||
|
|
Loading…
Reference in New Issue