شعر کودکانهی «این خانهای است که جک ساخت» را بخوانید.
قرار دادن یک عبارت یا بند درون عبارت یا بند دیگر را «درونهگذاری» مینامند. از طریق فرایندهای بازگشتی و درونهگذاری است که میتوانیم تعدادی متناهی شکل (واژه و عبارت) برداریم و تعداد نامتناهی عبارت بسازیم. علاوه بر این، درونهگذاری به ما امکان میدهد ساختاری بینهایت طولانی بسازیم، دستکم در نظر.
شعر کودکانه چنین است:
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.
این تمرین دربارهی بازآرایی کد است، بنابراین راهحلی را در اختیار شما قرار میدهیم که از قبل تستها را پاس میکند.
چالش این است که آن را بازنویسی کنید تا به آن افتخار کنید و در این مسیر چیزی هم یاد بگیرید.
اگر نمیدانید از کجا شروع کنید، چند ایده داریم:
عجله نکنید.
هر بار فقط یک چیز را تغییر دهید و بررسی کنید که راهحل شما هنوز تستها را پاس میکند.
خوش بگذرانید!