Talk:Old lady swallowed a fly

From Rosetta Code

“Where's my cow?”

“I knew an old lady who swallowed a cow. I don't know how she swallowed the cow.” –Donal Fellows 23:34, 15 August 2011 (UTC)

Here--Dgamey 00:03, 16 August 2011 (UTC)
Go ahead and implement a correct version, and mark my PHP example incorrect. --Michael Mol 00:52, 16 August 2011 (UTC)
Multiple versions wp:There_Was_an_Old_Lady_Who_Swallowed_a_Fly and goats and donkeys too it seems. There are also alternate choruses. --Dgamey 12:12, 17 August 2011 (UTC)
Someone really should make a decision on which version to use before there are more solutions, or Paddy will have a heartattack later when he sees that every program produces a different output. Maybe take a vote or something? --Ledrug 18:50, 17 August 2011 (UTC)
I vote for the primary version described on the wikipedia page. --Rdm 19:09, 17 August 2011 (UTC)
Something like this? Seems to be too many animals. (feel free to correct or delete in case of copyright lawyers)
I was thinking of something slightly different: --Rdm 13:18, 18 August 2011 (UTC)
I know an old lady who swallowed a fly.
I don't know why she swallowed the fly.
Perhaps she'll die.

I know an old lady who swallowed a spider.
That wriggled and jiggled and tickled inside her.
She swallowed the spider to catch the fly.
I don't know why she swallowed the fly.
Perhaps she'll die.

I know an old lady who swallowed a Bird.
Quite absurd. To swallow a Bird.
She swallowed the Bird to catch the spider.
She swallowed the spider to catch the fly.
I don't know why she swallowed the fly.
Perhaps she'll die.

I know an old lady who swallowed a Cat.
Fancy that. To swallow a Cat.
She swallowed the Cat to catch the Bird.
She swallowed the Bird to catch the spider.
She swallowed the spider to catch the fly.
I don't know why she swallowed the fly.
Perhaps she'll die.

I know an old lady who swallowed a Dog.
What a hog. To swallow a Dog.
She swallowed the Dog to catch the Cat.
She swallowed the Cat to catch the Bird.
She swallowed the Bird to catch the spider.
She swallowed the spider to catch the fly.
I don't know why she swallowed the fly.
Perhaps she'll die.

I know an old lady who swallowed a Pig.
Her mouth was so big. To swallow a Pig.
She swallowed the Pig to catch the Dog.
She swallowed the Dog to catch the Cat.
She swallowed the Cat to catch the Bird.
She swallowed the Bird to catch the spider.
She swallowed the spider to catch the fly.
I don't know why she swallowed the fly.
Perhaps she'll die.

I know an old lady who swallowed a Goat.
She just opened her throat. To swallow a Goat.
She swallowed the Goat to catch the Pig.
She swallowed the Pig to catch the Dog.
She swallowed the Dog to catch the Cat.
She swallowed the Cat to catch the Bird.
She swallowed the Bird to catch the spider.
She swallowed the spider to catch the fly.
I don't know why she swallowed the fly.
Perhaps she'll die.

I know an old lady who swallowed a Cow.
I don't know how. To swallow a Cow.
She swallowed the Cow to catch the Goat.
She swallowed the Goat to catch the Pig.
She swallowed the Pig to catch the Dog.
She swallowed the Dog to catch the Cat.
She swallowed the Cat to catch the Bird.
She swallowed the Bird to catch the spider.
She swallowed the spider to catch the fly.
I don't know why she swallowed the fly.
Perhaps she'll die.

I know an old lady who swallowed a Donkey.
It was rather wonky. To swallow a Donkey.
She swallowed the Donkey to catch the Cow.
She swallowed the Cow to catch the Goat.
She swallowed the Goat to catch the Pig.
She swallowed the Pig to catch the Dog.
She swallowed the Dog to catch the Cat.
She swallowed the Cat to catch the Bird.
She swallowed the Bird to catch the spider.
She swallowed the spider to catch the fly.
I don't know why she swallowed the fly.
Perhaps she'll die.

I know an old lady who swallowed a Horse.
She's dead, of course!

(comment remaining from an older version:)

Works for me. --Michael Mol 12:54, 18 August 2011 (UTC)
I found some (traditional) lyrics online for this song http://www.timmyabell.com/music/lyrics/ol/oldlady.htm, and almost all of second lines of each verse have exclamation marks. Also, the explanation about the spider is repeated in each verse (which makes better singing). -- Gerard Schildberger 05:28, 30 October 2012 (UTC)
Also, it's (sometimes) traditional for the lines of songs to be centered (but not universally, of course). -- Gerard Schildberger 05:28, 30 October 2012 (UTC)

This section shares only a title with this book by an excellent author.

Compression types

I wonder if the Tcl version is too much of a cheat. I just took the above text and compressed and encoded it, then wrapped a trivial decoder around it. Still, a fun little solution that obeys the challenge in a different way. –Donal Fellows 19:12, 20 August 2011 (UTC)

Compression is the most obvious way to utilize repeatitions of strings, so it's fine in my book (C code does compression, only with a crude home made compression scheme because it was more fun to me). --Ledrug 23:41, 20 August 2011 (UTC)

Really, only the (Un)Icon, J, Forth and PHP examples really approach it from the direction I had in mind (specifically using the verse and repetitive semantic structure). That said, the C, D and Tcl examples are wonderful examples of compression, and I think they make for interesting directions, too. My intent was for this example to be in the spirit of 99 Bottles of Beer, with a variety of possible approaches taken. --Michael Mol 01:43, 21 August 2011 (UTC)


