Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Make partitions of lists in Scheme.

Make partitions of lists in Scheme.

Make partitions of lists in Scheme.

The objective is to split a list into two parts.

(define (partition number list)

Scheme will take a number and check the list. The numbers in the list that are less or equal to "number" shall be placed in one piece while the remaining parts are placed in another one.

ex. (partition 5 "(1 2 4 5 6 7 8 9)
> ((1 2 3 4 5) 6 7 8 9)

Im a bit unsure of how to fix this. Give an old man a helping hand.
Excuse my english.

RE: Make partitions of lists in Scheme.

The allowed primitives are



RE: Make partitions of lists in Scheme.

What have you written ?

RE: Make partitions of lists in Scheme.

Sorry, I dont have any.. yet. I specified my question quite bad i see now. What I really need is just a finger pointed in the right direction. I dont know where to start. In previous problems I've made for example a function:

"Write a procedure "subst-all", which takes an arbitrary list, which may contain dotted pairs, and
replaces all occurences of an element to another element".

It looks like this.

(define (subst-all val new-val list)
  (cond ((null? list) '())
        ((atom? list)
         (if (eq? val list)
        ((atom? (car list))
         (if (eq? (car list) val)
             (cons new-val (subst-all val new-val (cdr list)))
             (cons (car list) (subst-all val new-val (cdr list)))))
        (else (cons (subst-all val new-val (car list))
                    (subst-all val new-val (cdr list))))))

I know this doesnt really help me much but it kinda shows wich level Im working on.

RE: Make partitions of lists in Scheme.

Problem solved...

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close