Advertisement
Guest User

Untitled

a guest
Dec 18th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import Data.List
  2. import Data.Char
  3.  
  4. f1 :: Int -> Bool
  5. f1 1 = False
  6. f1 0 = True
  7. f1 x
  8.   | x `mod` 2 == 0 = True
  9.   | x `mod` 3 == 0 = True
  10.   | x `mod` 5 == 0 = True
  11.   | otherwise = False
  12.  
  13. head2 :: [a] -> (a,a)
  14. head2 [x,y] = (x,y)
  15. head2 (x:xs) = (x,head xs)
  16.  
  17. ratAdd :: (Int, Int) -> (Int, Int) -> (Int, Int)
  18. ratAdd (x,y) (z,w) = (w * x + y*z, y*w)
  19.  
  20. fac :: Int -> Int
  21. fac 0 = 1
  22. fac n = n * (fac (n -1))
  23.  
  24. minimumInt :: [Int] -> Int
  25. minimumInt [x] = x
  26. minimumInt [x,y] = x
  27. minimumInt (x:xs) = head(sort(x:xs))
  28.  
  29. insert :: Int -> a -> [a] -> [a]
  30. insert x y z = take x z ++ y : drop x (z)
  31.  
  32. minimumOfMaxima :: Ord a => [[a]] -> a
  33. minimumOfMaxima [x:xs]= minimum(maximum [x:xs])
  34. -- ez csak két eleműre működik
  35.  
  36. safeHead :: [a] -> Maybe a
  37. safeHead [] = Nothing
  38. safeHead x =Just (head x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement