Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Topic about lists
- fact :: Int -> Int
- fact n = product [1..n]
- hasElements :: [Int] -> Bool
- hasElements [] = False
- hasElements n = n /= []
- hasElements' :: [Int] -> Bool
- hasElements' [] = False
- hasElements' n = length n /= 0
- hasElements'' :: [Int] -> Bool
- hasElements'' [] = False
- hasElements'' n = not $ null n
- hasElementsButWithMagic :: [Int] -> Bool
- hasElementsButWithMagic = not . null
- myLengthPM :: [Int] -> Int
- myLengthPM [] = 0
- myLengthPM (_:xs) = 1 + myLength xs
- myLengthNonPM :: [Int] -> Int
- myLengthNonPM [] = 0
- myLengthNonPM xs
- | null xs = 0
- | otherwise = 1 + (myLength $ tail xs)
- getClosedInterval :: Int -> Int -> [Int]
- getClosedInterval x y = [min x y .. max x y]
- isInside :: Int -> Int -> Int -> [Int]
- isInside x y n = n `elem` [min x y .. max x y]
- removeFirst :: Int -> [Int] -> [Int]
- removeFirst n (x:xs)
- | x == n = removeFirst n xs
- | otherwise = removeFirst n xs
- removeAllRec :: Int -> [Int] -> [Int]
- removeAllRec n (x:xs)
- | x == n = removeAllRec n xs
- | otherwise = x : removeAllRec n xs
- removeAllHOF :: Int -> [Int] -> [Int]
- removeAllHOF n xs = filter (\x -> x == n) xs
- incrementByLC :: Int -> [Int] -> [Int]
- incrementByLC n xs = [n + x | x <- xs]
- incrementByHOF :: Int -> [Int] -> [Int]
- incrementByHOF n xs = map (+n) xs
- rev = read . reverse . show
- rev' n = read $ reverse $ show n
- sumDivs n = sum [d | d <- [1..n], mod n d == 0]
- isPrime n = n > 2 && [1, n] == [d | d <- [1..n], mod n d == 0]
- sumDig = sum . map digitToInt . show
- sumDig' n = sum $ map digitToInt $ show n
- getPrimesLC :: Int -> Int -> [Int]
- getPrimesLC x y = [d | d <- [min x y .. max x y], isPrime d && elem '7' $ show d]
- getPrimesHOF :: Int -> Int -> [Int]
- getPrimesHOF x y = filter (\d -> isPrime d && elem '7' $ show d) [min x y .. max x y]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement