X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FPiecewise.hs;h=59af066db58dcd3a424f12576b76e7ae6998adad;hb=288455e9aade0b3a8abf138c4319beab3a0be705;hp=e550e4bf54659f434e88ea5ea369e5c61e3ada90;hpb=ba5fa4536b8171dd58afe38176da0b9c37032103;p=numerical-analysis.git diff --git a/src/Piecewise.hs b/src/Piecewise.hs index e550e4b..59af066 100644 --- a/src/Piecewise.hs +++ b/src/Piecewise.hs @@ -11,10 +11,9 @@ where 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 +import Prelude () -- | A predicate is basically a function that returns True or -- False. In this case, the predicate is used to determine which @@ -42,8 +41,8 @@ data Piecewise a = -- 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