askell Language -- higher-order functions with some basic datatypes ---------------------------------------------------------------------- -- p1 f x should call f three times (in nested fashion) on x p1 :: (a -> a) -> a -> a p1 = undefined -- p2 f x should call f with x and x as the two inputs to f p2 :: (a -> a -> c) -> a -> c p2 = undefined --apply a function to each component of a tuple, building a new tuple p3 :: (a -> b) -> (a,a) -> (b,b) p3 = undefined {- for p3 and p4, there is only one way to return a value of the desired output type. (So the type completely specifies what the code must do.) -} p4 :: (a -> b -> c) -> (a -> b) -> a -> c p4 = undefined p5 :: (b,d) -> (b -> c) -> ((c,d) -> e) -> e p5 = undefined {- change the order of the types in the input tuple of a function. -} p6 :: ((a,b) -> c) -> (b,a) -> c p6 = undefined
Haskell Language
-- higher-order functions with some basic datatypes
----------------------------------------------------------------------
-- p1 f x should call f three times (in nested fashion) on x
p1 :: (a -> a) -> a -> a
p1 = undefined
-- p2 f x should call f with x and x as the two inputs to f
p2 :: (a -> a -> c) -> a -> c
p2 = undefined
--apply a function to each component of a tuple, building a new tuple
p3 :: (a -> b) -> (a,a) -> (b,b)
p3 = undefined
{- for p3 and p4, there is only one way to return a value of the
desired output type. (So the type completely specifies what
the code must do.) -}
p4 :: (a -> b -> c) -> (a -> b) -> a -> c
p4 = undefined
p5 :: (b,d) -> (b -> c) -> ((c,d) -> e) -> e
p5 = undefined
{- change the order of the types in the input tuple of a function. -}
p6 :: ((a,b) -> c) -> (b,a) -> c
p6 = undefined

Trending now
This is a popular solution!
Step by step
Solved in 2 steps









