From 658974a97f948850c2386166acf313c4383d40be Mon Sep 17 00:00:00 2001 From: anon Date: Mon, 22 Jul 2024 19:39:19 +0200 Subject: [PATCH] Added 'Haskell/4.hs' --- Haskell/4.hs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Haskell/4.hs diff --git a/Haskell/4.hs b/Haskell/4.hs new file mode 100644 index 0000000..3868332 --- /dev/null +++ b/Haskell/4.hs @@ -0,0 +1,36 @@ +and' True True = True +and' _ _ = False +-- +and'' (True, True) = True +and'' ( _, _) = False +-- +add' (a, b) (c, d) = ((+) a b, (+) b c) + + +or' False False = False +or' _ _ = True + + +xor' :: Bool -> Bool -> Bool +xor' a b = not (a == b) + + +t = ((10, 11), (13, 14)) +f ((a, b), (c, d)) = a +((a, b), (c, d)) = t + + +bin_add 0 0 = (0, 0) +bin_add 0 1 = (0, 1) +bin_add 1 0 = (0, 1) +bin_add 1 1 = (1, 0) + + +calc (a, (o), b) = (o) a b + + +sum' :: [Int] -> Int +sum' [] = 0 +sum' (x:xs) = x + (sum' xs) + +-- HF: in - list; out - odds