Created
November 16, 2012 21:01
-
-
Save anonymous/4090877 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(provide daddy-brings-worms | |
momma-sits) | |
(module nest racket | |
(provide eggs chicks lay-egg hatch) | |
(define eggs 0) | |
(define chicks 0) | |
(define (hatch) | |
(if (> eggs 0) | |
(begin | |
(set! eggs (sub1 eggs)) | |
(set! chicks (add1 chicks))) | |
(void))) | |
(define (lay-egg) | |
(set! eggs (add1 eggs)))) | |
(module birds racket | |
(provide | |
daddy-brings-worms | |
momma-sits) | |
(require | |
(for-syntax syntax/parse) | |
(for-meta 1 (submod ".." nest))) | |
(define-syntax (daddy-brings-worms stx) | |
(syntax-parse stx | |
[(_) | |
(lay-egg) | |
(with-syntax ((nest-state (cons eggs chicks))) | |
#''nest-state)])) | |
(define-syntax (momma-sits stx) | |
(syntax-parse stx | |
[(_) | |
(hatch) | |
(with-syntax ((nest-state (cons eggs chicks))) | |
#''nest-state)])) | |
) | |
(require (submod "." birds)) | |
(define the-nest | |
(begin | |
(daddy-brings-worms) | |
(momma-sits) | |
(daddy-brings-worms))) | |
the-nest | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment