Erzeuge den Liedtext des Songs „I Know an Old Lady Who Swallowed a Fly".
Du könntest den Text natürlich kopieren und einfügen oder ihn aus einer Datei einlesen, aber dieses Problem ist viel interessanter, wenn du es algorithmisch angehst.
Dies ist ein kumulatives Lied unbekannten Ursprungs.
Dies ist eine von vielen gängigen Varianten.
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.
It 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.
How absurd to swallow a bird!
She swallowed the bird to catch the 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 cat.
Imagine that, to swallow a cat!
She swallowed the cat to catch the bird.
She swallowed the bird to catch the 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 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 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 goat.
Just opened her throat and swallowed a goat!
She swallowed the goat 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 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 cow.
I don't know how she swallowed a cow!
She swallowed the cow to catch the goat.
She swallowed the goat 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 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 horse.
She's dead, of course!
In dieser Übung geht es um Code-Refactoring, deshalb geben wir dir eine Lösung, die die Tests bereits besteht.
Die Herausforderung ist, sie so lange umzuschreiben, bis du stolz darauf bist, und dabei etwas zu lernen.
Wenn du nicht weißt, wo du anfangen sollst, hier ein paar Ideen:
Lass dir Zeit.
Ändere immer nur eine Sache und prüfe, ob deine Lösung die Tests weiterhin besteht.
Viel Spaß!
Melde dich bei Exercism an, um Haskell mit 107 Übungen und echtem menschlichen Mentoring zu lernen und zu meistern, alles kostenlos.