All pastes #918640 Raw Edit

Someone

public text v1 · immutable
#918640 ·published 2008-02-26 07:49 UTC
rendered paste body
(define (inc n) (+ n 1))

(define (cube x) (* x x x))

(define (sum term a next b)
  (if (> a b)
      0
      (+ (term a)
         (sum term (next a) next b))))

(define (simpson f a b n)
  (define k 0)
  (define h (/ (- b a) n))
  (define (coeff k)
    (cond ((= k 0) 1)
          ((= k n) 1)
          ((= k 1) 4)
          ((= (% k 2) 0) 2)
          (else 4)))
  (* (/ h 3)
     (sum (* (coeff k) 
             (f (+ a (* k h)))) k inc b)))


==========================================

When I evaluate (simpson cube 0 1 100) I get an error saying: "procedure application: expected procedure, given: 0; arguments were: 0" which points to line 8.