Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. data Stream a = Cons a (Stream a)
  2.  
  3. instance Show a => Show (Stream a) where
  4. show = take 20 . streamToList
  5.  
  6. streamToList :: Stream a -> [a]
  7. streamToList (Cons x xs) = [x] ++ streamToList xs  
  8.  
  9. -- generates a stream containing infinitely many copies of the
  10. -- given elemen
  11.  
  12. streamRepeat :: a -> Stream a
  13. streamRepeat x = Cons x $ streamRepeat x
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement