Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. fact x
  2. | (x<0) =0
  3. | x==0 =1
  4. |otherwise = x *fact (x-1)
  5.  
  6. fact' x
  7. | x < 0 = 0
  8. fact' 0 = 1
  9. fact' x = x * fact (x-1)
  10.  
  11. fact'' 0 = 1
  12. fact'' x = x * fact'' (x-1)
  13.  
  14. h x
  15. | x < 0 = 0
  16. | otherwise = fact'' x
  17. where
  18. fact'' :: Integral a => a -> a
  19. fact'' 0 = 1
  20. fact'' x = x * fact'' (x-1)
  21.  
  22. listApp :: [a -> b] -> a -> [b]
  23. listApp [] _ = []
  24. listApp (x:xs) a = x a : listApp xs a
  25.  
  26. isPrefixOf [] _ = True
  27. isPrefixOf _ []= False
  28. isPrefixOf (x:xs) (y:ys) =x == y && isPrefixOf xs ys
  29.  
  30. nub [] = []
  31. nub (x:xs) = x : nub [a | a <- xs, a /=x]
  32.  
  33. polinom [] _ = 0
  34. polinom (x:xs) a = x + a * polinom xs a
  35.  
  36. runs _ [] = []
  37. runs n l = take n l : runs n (drop n l)
  38.  
  39. slice (x:xs) l = take x l : slice xs (drop x l)
  40. slice _ _ = []
  41.  
  42. every _ [] = []
  43. every n (x:xs) = x : every n (drop (n-1) xs)
  44.  
  45. tails [] = [[]]
  46. tails (x:xs) = (x:xs) : tails xs
  47.  
  48. tails [] = [[]]
  49. tails list@(_:xs) = list : tails xs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement