Jump to content

Old lady swallowed a fly: Difference between revisions

Added Julia language
(Added a link to scratch implementation)
(Added Julia language)
Line 1,222:
}
}</lang>
 
=={{header|Julia}}==
{{works with|Julia|0.6}}
 
<lang julia>using CodecZlib
 
b64 = b"""eNrtVE1rwzAMvedXaKdeRn7ENrb21rHCzmrs1m49K9gOJv9+cko/HBcGg0LHcpOfnq2np0QL
2FuKgBbICDAoeoiKwEc0hqIUgLAxfV0tQJCdhQM7qh68kheswKeBt5ROYetTemYMCC3rii//
WMS3WkhXVyuFAaLT261JuBWwu4iDbvYp1tYzHVS68VEIObwFgaDB0KizuFs38aSdqKv3TgcJ
uPYdn2B1opwIpeKE53qPftxRd88Y6uoVbdPzWxznrQ3ZUi3DudQ/bcELbevqM32iCIrj3IIh
W6plOJf6L6xaajZjzqW/qAsKIvITBGs9Nm3glboZzkVP5l6Y+0bHLnedD0CttIyrpEU5Kv7N
Mz3XkPBc/TSN3yxGiqMiipHRekycK0ZwMhM8jerGC9zuZaoTho3kMKSfJjLaF8v8wLzmXMqM
zJvGew/jnZPzclA08yAkikegDTTUMfzwDXBcwoE="""
println(String(transcode(ZlibDecompressor(), base64decode(b64))))</lang>
 
<lang julia>animals = [
("fly", "I don't know why she swallowed a fly, perhaps she'll die."),
("spider", "It 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 a goat."),
("cow", "I don't know how she swallowed a cow."),
("horse", "She's dead, of course.")]
 
for (i, (animal, lyric)) in enumerate(animals)
println("There was an old lady who swallowed a $animal.\n$lyric")
 
if animal == "horse" break end
 
for ((predator, _), (prey, _)) in zip(animals[i:-1:1], animals[i-1:-1:1])
println("\tShe swallowed the $predator to catch the $prey")
end
 
if animal != "fly" println(animals[1][2]) end # fly lyric
println() # new line
end</lang>
 
=={{header|Kotlin}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.