Haskell函数式编程基础习题

来源:互联网 发布:mac可以玩使命召唤吗 编辑:程序博客网 时间:2024/06/05 15:27
-- Exercise 3.14myMin :: Int -> Int -> IntmyMin x y | x < y = x| otherwise = ymyMinThree :: Int -> Int -> Int -> IntmyMinThree x y z| myMinTwo  < z = myMinTwo| otherwise = zwhere myMinTwo = myMin x y-- Exercise 3.13-- Exercise 3.12-- Exercise 3.11-- Exercise 3.10fourEqual :: Integer -> Integer -> Integer ->Integer -> BoolfourEqual m n x y = (threeEqual m n x) && (m ==y)threeEqual :: Integer -> Integer -> Integer -> BoolthreeEqual m n p  = m ==n && n ==p-- Exercise 3.9threeDifferent :: Integer -> Integer -> Integer -> BoolthreeDifferent m n p =  m /=n && m/=p && n/= p-- Exercise 3.8mystery:: Integer -> Integer -> Integer -> Boolmystery m n p = not ( (m == n) && (n==p))-- Exercise 3.7-- Exercise 3.6-- Exercise 3.5nAnd :: Bool -> Bool -> BoolnAnd TrueTrue=TruenAnd  __=False-- Exercise 3.4andand :: Bool -> Bool -> Boolandand True True = Trueandand  __    = Falseoror ::Bool -> Bool -> Booloror True _ = Trueoror _ True = Trueoror _ _ = False-- Exercise 3.3-- Exercise 3.2-- Exercise 3.1exOr :: Bool -> Bool -> BoolexOr x y | x /= y = True| otherwise = False

0 0
原创粉丝点击