
编程 haskell 题目如下:使用符号 <+> 表示加法,起到加号的作用 例如 Main> 1 <+> 2 3
1个回答
展开全部
instance Show (a -> b) where
show f = "<function>"
instance Eq (a -> b) where
f == g = False
instance (Integral a, Integral b) => Num (a -> b) where
f + g = \x -> f x + g x
f - g = \x -> f x - g x
f * g = \x -> f x * g x
fromInteger n = \m -> fromIntegral m + fromIntegral n
abs f = undefined
signum f = undefined
(<+>) :: Int -> Int -> Int
(<+>) x y = x + y
show f = "<function>"
instance Eq (a -> b) where
f == g = False
instance (Integral a, Integral b) => Num (a -> b) where
f + g = \x -> f x + g x
f - g = \x -> f x - g x
f * g = \x -> f x * g x
fromInteger n = \m -> fromIntegral m + fromIntegral n
abs f = undefined
signum f = undefined
(<+>) :: Int -> Int -> Int
(<+>) x y = x + y
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询