[Haskell-cafe] New (simple) Lazy Evaluation tutorial
Seth Gordon
sethg at ropine.com
Thu Jan 18 16:43:07 EST 2007
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.
>
> http://www.haskell.org/haskellwiki/Haskell/Lazy_Evaluation
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
More information about the Haskell-Cafe
mailing list