X-Git-Url: http://gitweb.michael.orlitzky.com/?p=numerical-analysis.git;a=blobdiff_plain;f=src%2FPiecewise.hs;h=6d2f5085e31b88fe85468cc31e70e853c8fc1f3f;hp=e550e4bf54659f434e88ea5ea369e5c61e3ada90;hb=9b639d75334420747ce83376910af90368940640;hpb=25706b7e253af82d8ca9128eb23772c47ee6c0c3 diff --git a/src/Piecewise.hs b/src/Piecewise.hs index e550e4b..6d2f508 100644 --- a/src/Piecewise.hs +++ b/src/Piecewise.hs @@ -11,7 +11,6 @@ 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 @@ -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