diff --git a/07/Main.hs b/07/Main.hs index 870bf13..eedfac6 100644 --- a/07/Main.hs +++ b/07/Main.hs @@ -20,6 +20,18 @@ int_plus_3 n = n + 3 -- examples comp :: BigP -> Integer comp = int_plus_3 . bar +-- same as: int_plus_3 $ bar $ P2 10 + +double_arg :: Integer -> Integer -> Integer +double_arg a b = a + b + +partially_applied :: Integer -> Integer +partially_applied = double_arg 7 + + +func_arg :: (Integer -> Integer) -> Integer -> Integer +func_arg f b = f b + main :: IO () main = putStrLn "Hello world" diff --git a/07/Second.hs b/07/Second.hs new file mode 100644 index 0000000..c4ee758 --- /dev/null +++ b/07/Second.hs @@ -0,0 +1,28 @@ + +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] +inv _ = _ + + +getF :: Name -> Maybe Name +getF n = lookup n fathers