package house import "strings" func Embed(relPhrase, nounPhrase string) string { return relPhrase + " " + nounPhrase } func Verse(subject string, relPhrases []string, nounPhrase string) string { return subject + " " + strings.Join(append(relPhrases, nounPhrase), " ") } var items = [][]string{ {"lay in", "the house that Jack built."}, {"ate", "the malt"}, {"killed", "the rat"}, {"worried", "the cat"}, {"tossed", "the dog"}, {"milked", "the cow with the crumpled horn"}, {"kissed", "the maiden all forlorn"}, {"married", "the man all tattered and torn"}, {"woke", "the priest all shaven and shorn"}, {"kept", "the rooster that crowed in the morn"}, {"belonged to", "the farmer sowing his corn"}, {"", "the horse and the hound and the horn"}, } func Song() string { var s []string for k, v := range items { s = append(s, "This is "+v[1]) for i := k - 1; i >= 0; i-- { s = append(s, "that "+strings.Join(items[i], " ")) } if k != len(items)-1 { s = append(s, "") } } return strings.Join(s, "\n") }