Created
February 16, 2021 20:56
-
-
Save shaunagm/48f22544dae2f6908b027008edb7b136 to your computer and use it in GitHub Desktop.
Racket madlibs iteration 5
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 at-exp racket | |
(define-namespace-anchor a) | |
(define ns (namespace-anchor->namespace a)) | |
(define tree-story (list | |
`@~a{There once was a big @treetype tree in the old forest of @location. | |
It was tended by a @job named @name. @name was nearly @count years | |
old and she was very tired of tending her @treetype tree."} | |
(list `treetype "Type of thing: ") | |
(list `location "Location: ") | |
(list `job "Job: ") | |
(list `name "Name: ") | |
(list `count "Number: "))) | |
(define (run-prompt prompt) | |
(display (second prompt)) | |
(define (eval (first prompt)) (read-line)) | |
(first prompt)) | |
(define (tell-story story) | |
(for/list ([prompt (rest story)]) | |
(run-prompt prompt)) | |
(eval (first story) ns)) | |
(tell-story tree-story) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment