Skip to content

Instantly share code, notes, and snippets.

@yedi
Created November 23, 2012 18: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 yedi/4136844 to your computer and use it in GitHub Desktop.
Save yedi/4136844 to your computer and use it in GitHub Desktop.
; 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