Recite a cantiga infantil 'This is the House that Jack Built'.
[O] processo de colocar uma frase ou oração dentro de outra frase ou oração é chamado de encaixe. É por meio dos processos de recursão e encaixe que conseguimos pegar um número finito de formas (palavras e frases) e construir um número infinito de expressões. Além disso, o encaixe também nos permite construir uma estrutura infinitamente longa, em teoria, pelo menos.
A cantiga infantil é a seguinte:
This is the house that Jack built.
This is the malt
that lay in the house that Jack built.
This is the rat
that ate the malt
that lay in the house that Jack built.
This is the cat
that killed the rat
that ate the malt
that lay in the house that Jack built.
This is the dog
that worried the cat
that killed the rat
that ate the malt
that lay in the house that Jack built.
This is the cow with the crumpled horn
that tossed the dog
that worried the cat
that killed the rat
that ate the malt
that lay in the house that Jack built.
This is the maiden all forlorn
that milked the cow with the crumpled horn
that tossed the dog
that worried the cat
that killed the rat
that ate the malt
that lay in the house that Jack built.
This is the man all tattered and torn
that kissed the maiden all forlorn
that milked the cow with the crumpled horn
that tossed the dog
that worried the cat
that killed the rat
that ate the malt
that lay in the house that Jack built.
This is the priest all shaven and shorn
that married the man all tattered and torn
that kissed the maiden all forlorn
that milked the cow with the crumpled horn
that tossed the dog
that worried the cat
that killed the rat
that ate the malt
that lay in the house that Jack built.
This is the rooster that crowed in the morn
that woke the priest all shaven and shorn
that married the man all tattered and torn
that kissed the maiden all forlorn
that milked the cow with the crumpled horn
that tossed the dog
that worried the cat
that killed the rat
that ate the malt
that lay in the house that Jack built.
This is the farmer sowing his corn
that kept the rooster that crowed in the morn
that woke the priest all shaven and shorn
that married the man all tattered and torn
that kissed the maiden all forlorn
that milked the cow with the crumpled horn
that tossed the dog
that worried the cat
that killed the rat
that ate the malt
that lay in the house that Jack built.
This is the horse and the hound and the horn
that belonged to the farmer sowing his corn
that kept the rooster that crowed in the morn
that woke the priest all shaven and shorn
that married the man all tattered and torn
that kissed the maiden all forlorn
that milked the cow with the crumpled horn
that tossed the dog
that worried the cat
that killed the rat
that ate the malt
that lay in the house that Jack built.
Este exercício é sobre refatoração de código, então fornecemos para você uma solução que já passa nos testes.
O desafio é reescrevê-la até você se orgulhar dela e aprender algo no processo.
Se você não sabe por onde começar, aqui vão algumas ideias:
Sem pressa.
Mude uma coisa de cada vez e verifique se a sua solução ainda passa nos testes.
Divirta-se!
Crie sua conta no Exercism para aprender e dominar Haskell com 107 exercícios e mentoria humana de verdade, tudo de graça.