Apply a function multiple times in Haskell -
this question has answer here:
learn haskell great good (section "higher order functions", subsection "some higher-orderism in order") describes example function applytwice
calls function on argument twice:
applytwice :: (a -> a) -> -> applytwice f x = f (f x)
but need function applies function on argument arbitrary amount of times. example applyn 3 f x
equivalent f $ f $ f x
. how write function of repeated application in haskell? please post possible solutions, using recursion, higher-order functions or else.
i did iterate f x !! n
.
Comments
Post a Comment