Old lady swallowed a fly: Difference between revisions

m
→‎{{header|Go}}: Formatted using gofmt, added comment punctuation, limited to 80 columns (assuming an indentation width of 8 spaces).
(adding lambdatalk)
m (→‎{{header|Go}}: Formatted using gofmt, added comment punctuation, limited to 80 columns (assuming an indentation width of 8 spaces).)
Line 1,335:
 
=={{header|Go}}==
[https://play.golang.org/p/NwG13guusvOV3YJSWxaJP Go Playground]
<lang go>package main
 
Line 1,341:
 
var name, lyric, animals = 0, 1, [][]string{
{"fly", "I don't know why she swallowed a fly. Perhaps she'll die."},
{"spider", "That wiggled and jiggled and tickled inside her."},
{"bird", "How absurd, to swallow a bird."},
{"cat", "Imagine that, she swallowed a cat."},
{"dog", "What a hog, to swallow a dog."},
{"goat", "She just opened her throat and swallowed that goat."},
{"cow", "I don't know how she swallowed that cow."},
{"horse", "She's dead, of course."},
}
 
func main() {
for i, animal := range animals {
fmt.Printf("There was an old lady who swallowed a %s,\n", animal[name])
animal[name])
 
if i > 0 {
fmt.Println(animal[lyric])
}
}
 
// Swallowing the last animal signals her death, cutting the lyrics short
// lyrics short.
if i+1 == len(animals) {
break
break
}
}
 
for ; i > 0; i-- {
fmt.Printf("She swallowed the %s to catch the %s,\n", animals[i][name], animals[i-1][name])
animals[i][name], animals[i-1][name])
}
}
 
fmt.Println(animals[0][lyric] + "\n")
}
}
}</lang>