import qualified Algebra.Additive as Additive ( C )
import qualified Algebra.Field as Field ( C )
import Control.Arrow ( first )
-import Data.Maybe ( catMaybes )
import Misc ( partition )
import NumericPrelude
import qualified Prelude as P
-- point and the result is returned wrapped in a 'Just'. If the
-- point is outside of the domain, 'Nothing' is returned.
evaluate :: Piecewise a -> a -> Maybe a
-evaluate (Piecewise pieces) x =
- foldl f Nothing pieces
+evaluate (Piecewise ps) x =
+ foldl f Nothing ps
where
f (Just y) _ = Just y
f Nothing (p,g) = if p x then Just (g x) else Nothing