cond-list pasted by alaricsp on Tue Apr 8 12:25:55 2014
(define-syntax cond-list (syntax-rules () ((cond-list) (list)) ((cond-list (c e) . rest) (if c (cons e (cond-list . rest)) (cond-list . rest))))) #;2> (cond-list) () #;3> (cond-list (#t 1) (#t 2)) (1 2) #;4> (cond-list (#t 1) (#f 2)) (1) #;5> (cond-list (#f 1) (#f 2)) () #;6> (cond-list (#f 1) (#t 2)) (2)
cond-list generating less code pasted by DerGuteMoritz on Tue Apr 8 16:21:21 2014
(define-syntax cond-list
(syntax-rules ()
((cond-list) (list))
((cond-list (c e) ...)
(let ((tail (cond-list rest ...)))
(if c
(cons e tail)
tail)))))
fixed a typo in DerGetMoritz's version added by alaricsp on Tue Apr 8 16:24:39 2014
(define-syntax cond-list
(syntax-rules ()
((cond-list) (list))
((cond-list (c e) rest ...)
(let ((tail (cond-list rest ...)))
(if c
(cons e tail)
tail)))))