Created
February 16, 2021 22:15
-
-
Save shaunagm/39c796dcb51666d0fa7848bb79eb2000 to your computer and use it in GitHub Desktop.
Madlibs Iteration 4
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 | |
(define cat-story (list | |
"There once was a cat named ~a who lived in ~a" | |
"Name: " | |
"Location: ")) | |
(define pirate-story (list | |
"A pirate named ~a roamed the high seas of ~a in ~a ship. It was a ~a day when suddenly there came ~a from a distance." | |
"Name: " | |
"Location: " | |
"Pronoun: " | |
"Adjective: " | |
"Noun: ")) | |
(define (run-prompt prompt) | |
(display prompt) | |
(read-line)) | |
(define (print-story template answers) | |
(apply printf template answers)) | |
(define (tell-story story) | |
(print-story | |
(first story) | |
(for/list ([prompt (rest story)]) | |
(run-prompt prompt)) | |
) | |
) | |
(tell-story cat-story) | |
(tell-story pirate-story) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment