Old lady swallowed a fly: Difference between revisions

(→‎{{header|Vlang}}: Rename "Vlang" in "V (Vlang)")
Line 2,279:
}
}</syntaxhighlight>
 
=={{header|jq}}==
'''Adapted from [[#Wren|Wren]]'''
{{works with|jq}}
'''Also works with gojq and fq, the Go implementations'''
<syntaxhighlight lang=jq>
def animals:
["fly", "spider", "bird", "cat", "dog", "goat", "cow", "horse"];
 
def phrases: [
null,
"That wriggled and jiggled and tickled inside her",
"How absurd to swallow a bird",
"Fancy that to swallow a cat",
"What a hog, to swallow a dog",
"She just opened her throat and swallowed a goat",
"I don't know how she swallowed a cow",
"\n ...She's dead of course"
];
 
def sing:
range(0; animals|length) as $i
| "There was an old lady who swallowed a \(animals[$i]);",
( phrases[$i] // empty | "\(.)!" ),
( if $i < 7
then "",
(if $i > 0
then range($i; 0; -1) as $j
| " She swallowed the \(animals[$j]) to catch the \(
animals[$j - 1])\(if $j < 3 then ";" else "," end)",
(select($j == 2) | " \(phrases[1])!")
else empty
end),
" I don't know why she swallowed a fly - Perhaps she'll die!\n"
else empty
end) ;
 
sing
</syntaxhighlight>
{{output}}
As for [[#Wren|Wren]].
 
=={{header|Julia}}==
2,489

edits