Old lady swallowed a fly: Difference between revisions
Content deleted Content added
m →{{header|Sidef}}: modified code to work with the latest version of Sidef |
|||
Line 1,119: | Line 1,119: | ||
}</lang> |
}</lang> |
||
And that's how I larned it! |
And that's how I larned it! |
||
=={{header|Phix}}== |
|||
{{Trans|Ada}} |
|||
<lang Phix>sequence lines = {"Perhaps she'll die!\n"}, animals = {} |
|||
procedure swallow(string animal, second_line, integer permanent_second_line=TRUE) |
|||
printf(1,"There was an old lady who swallowed a %s,\n%s\n",{animal,second_line}) |
|||
if length(animals)!=0 then |
|||
lines = prepend(lines,sprintf("She swallowed the %s to catch the %s,\n",{animal,animals[$]})) |
|||
end if |
|||
printf(1,"%s\n",{join(lines,"")}) |
|||
if permanent_second_line then |
|||
lines = prepend(lines,second_line&"\n") |
|||
end if |
|||
animals = append(animals,animal) |
|||
end procedure |
|||
procedure swallow_all(sequence all) |
|||
for i=1 to length(all) do |
|||
string {animal,line2} = all[i] |
|||
swallow(animal, sprintf("%s, %s a %s;",{line2,iff(animal="cow"?"she swallowed":"to swallow"),animal}), FALSE); |
|||
end for |
|||
end procedure |
|||
swallow("fly", "But I don't know why she swallowed the fly,"); |
|||
swallow("spider", "That wriggled and jiggled and tickled inside her;"); |
|||
swallow_all({{"bird", "Quite absurd"},{"cat", "Fancy that"},{"dog", "What a hog"}, |
|||
{"pig", "Her mouth was so big"},{"goat","She just opened her throat"}, |
|||
{"cow", "I don't know how"},{"donkey", "It was rather wonky"}}) |
|||
printf(1, "There was an old lady who swallowed a horse ...\nShe's dead, of course!")</lang> |
|||
=={{header|PHP}}== |
=={{header|PHP}}== |