You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
470 B
Haskell
19 lines
470 B
Haskell
4 years ago
|
inc :: Num a => a -> a
|
||
|
inc n = n + 1
|
||
|
double :: Num a => a -> a
|
||
|
double n = n * 2
|
||
|
square :: Num a => a -> a
|
||
|
square n = n ^ 2
|
||
|
|
||
|
isEven :: Integral p => (p -> p) -> p -> p
|
||
|
isEven myFunction x = if even x
|
||
|
then myFunction x
|
||
|
else x
|
||
|
|
||
|
|
||
|
ifEvenDouble :: Integral p => p -> p
|
||
|
ifEvenDouble x = isEven double x
|
||
|
ifEvenInc :: Integral p => p -> p
|
||
|
ifEvenInc x = isEven inc x
|
||
|
ifEvenSquare :: Integral p => p -> p
|
||
|
ifEvenSquare x = isEven square x
|