I am a scheme newbie, could anyone tell me how can i combine this following 2 definition into one? --------------------------------------------------------------------------- -------------------------------------------------- (define insert-number (lambda (new-element sorted) (cond ((null? sorted) (list new-element)) ((<= new-element (car sorted)) (cons new-element sorted)) (else (cons (car sorted) (insert-number new-element (cdr sorted)))))))
SamuelXiao wrote: > I am a scheme newbie, could anyone tell me how can i combine this > following 2 definition into one? > --------------------------------------------------------------------------- --------------------------------------------------
On Sun, Oct 5, 2008 at 10:56 AM, SamuelXiao <foolsmart2...@gmail.com> wrote: > I am a scheme newbie, could anyone tell me how can i combine this > following 2 definition into one?
This question[1] looks like it might be related to a set of problems issued at Grinnell in the Spring of 2007[2].
I've CC:'d Samuel Rebelsky at Grinnell, as a lab of his was the only page Google could find with the words "insert-number" and "insertion-sort-numbers" that wasn't the Google Groups version of the original posting.
> On Sun, Oct 5, 2008 at 10:56 AM, SamuelXiao <foolsmart2...@gmail.com> wrote: > > I am a scheme newbie, could anyone tell me how can i combine this > > following 2 definition into one?
> This question[1] looks like it might be related to a set of problems > issued at Grinnell in the Spring of 2007[2].
> I've CC:'d Samuel Rebelsky at Grinnell, as a lab of his was the only > page Google could find with the words "insert-number" and > "insertion-sort-numbers" that wasn't the Google Groups version of the > original posting.
> And, if I've completely missed the mark, "oops."
(let helper (( )())) ----> what does this means? because in my notes and even the online materials: ( let ( {[ ‹id› ‹expr› ]}* ) ‹expr›+ ) the let statement should be sth like the above one. what is the helper standing for?
On Oct 7, 12:53 am, SamuelXiao <foolsmart2...@gmail.com> wrote:
> Yes, you are right, actually, i am studying the scheme by taking his > notes because in my school, the teacher's example is a bit simple.
> On Oct 6, 10:06 am, "Matt Jadud" <jad...@gmail.com> wrote:
> > On Sun, Oct 5, 2008 at 10:56 AM, SamuelXiao <foolsmart2...@gmail.com> wrote: > > > I am a scheme newbie, could anyone tell me how can i combine this > > > following 2 definition into one?
> > This question[1] looks like it might be related to a set of problems > > issued at Grinnell in the Spring of 2007[2].
> > I've CC:'d Samuel Rebelsky at Grinnell, as a lab of his was the only > > page Google could find with the words "insert-number" and > > "insertion-sort-numbers" that wasn't the Google Groups version of the > > original posting.
> > And, if I've completely missed the mark, "oops."
SamuelXiao wrote: (let helper (( )())) ----> what does this means?
(let procname ((var value) ...) definition ... expr ...) This is a named let form, quite something else than a plain let. Look for "named let" in your notes. May be in a section about iterations. Or look ifor named let in the index of "The Scheme Programming Language" by R. Kent Dybvig or any other book about Scheme. In your example procname is "helper" and is called recursively in the last line. Jos
----- Original Message ----- From: "SamuelXiao" <foolsmart2...@gmail.com> To: <plt-sch...@list.cs.brown.edu> Sent: Friday, October 10, 2008 7:26 AM Subject: [plt-scheme] Re: Combining two definition into one only
Excuse, I want to ask one more question, actually, for the let statement:
(let helper (( )())) ----> what does this means? because in my notes and even the online materials: ( let ( {[ ‹id› ‹expr› ]}* ) ‹expr›+ ) the let statement should be sth like the above one. what is the helper standing for?
On Oct 7, 12:53 am, SamuelXiao <foolsmart2...@gmail.com> wrote: > Yes, you are right, actually, i am studying the scheme by taking his > notes because in my school, the teacher's example is a bit simple.
> On Oct 6, 10:06 am, "Matt Jadud" <jad...@gmail.com> wrote:
> > On Sun, Oct 5, 2008 at 10:56 AM, SamuelXiao <foolsmart2...@gmail.com> > > wrote: > > > I am a scheme newbie, could anyone tell me how can i combine this > > > following 2 definition into one?
> > This question[1] looks like it might be related to a set of problems > > issued at Grinnell in the Spring of 2007[2].
> > I've CC:'d Samuel Rebelsky at Grinnell, as a lab of his was the only > > page Google could find with the words "insert-number" and > > "insertion-sort-numbers" that wasn't the Google Groups version of the > > original posting.
> > And, if I've completely missed the mark, "oops."