But surely decompression by another external program leaves too little for the task to be solved by a particular language (as was the case in Perl - now changed)? --Paddy3118 04:19, 31 August 2011 (UTC)
I agree; I don't care for the example calling out to another program to handle the decompression. I noted those examples because they were handling the decompression, at least, 'in-house'. It's nicely illustrative of decompression when you can read and recognized the raw compressed data by eye. --Michael Mol 13:50, 31 August 2011 (UTC)
It really doesn't make a difference. Now Perl code uses modules to do the decompression, which uses libbz2 just like bunzip2 program, and I ended up doing exactly the same amount of work. I don't see how this better fits the spirit of the task, not to mention that Perl is a glue language, and calling system commands is its thing anyway. --Ledrug 05:04, 31 August 2011 (UTC)
Computational work, sure. It's the illustration of the process that I find interesting. --Michael Mol 13:50, 31 August 2011 (UTC)
(deindent) Well, that's what I was saying: using a module you didn't write to do the decompression doesn't illustrate anything more than calling a shell command does, since the dirty work is hidden from view anyway. Once you decide to use deflate or bzip2, all you know is the uuencoded string will become some incomprehensible binary hodgepodge that a library somewhere will decode for you, I really don't see a difference whether the lib is invoked by Module::Inflate or /bin/unzip. --Ledrug 15:49, 31 August 2011 (UTC)
Which I agree isn't as interesting. Currently, the C, D and PicoLisp examples rate higher than the Tcl, Python and Perl examples in terms of what I find interesting and illustrative for compression algorithms. Tcl, Python and Perl examples are illustrative of packing data into source code. While I don't think this task is particularly successful yet (the examples should probably be subclassified for the direction of their solution--compression, semantic assembly or some other technique.), the examples noted do raise interesting ideas for other tasks. Again, I particularly like how the C, D and PicoLisp's examples data is readable and recognizable prior to decompression. I'd be interested in seeing a task that used that property to illustrate the compression and decompression sides of a compression algorithm. (Though perhaps the 99 Bottles of Beer song would be a better basis). As for the direction Tcl, Perl and Python took, there's probably use for a task explicitly invoking that behavior in a program; it bears some resemblance to self-extracting programs which serve as the basis for the installers for many software programs. --Michael Mol
I created the task on a whim. It was somewhat like dropping a grain of sand into a supersaturated solution; it's very interesting and inspiring looking at the different kinds of things that are precipitating. --Michael Mol 17:09, 31 August 2011 (UTC)
Calling out to OS utilities makes the program OS specific. At least in Python, using the standard modules for decompression etc makes the code work on many more OS's. --Paddy3118 20:20, 31 August 2011 (UTC)
Honestly, I'm not terribly worried about that as a requirement. Obviously, use of bundled or more generalized options should be favored, but "calling out" isn't intrinsically wrong. (Except where it's particularly unidiomatic for the problem for the language. "calling out" is probably appropriate in Perl, but probably not appropriate in Python or PHP) In general, this has usually been handled on RC by showing multiple solutions per language. --Michael Mol 20:44, 31 August 2011 (UTC)
That's true -- heeeey, but that's not what you argued for earlier. In any event, it's a moot point, because using zip or bzip2 doesn't make a particularly interesting program. --Ledrug 20:56, 31 August 2011 (UTC)

Copyright!

According to this and this and this the song is not that old and has an author. I note that none of those quote the lyrics so I think we may be on shaky copyright grounds. --Paddy3118 06:10, 16 August 2011 (UTC)

If it was registered in 1951, it may have fallen out of copyright. All works published in the US prior to a date (somewhere in the 1930s?) will have fallen out of copyright, but some afterward will have as well, depending on whether they bothered to renew their registrations. I'm not an expert on the subject, though. Trying to identify how to look up registration history on a work. Otherwise, yeah, that stands to be a major problem. --Michael Mol 13:25, 16 August 2011 (UTC)
We should also note that the recording industry is known to a bunch of litigious <insert your own appropriate word here>. Which is another reason to err on the side of caution. --Paddy3118 15:47, 16 August 2011 (UTC)
Believe me, I'm unlikely to forget. I've lived with a paranoia about the RIAA for over a decade. I've removed the program results, and the code itself is incorrect, though it probably qualifies as a derivative work. I wonder if the current LOC exemptions set for the DMCA includes this form of 'educational use.' That said, I don't think they're going to care terribly much. I still want to look into when/if copyright was registered (the song was produced before things were automagically copyrighted without registration). If I can show that the copyright fell out of registration, or that a current LOC exemption would include RC, then I'd be comfortable moving forward with the task. If I get a DMCA notice, I'll take it down and replace it with an explanation of all the facts and a link to [chillingeffects.org chillingeffects.org]. I won't fight something in a way I can't afford to fight it.--Michael Mol 16:10, 16 August 2011 (UTC)
Actually, most implementations in code probably constitute fair use. The code is no more a derivative work of the song than a publication that describes the characters in the harry potter novels would be a derivative work of the novels. Any argument that code being asked for here is derivative of the song, for copyright purposes, would probably be an argument that the song is not a creative work. --Rdm 17:34, 17 August 2011 (UTC)

Lyrics Versions

The PHP example is tagged incorrect because its output does not match, but given that it seems that several versions of this song exist and that the result is not like a mathematical result, maybe we could avoid to care about this, what do you think?

I suspect that all solutions are incorrect, because their lyrics are not matching these lyrics from 1993. The old lady never swallows a donkey. After she swallows a horse, "She's alive and well of course!" --Kernigh 23:52, 2 September 2011 (UTC)
I think that those are lyrics. I do not think that those are the only lyrics. So if all solutions are wrong because they do not match those particular lyrics they would also be wrong if they matched those lyrics (because in matching those lyrics they would not match other lyrics that began the same way). --Rdm 12:03, 3 September 2011 (UTC)