type Function = proc(x: float): float type Rule = proc(f: Function; x, h: float): float proc leftRect(f: Function; x, h: float): float = f(x) proc midRect(f: Function; x, h: float): float = f(x + h/2.0) proc rightRect(f: Function; x, h: float): float = f(x + h) proc trapezium(f: Function; x, h: float): float = (f(x) + f(x+h)) / 2.0 proc simpson(f: Function, x, h: float): float = (f(x) + 4.0*f(x+h/2.0) + f(x+h)) / 6.0 proc cube(x: float): float = x * x *x proc reciprocal(x: float): float = 1.0 / x proc identity(x: float): float = x proc integrate(f: Function; a, b: float; steps: int; meth: Rule): float = let h = (b-a) / float(steps) for i in 0 ..