Home > Blockchain >  Functor application over division
Functor application over division

Time:05-24

My question can be written in the context of lists. I have a function doing what is analogous to:

div' xs n = (*) (1 / n) <$> xs

Can this be simplified at all? I have been unable to work anything out.

CodePudding user response:

You can work with the section of an infix operator [Haskell-wiki] and write (/ n) to construct a function that will divide by n, that means you can implement div' as:

div' :: (Functor f, Fractional a) => f a -> a -> f a
div' xs n = (/ n) <$> xs
  • Related