Old lady swallowed a fly: Difference between revisions
Content added Content deleted
(→{{header|Java}}: use template) |
(→{{header|Haskell}}: shorter) |
||
Line 1,053: | Line 1,053: | ||
,"cat.\t\nImagine that. She swallowed a cat." |
,"cat.\t\nImagine that. She swallowed a cat." |
||
,"dog.\t\nWhat a hog to swallow a dog." |
,"dog.\t\nWhat a hog to swallow a dog." |
||
,"goat.\t\nShe just opened her throat and swallowed |
,"goat.\t\nShe just opened her throat and swallowed the goat." |
||
,"cow.\nI don't know how she swallowed |
,"cow.\nI don't know how she swallowed the cow." |
||
,"horse.\nShe's dead, of course."] |
,"horse.\nShe's dead, of course."] |
||
beginnings = map ("There was an old lady who swallowed a "++) animals |
beginnings = map ("There was an old lady who swallowed a "++) animals |
||
lastVerse = reverse $ ["She swallowed the "++takeWhile (/='.') y++" to catch the "++ takeWhile (/='\t') x |
|||
| (x:y:_:_)<-tails animals] |
|||
lastVerse = tail $ reverse $ zipWith swalloed animals $ tail animals |
|||
main = putStr $ concatMap unlines $ zipWith (:) beginnings $ |
main = putStr $ concatMap unlines $ zipWith (:) beginnings $ reverse $ ([]:) $ tails $ lastVerse</lang> |
||
{{out}}<pre>There was an old lady who swallowed a fly. |
{{out}}<pre>There was an old lady who swallowed a fly. |
||
I don't know why she swallowed a fly. |
I don't know why she swallowed a fly. |