if-cdr-else   macro


Defined in:  https://github.com/lambdamusic/extempore-extensions/blob/main/init/init_lisp.xtm

Implementation

;
;; try to apply cdr to arg1, do it and return that, otherwise return arg2
;; if the arg1 list still has elements => True
;; used in temporal recursions to loop through a list, and eventually go back to a seed list
;; 2024-02-01: alias 'cdr-or-else' 
;;
;; example
;; (if-cdr-else '(a) '(a b)) ; => '(a b)
(define-macro (if-cdr-else list1 list2)
   `(if (null? (cdr ,list1))
        ,list2
        (cdr ,list1)))


Back to Index