Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,28 @@
(define (get-mad-libs file)
(with-input-from-file file
(lambda ()
(for/fold ((text ""))
((line (in-lines)))
(string-append text line "\n")))))
(define (replace-context mad-libs)
(define matches
(regexp-match* #rx"<[a-zA-Z0-9 ]*>" mad-libs))
(map
(lambda (context)
(display (format "~a?" context))
(cons context (read-line)))
(remove-duplicates matches)))
(define (play-mad-libs)
(display "Tell me a file to play Mad Libs: ")
(define text (get-mad-libs (read-line)))
(define matches (replace-context text))
(display
(for/fold ((mad-story text))
((change (in-list matches)))
(string-replace mad-story (car change) (cdr change)))))
(play-mad-libs)