New (simple) Lazy Evaluation tutorial

Hi all, An interesting question came up in #haskell the other day, and I took the resulting discussion and wrapped it up into a simple tutorial for the wiki. Since I'm quite a newbie to haskell myself, I'd appreciate any double-checking of my logic and, of course, any other comments/suggestions. Thanks to Cale for his efforts on this problem, and to the original asker, whose name I can't recall. http://www.haskell.org/haskellwiki/Haskell/Lazy_Evaluation

Andrew Wagner wrote:
Hi all,
An interesting question came up in #haskell the other day, and I took the resulting discussion and wrapped it up into a simple tutorial for the wiki. Since I'm quite a newbie to haskell myself, I'd appreciate any double-checking of my logic and, of course, any other comments/suggestions. Thanks to Cale for his efforts on this problem, and to the original asker, whose name I can't recall.
Rather than use the Fibonacci series as an example, why not something like this...? contains :: String -> String -> Bool contains _ "" = False contains "" _ = True contains (x:xs) (y:ys) = ((x == y && contains xs ys) || contains (x:xs) ys) infiniteBanana :: String infiniteBanana = "banana" ++ infiniteBanana contains "na" infiniteBanana
participants (2)
-
Andrew Wagner
-
Seth Gordon