This repository has been archived on 2025-07-20. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
fp/02-lab.hs
2023-10-11 10:24:15 +01:00

39 lines
No EOL
881 B
Haskell

import Data.Char
orB :: Bool -> Bool -> Bool
orB x y = x || y
swap :: (x, y) -> (y, x)
swap (x, y) = (y, x)
middle :: [a] -> [a]
middle x = tail (take ((length x) - 1) x)
condrev :: [a] -> [a]
condrev x | (length x) >= 7 = reverse x
| otherwise = x
dblmagic :: [Int] -> [Int]
dblmagic x = filter (>10) (map (*2) x)
wtfstring :: String -> String
wtfstring x = reverse (map (toUpper) x)
addindex :: [a] -> [(Int, a)]
addindex x = zip [0..((length x) - 1)] x
relcmp :: (Num a, Ord a) => a -> a -> Bool
relcmp x y | x > y && x < (y*2) = True
| otherwise = False
third :: [a] -> a
-- third x = head (tail (tail x))
-- third x = x!!2
third (_:_:x:_) = x
safetail :: [a] -> [a]
-- safetail x = if (length x) == 0 then [] else tail x
-- safetail x | length x == 0 = []
-- | otherwise = tail x
safetail [] = []
safetail (_:xs) = xs