Advertisement
Guest User

Haskell

a guest
Aug 15th, 2021
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {-The list is made of tuples whose first component is the stock value, the second is the year, the third is the month and the fourth is the date. We want to know when the stock value first exceeded one thousand dollars!-}
  2.  
  3. stock = [(994.4,2008,9,1),(995.2,2008,9,2),(999.2,2008,9,3),(1001.4,2008,9,4),(998.3,2008,9,5)]  
  4.  
  5. function = head $ dropWhile (\(val,y,m,d) -> val < 1000) stock
  6.  
  7. function' = head $ dropWhile (f < 1000) stock
  8.    where f (val,y,m,d) = val
  9.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement