You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
programming-basics-2022/07_haskell/Second.hs

36 lines
501 B

2 years ago
type Name = String
type Table = [ (Name, Name) ]
fathers :: Table
fathers = [
("a", "d"),
("b", "r")
]
head' :: [a] -> a
head' (x:xs) = x
helper :: Integer -> [a] -> Integer
helper acc (x:xs) = helper (acc + 1) xs
helper acc ([]) = acc
len' :: [a] -> Integer
len' xs = helper 0 xs
inv :: [a] -> [a] -> [a]
inv acc (x:xs) = inv (x : acc) xs
inv acc [] = acc
rev :: [a] -> [a]
rev xs = inv [] xs
-- 1 : 2 : 3 : []
-- 3 : 2 : 1 : []
2 years ago
getF :: Name -> Maybe Name
getF n = lookup n fathers