From e57593bc92abddfa68750167cd21c21f9119375c Mon Sep 17 00:00:00 2001 From: Pawel Marczewski Date: Sun, 17 Jun 2012 18:04:40 +0200 Subject: [PATCH] 'and' macro example --- test.html | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test.html b/test.html index 5903ae5..b0adbca 100644 --- a/test.html +++ b/test.html @@ -63,6 +63,16 @@ (cons (func (car list)) (map func (cdr list))))) (map (lambda (x) (+ x 1)) '(1 2 3)) + +; And macro example +(defmacro (and x . xs) + (if (empty? xs) + x + `(when ,x (and . ,xs)))) +(expand-code '(and a b c d)) +; and to demonstrate the short-circuit mechanism: +; ((unknown) should crash when run) +(and (= 2 2) (= 2 3) (unknown))