|
|
@ -55,7 +55,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
(assert-eq "flat test 1 failed" |
|
|
|
(assert-eq "flat test 1 failed" |
|
|
|
'(1 2 3 4 5 (6 7) 8) |
|
|
|
'(1 2 3 4 5 (6 7) 8) |
|
|
|
(flat '((1 2) (3 4) (5 (6 7) 8)))) |
|
|
|
(flat '((1 2) () (3 4) (5 (6 7) 8)))) |
|
|
|
|
|
|
|
|
|
|
|
(define (filter predicate) (reduce-right '() |
|
|
|
(define (filter predicate) (reduce-right '() |
|
|
|
(lambda (current accumulator) |
|
|
|
(lambda (current accumulator) |
|
|
@ -129,12 +129,9 @@ |
|
|
|
((compose (list |
|
|
|
((compose (list |
|
|
|
(coalesce-not-empty (lambda () (f (cdr values)))) |
|
|
|
(coalesce-not-empty (lambda () (f (cdr values)))) |
|
|
|
flat |
|
|
|
flat |
|
|
|
(filter id) |
|
|
|
(map (lambda (token) ((compose (list |
|
|
|
(map |
|
|
|
|
|
|
|
(lambda (token) |
|
|
|
|
|
|
|
((truthy-chaining (compose (list |
|
|
|
|
|
|
|
(map (prepend (car token))) |
|
|
|
(map (prepend (car token))) |
|
|
|
(lambda (rest) (f (next rest values)))))) |
|
|
|
(lambda (rest) (if rest (f (next rest values)) '())))) |
|
|
|
(starts-with (cdr token) values)))))) |
|
|
|
(starts-with (cdr token) values)))))) |
|
|
|
tokens)))))) |
|
|
|
tokens)))))) |
|
|
|
|
|
|
|
|
|
|
|