Created
November 23, 2012 18:56
-
-
Save yedi/4136844 to your computer and use it in GitHub Desktop.
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
; I'm trying to write this rhyme-scheme function which takes a poem(list of lines[strings]) and returns "abab" or "aabb" or "aaaa" for the rhyme scheme of the poem. THe length of the string should be the length of the line in the poems. | |
;I have this function classify-lines, that groups each line by it's end rhyme as shown below | |
;rhyme-finder.core> (classify-lines (get-poem "poems/abab.txt")) | |
;{("ey") ["i'm writing a poem today" "i don't care what you say"], ("eh" "l") ["i hope it turns out swell" "because we're all under a spell"]} | |
; This is how I started out, I'm kinda stuck on how the reduce function should go. | |
(defn rhyme-scheme [poem] | |
"returns the rhyme scheme of a poem" | |
(let [end-rhymes (classify-lines poem)] | |
(reduce | |
(fn [scheme line] | |
"" | |
poem))) | |
; abab.txt (should return "abab"): | |
; I'm writing a poem today | |
; I hope it turns out swell | |
; I don't care what you say | |
; because we're all under a spell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment