Library function to compose a function with itself n times

前端 未结 10 2002
野的像风
野的像风 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:30

    A variation on trinithis' answer using the newtype package, just for fun:

    (\n f -> under Endo (mconcat . replicate n) f)
    

    Or point-free:

    under Endo . (mconcat .) . replicate
    

提交回复
热议问题