| In the movie The Princess Bride, the characters Inigo and Fezzik have a rhyming game they like to play, especially when their cruel boss, Vizzini, yells at them: Inigo: That Vizzini, he can fuss. Fezzik: I think he likes to scream at us. Inigo: Probably he means no harm. Fezzik: He’s really very short on charm. |
When I was writing the alternate.txt for the Gashlycrumb exercise, I would come up with a word like "cyanide" and wonder what I could rhyme with that. Mentally I start with the first consonant sound of the alphabet and start substituting "b" for "byanide," skip "c" because that’s already the first character, then "d" for "dynanide," and so forth. This is effective but tedious, so I decided to write a program to do this for me, as one does.
This is basically another find-and-replace type of program that we’ve seen before like swapping all the numbers in a string in "Jump The Five" or all the vowels in a string in "Apples and Bananas." We wrote those programs using very manual, imperative methods like iterating through all the characters of a string, comparing them to some wanted value, and possibly returning a new value.