Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type Student = (String, Int)
- s1 :: Student
- s2 :: Student
- s1 = ("Kiro Stamatov", 111213)
- s2 = ("Hristo Hristov", 102030)
- mult4 :: (Int, Int, Int, Int) -> Int
- mult4 (x, y, z, t) = x*y*z*t
- sort2 :: (Int, Int) -> (Int, Int)
- sort2 (x, y) = if x >= y then (x, y) else (y, x)
- fib :: Int -> Int
- fib n
- | n == 1 = 1
- | n == 2 = 1
- | n > 2 = fib (n-2) + fib (n-1)
- | otherwise = error "Not defined"
- fibStep :: (Int, Int) -> (Int, Int)
- fibStep (u, v) = (u, u+v)
- fibPair :: Int -> (Int, Int)
- fibPair n = (fib(n), fib(n + 1))
- toEnd :: a -> [a] -> [a]
- toEnd x l = l ++ [x]
- sumPairs :: [(Int, Int)] -> [Int]
- sumPairs pL = [x + y | (x, y) <- pL]
- digit :: Char -> Bool
- digit ch = ch >= '0' && ch <= '9'
- all_digits :: String -> String
- all_digits str = [ch | ch <- str, digit ch]
- allEven :: [Int] -> Bool
- allEven x = (x == [a | a <- x, even a])
- allOdd :: [Int] -> Bool
- allOdd x = (x == [a | a <- x, odd a])
- revWords :: String -> String
- revWords input = (unwords . reverse . words) input
- sumMy :: [Int] -> Int
- sumMy [] = 0
- sumMy (x:xs) = x + sum xs
- concatMy :: [[a]] -> [a]
- concatMy [] = []
- concatMy (x : xs) = x ++ concat xs
- sumList :: [Int] -> Int
- sumList [] = 0
- sumList (x:xs) = x + sumList xs
- concatList :: [[a]] -> [a]
- concatList [] = []
- concatList (x : xs) = x ++ concatList xs
- member :: Int -> [Int] -> Bool
- member x [] = False
- member x (y:ys) = (x == y) || (member x ys)
- plus1 :: [Int] -> [Int]
- plus1 [] = []
- plus1 (x:xs) = x + 1 : plus1 xs
- filterEven :: [Int] -> [Int]
- filterEven [] = []
- filterEven (x:xs)
- | even x = x : filterEven xs
- | otherwise = filterEven xs
- filterMy :: (Int -> Bool) -> [Int] -> [Int]
- filterMy p [] = []
- filterMy p (x:xs)
- | p x = x : filterMy p xs
- | otherwise = filterMy p xs
- insert :: Int -> [Int] -> [Int]
- insert x [] = [x]
- insert x (y:ys)
- | x <= y = x : (y:ys)
- | otherwise = y : insert x ys
- insertSort :: [Int] -> [Int]
- insertSort [] = []
- insertSort (x:xs) = insert x (insertSort xs)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement