i :: Int
i =
--add, sub :: Int -> Int -> Int
add, sub :: (Num a) => a -> a -> a
add a b = a + b
sub a b = a - b
f :: (Num a) => a -> a
f x = * x +
--出错
--area :: (Num x) => Floating -> x -> x
area :: Floating a => a -> a
area r = pi * (r ^ )
fun :: (Num a) => (a, a) -> a
fun (x,y) = * x + * y +
fun' :: (Num a) => a -> a-> a
fun' x y = 4 * x + 5 * y + 1
--Lambda表达式
--fun'' = \x -> \y -> * x + * y +
fun'' :: Num a => a -> a ->a
fun'' = \x y -> * x + *y +
plus :: Num a => a -> a -> a
plus = (+)
--参数绑定
--area_tri :: Float -> Float -> Float -> Float
area_tri :: Floating a => a -> a -> a -> a
-- let ... in
area_tri a b c = let p = (a+b+c)/ in sqrt (p * (p-a) * (p-b) * (p-c))
area_tri' :: Double -> Double -> Double -> Double
-- where
area_tri' a b c =
sqrt (p * (p-a) * (p-b) * (p-c))
where
p = ((a + b + c) / 2.0)
--条件表达式
isTwo :: Int -> Bool
isTwo x = if x == then True else False
isTwo' :: Int -> Bool
isTwo' = (==2)