diff --git a/tk/listlogic.scm b/tk/listlogic.scm index e51af53..9c11da8 100644 --- a/tk/listlogic.scm +++ b/tk/listlogic.scm @@ -2,7 +2,7 @@ #:export (flatten lp& l& - ) + if-some) #:duplicates (warn-override-core warn )) (define (flatten-helper lst acc stk) @@ -37,8 +37,7 @@ '()) ((p (car ls1) (car ls2)) (cons (car ls1) (loop (cdr ls1) (cdr ls2)))) - (else '()) - ))) + (else '())))) ;; Collect entries from the beginning of the given lists as long as those ;;entries are equivalent according to (eqv?) @@ -46,3 +45,6 @@ (cond ((eqv? ls1 ls2) ls1) (else (lp& eqv? ls1 ls2)))) +;; Returns the argument if it isn't #f, otherwise returns the empty list +(define (if-some $cond) + (if $cond $cond '()))