Library function to compose a function with itself n times

前端 未结 10 2009
野的像风
野的像风 2020-11-30 03:36

Is there a library function available in Haskell to compose a function with itself n times?

For example I have this function:

func :: a ->         


        
10条回答
  •  春和景丽
    2020-11-30 04:19

    iterate (f .) id !! n
    

    or

    iterate (f .) f !! (n-1)
    

    depending on if n == 0 is allowed.

提交回复
热议问题