From: mark
Subject: higher-order function
Date: 
Message-ID: <1194129215.512764.305480@z24g2000prh.googlegroups.com>
Hi everyone,

I'm still a Lisp novice. I'm reading by myself the book SICP. I've
practiced quite a few exercies in the book and this is my code for the
exercise 1.29 about Simpson's Rule:

(define (simpson f a b n)
  (define (yk k)
    (cond ((even? k) (* 2 (f (+ a (* k (/ (- b a) n))))))
          (else (* 4 (f (+ a (* k (/ (- b a) n))))))))
  (define (incr a)
    (+ a 1))
  (* (/ (/ (- b a) n) 3)
     (+ (sum yk 1 incr n)
        (yk 0))))

The problem is, though I checked on some numbers and the program seems
to work fine, I suspect there may be something wrong. How should I
proceed to check this program? Moreover in any similar situation how
should I test my program?

Thank you.

Mark.

From: mark
Subject: Re: higher-order function
Date: 
Message-ID: <1194129682.574107.79780@i13g2000prf.googlegroups.com>
I should also say that the procedure *sum* is defined in the book by
the authors with the form:

(sum term a next b)

...

and it keeps summing (term a) until a >= b (a is brought to its next
by (next a)).

Thanks.

Mark.
From: Slobodan Blazeski
Subject: Re: higher-order function
Date: 
Message-ID: <1194135212.810135.7410@y42g2000hsy.googlegroups.com>
On Nov 3, 3:33 pm, mark <·············@gmail.com> wrote:
> Hi everyone,
>
> I'm still a Lisp novice. I'm reading by myself the book SICP. I've
> practiced quite a few exercies in the book and this is my code for the
> exercise 1.29 about Simpson's Rule:
>
> (define (simpson f a b n)
>   (define (yk k)
>     (cond ((even? k) (* 2 (f (+ a (* k (/ (- b a) n))))))
>           (else (* 4 (f (+ a (* k (/ (- b a) n))))))))
>   (define (incr a)
>     (+ a 1))
>   (* (/ (/ (- b a) n) 3)
>      (+ (sum yk 1 incr n)
>         (yk 0))))
>
> The problem is, though I checked on some numbers and the program seems
> to work fine, I suspect there may be something wrong. How should I
> proceed to check this program? Moreover in any similar situation how
> should I test my program?
>
> Thank you.
>
> Mark.

This is a group about common lisp , post your questions to
http://groups.google.com/group/comp.lang.scheme/topics?lnk=rgh

Slobodan
From: ······@corporate-world.lisp.de
Subject: Re: higher-order function
Date: 
Message-ID: <1194136538.779428.139660@57g2000hsv.googlegroups.com>
On 4 Nov., 01:13, Slobodan Blazeski <·················@gmail.com>
wrote:
> On Nov 3, 3:33 pm, mark <·············@gmail.com> wrote:
>
>
>
> > Hi everyone,
>
> > I'm still a Lisp novice. I'm reading by myself the book SICP. I've
> > practiced quite a few exercies in the book and this is my code for the
> > exercise 1.29 about Simpson's Rule:
>
> > (define (simpson f a b n)
> >   (define (yk k)
> >     (cond ((even? k) (* 2 (f (+ a (* k (/ (- b a) n))))))
> >           (else (* 4 (f (+ a (* k (/ (- b a) n))))))))
> >   (define (incr a)
> >     (+ a 1))
> >   (* (/ (/ (- b a) n) 3)
> >      (+ (sum yk 1 incr n)
> >         (yk 0))))
>
> > The problem is, though I checked on some numbers and the program seems
> > to work fine, I suspect there may be something wrong. How should I
> > proceed to check this program? Moreover in any similar situation how
> > should I test my program?
>
> > Thank you.
>
> > Mark.
>
> This is a group about common lisp ,
 ...
>
> Slobodan

Almost. It is correct to point out that Scheme-related questions are
best asked on comp.lang.scheme .

comp.lang.lisp is not only about Common Lisp. It is also for general
Lisp discussion. Other dialects of
can also be discussed here, though specific questions should better be
asked on specialized
forums, mailing lists, etc. Some Lisp dialects have their own
newsgroup (Logo, Scheme, Emacs Lisp, ...).
Some don't (ISLisp, ...).

Example: if there is a nice success story of Lisp usage (any Lisp
dialect), comp.lang.lisp is
a fine place to post that story.

Another example: if there is a new book, article, website, ... with
Lisp-related content (again
any Lisp dialect), comp.lang.lisp is a fine place to announce that.

Hint: you may also write Common Lisp answers to Scheme questions. ;-)