
8 May
2009
8 May
'09
12:49 a.m.
Hi, I am curious to know if there is a function in Haskell to find if a certain value has already been evaluated. The function I need would have the type:
(?!) :: a -> Bool
And I expect it to be such that the following terminates after printing the first 101 fibonacci numbers.
fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
main = do print $ fibs !! 100 print $ takeWhile (?!) fibs
Although I guess I can imagine the following not terminating:
print $ filter (?!) fibs
I would find such a function immensely useful in "printing out" my infinite lists. Thanks! nikhil