Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/First-class-functions/Haskell/first-class-functions.hs
Normal file
18
Task/First-class-functions/Haskell/first-class-functions.hs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
cube :: Floating a => a -> a
|
||||
cube x = x ** 3.0
|
||||
|
||||
croot :: Floating a => a -> a
|
||||
croot x = x ** (1/3)
|
||||
|
||||
-- compose already exists in Haskell as the `.` operator
|
||||
-- compose :: (a -> b) -> (b -> c) -> a -> c
|
||||
-- compose f g = \x -> g (f x)
|
||||
|
||||
funclist :: Floating a => [a -> a]
|
||||
funclist = [sin, cos, cube ]
|
||||
|
||||
invlist :: Floating a => [a -> a]
|
||||
invlist = [asin, acos, croot]
|
||||
|
||||
main :: IO ()
|
||||
main = print $ zipWith (\f i -> f . i $ 0.5) funclist invlist
|
||||
Loading…
Add table
Add a link
Reference in a new issue