Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Combining two definition into one only
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
SamuelXiao  
View profile  
 More options Oct 5 2008, 10:56 am
From: SamuelXiao <foolsmart2...@gmail.com>
Date: Sun, 5 Oct 2008 07:56:13 -0700 (PDT)
Local: Sun, Oct 5 2008 10:56 am
Subject: [plt-scheme] Combining two definition into one only
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)))))))

(define insertion-sort-numbers
(lambda (numbers)
(let helper ((unsorted numbers) ; The remaining unsorted values
(sorted '())) ; The sorted values
(if (null? unsorted)
sorted
(helper (cdr unsorted) (insert-number (car unsorted) sorted))))))
_________________________________________________
  For list-related administrative tasks:
  http://list.cs.brown.edu/mailman/listinfo/plt-scheme


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jon Rafkind  
View profile  
 More options Oct 5 2008, 4:50 pm
From: Jon Rafkind <work...@ccs.neu.edu>
Date: Sun, 05 Oct 2008 14:50:32 -0600
Local: Sun, Oct 5 2008 4:50 pm
Subject: Re: [plt-scheme] Combining two definition into one only
SamuelXiao wrote:
> I am a scheme newbie, could anyone tell me how can i combine this
> following 2 definition into one?
> --------------------------------------------------------------------------- --------------------------------------------------

(define insertion-sort-numbers
(lambda (numbers)
(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)))))))
(let helper ((unsorted numbers) ; The remaining unsorted values
(sorted '())) ; The sorted values
(if (null? unsorted)
sorted
(helper (cdr unsorted) (insert-number (car unsorted) sorted))))))

_________________________________________________
  For list-related administrative tasks:
  http://list.cs.brown.edu/mailman/listinfo/plt-scheme


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matt Jadud  
View profile  
 More options Oct 5 2008, 10:06 pm
From: "Matt Jadud" <jad...@gmail.com>
Date: Sun, 5 Oct 2008 22:06:12 -0400
Local: Sun, Oct 5 2008 10:06 pm
Subject: Re: [plt-scheme] Combining two definition into one only

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."

Cheers,
Matt

[1] http://groups.google.com/group/plt-scheme/browse_thread/thread/ff785c...
[2] http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2007S/Labs/inserti...
_________________________________________________
  For list-related administrative tasks:
  http://list.cs.brown.edu/mailman/listinfo/plt-scheme


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
SamuelXiao  
View profile  
 More options Oct 6 2008, 12:53 pm
From: SamuelXiao <foolsmart2...@gmail.com>
Date: Mon, 6 Oct 2008 09:53:49 -0700 (PDT)
Local: Mon, Oct 6 2008 12:53 pm
Subject: [plt-scheme] Re: Combining two definition into one only
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:

_________________________________________________
  For list-related administrative tasks:
  http://list.cs.brown.edu/mailman/listinfo/plt-scheme

    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
SamuelXiao  
View profile  
 More options Oct 10 2008, 1:26 am
From: SamuelXiao <foolsmart2...@gmail.com>
Date: Thu, 9 Oct 2008 22:26:38 -0700 (PDT)
Local: Fri, Oct 10 2008 1: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 ((unsorted numbers) ; The remaining unsorted values
(sorted '())) ; The sorted values
(if (null? unsorted)
sorted
(helper (cdr unsorted) (insert-number (car unsorted) sorted)))))

(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:

_________________________________________________
  For list-related administrative tasks:
  http://list.cs.brown.edu/mailman/listinfo/plt-scheme

    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jos Koot  
View profile  
 More options Oct 13 2008, 2:39 pm
From: "Jos Koot" <jos.k...@telefonica.net>
Date: Mon, 13 Oct 2008 20:39:52 +0200
Local: Mon, Oct 13 2008 2:39 pm
Subject: Re: [plt-scheme] Re: Combining two definition into one only

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


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2010 Google