package house
import (
"strings"
)
var words = []string{
"house",
"malt",
"rat",
"cat",
"dog",
"cow with the crumpled horn",
"maiden all forlorn",
"man all tattered and torn",
"priest all shaven and shorn",
"rooster that crowed in the morn",
"farmer sowing his corn",
"horse and the hound and the horn",
}
var doWords = []string{
"",
"\nthat lay in the ",
"\nthat ate the ",
"\nthat killed the ",
"\nthat worried the ",
"\nthat tossed the ",
"\nthat milked the ",
"\nthat kissed the ",
"\nthat married the ",
"\nthat woke the ",
"\nthat kept the ",
"\nthat belonged to the ",
}
func Verse(v int) string {
var ret strings.Builder
ret.WriteString("This is the ")
ret.WriteString(writeVerse(v))
ret.WriteString(" that Jack built.")
return ret.String()
}
func Song() string {
const verses = 12
var ret strings.Builder
for i := 1; i < verses+1; i++ {
ret.WriteString(Verse(i))
if i != verses {
ret.WriteString("\n\n")
}
}
return ret.String()
}
func writeVerse(v int) string {
var ret strings.Builder
if v < 1 {
return ret.String()
}
ret.WriteString(words[v-1])
ret.WriteString(doWords[v-1])
ret.WriteString(writeVerse(v - 1))
return ret.String()
}