data Interval = Interval Double Double type Step = Double input :: ( [ (Double -> Double) ], [Double], Interval, Step) input = ( [f1, f2], [f1_, f2_], interval, step) where f1 x = (30 + 5 * x**2) / (24 - 2*x) f2 = (40 -) . (7 *) interval = Interval 1 6 f1_ = 2.5 f2_ = 22 step = 0.001 argsteps :: Interval -> Step -> [Double] argsteps (Interval left right) step | abs left > right = [] | otherwise = left : argsteps (Interval (left + step) right) step maxmin = mm maximum minimum minmax = mm minimum maximum mm :: ([(Double, Double)] -> (Double, Double)) -> ([Double] -> Double) -> [(Double->Double)] -> [Double] -> Interval -> Step -> (Double, Double) mm f1 f2 funcs fs_ interval step = f1 [ (f x, x) | x <- args ] where args = argsteps interval step f x = f2 [func x / func_ | (func, func_) <- zip funcs fs_] do_stuff = [f funcs fs_ interval step | f <- [maxmin, minmax]] where (funcs, fs_, interval, step) = input