From 2416a843abadbca4ee6ffa7ea08dfa2b544a2a9f Mon Sep 17 00:00:00 2001 From: Brady McDonough Date: Mon, 18 Jan 2021 23:33:49 -0700 Subject: [PATCH] Added (fcons) which I'm still not sure about --- tk/listlogic.scm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tk/listlogic.scm b/tk/listlogic.scm index 885e51f..5e11bbe 100644 --- a/tk/listlogic.scm +++ b/tk/listlogic.scm @@ -18,6 +18,17 @@ ;;the entries in that list are 'unwrapped'. This occurs recursively. (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 ;;as that evauluation results in #t. (define (lp& p ls1 ls2)