Reverse works, but not prettily.

This commit is contained in:
Elf M. Sternberg 2015-06-23 08:09:20 -07:00
parent c5008cdb5d
commit c34a0f391b
1 changed files with 8 additions and 8 deletions

View File

@ -23,21 +23,21 @@ map = (lst, iteratee, context, count = 0) ->
cons product, rest
rmap = (lst, iteratee, context, count = 0) ->
return nil if nilp lst
rest = (if (nilp cdr lst) then nil else
map((cdr lst), iteratee, context, count + 1))
product =, (car lst), count, lst)
cons rest, product
ptr = lst
ret = cons()
while not nilp ptr
ret = cons (car ptr), ret
ptr = cdr ptr
reverse = (lst) -> rmap lst, (i) -> i
filter = (lst, iteratee, context) ->
return nil if nilp lst
if, (car lst), lst)
cons (car lst), filter (cdr lst), iteratee, context
cons (car lst), (filter (cdr lst), iteratee, context)
filter (cdr list), iteratee, context
filter (cdr lst), iteratee, context
module.exports =
reduce: reduce