Added (fcons) which I'm still not sure about

master
Brady McDonough 5 years ago
parent e305992892
commit 2416a843ab

@ -18,6 +18,17 @@
;;the entries in that list are 'unwrapped'. This occurs recursively. ;;the entries in that list are 'unwrapped'. This occurs recursively.
(define (flatten lst) (flatten-helper lst '() '())) (define (flatten lst) (flatten-helper lst '() '()))
;; A flat cons. Normal cons returns a list with a nested association in the
;;car position if x is a list, this function eliminates that assocation,
;;recursively "flattening" x and combining it's cdr with y.
(define (fcons x y)
(cond ((pair? x)
(fcons (car x) (fcons (cdr x) y)))
((null? x)
y)
(else
(cons x y))))
;; Evaluates (p (car ls1) (car ls2)) and accumulate into a return list as long ;; Evaluates (p (car ls1) (car ls2)) and accumulate into a return list as long
;;as that evauluation results in #t. ;;as that evauluation results in #t.
(define (lp& p ls1 ls2) (define (lp& p ls1 ls2)

Loading…
Cancel
Save