module Precursor.Function
( const
, fix
, flip
, on
, ($)
, (&)
, applyN
, converge
, (.:)
) where
import Precursor.Data.Bool
import Precursor.Control.Category
import Data.Function hiding ((.))
import Precursor.Algebra.Eq
import Precursor.Numeric.Num
import Precursor.Algebra.Ord
import Precursor.Algebra.Ring
applyN :: (a -> a) -> Int -> a -> a
applyN f = go . max 0 where
go 0 x = x
go n x = go (n1) (f x)
converge :: Eq a => (a -> a) -> a -> a
converge f = r where
r x | x == y = y
| otherwise = r y
where y = f x
infixr 8 .:
(.:) :: (c -> d) -> (a -> b -> c) -> a -> b -> d
(f .: g) x y = f (g x y)