Skip to content

Instantly share code, notes, and snippets.

@shaunagm
Created February 16, 2021 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shaunagm/48f22544dae2f6908b027008edb7b136 to your computer and use it in GitHub Desktop.
Save shaunagm/48f22544dae2f6908b027008edb7b136 to your computer and use it in GitHub Desktop.
Racket madlibs iteration 5
#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