123456789101112131415161718192021222324252627282930 |
- ;; Idea:
- ;; Write (thunk (+ a b)) instead of (lambda () (+ a b)).
- (import
- (except (rnrs base) let-values)
- (only (guile)
- lambda* λ))
- ;; A thunk is a lambda expression, which takes no arguments.
- (define-syntax thunk
- (syntax-rules ()
- [(thunk expr* ...)
- (lambda () expr* ...)]))
- ;; Usage example:
- (define higher-order-func
- (λ (message-displayer)
- (message-displayer)))
- (higher-order-func
- (thunk
- (display
- (simple-format #f "~s\n" "Hello!"))
- (display
- (simple-format #f "~s\n" "World!"))))
|