+
+
+-- | Plot a piecewise function over an interval @(x0,x1)@ using
+-- 'evaluate''. Return the result a list of @(x,y)@ tuples.
+--
+-- Examples:
+--
+-- >>> let p1 = ((-1,0), \x -> -x) :: ((Double,Double), Double->Double)
+-- >>> let p2 = ((0,1), \x -> x) :: ((Double,Double), Double->Double)
+-- >>> let ivs = [p1, p2]
+-- >>> let pw = from_intervals ivs
+-- >>> list_plot' pw (-2) 2 4
+-- [(-2.0,0.0),(-1.0,1.0),(0.0,-0.0),(1.0,1.0),(2.0,0.0)]
+--
+list_plot' :: (Additive.C a, Field.C a)
+ => Piecewise a
+ -> a
+ -> a
+ -> Int
+ -> [(a,a)]
+list_plot' pw x0 x1 subintervals =
+ [ (x, evaluate' pw x) | x <- nodes ]
+ where
+ nodes = x0 : (map snd $ partition subintervals x0 x1)