guile-primer/11_extensibility.scm

41 lines
839 B
Scheme
Raw Permalink Normal View History

2024-03-13 23:52:40 +01:00
;; -*- geiser-scheme-implementation: guile -*-
(if (our-test)
(begin
(do-thing-1)
(do-thing-2)))
(define (when test . body)
`(if ,test
,(cons 'begin body)))
(when '(our-test)
'(do-thing-1)
'(do-thing-2))
; (if (our-test) (begin (do-thing-1) (do-thing-2)))
(define-macro (when test . body)
`(if ,test
,(cons 'begin body)))
(when (our-test)
(do-thing-1)
(do-thing-2))
(define-syntax-rule (when test body ...)
(if test
(begin body ...)))
(define-syntax-rule (for (item lst) body ...)
(for-each (lambda (item)
body ...)
lst))
(for (str '("strawberries" "bananas" "grapes"))
(display
(string-append "I just love "
(string-upcase str)
"!!!\n")))
; #<unspecified>