Coder Profile - Show off your skills, get a coder profile.
 
 
 
The Author
neko-mangaka
Chris Bouchard
Send A Message
Rating
7.00
out of 10
( 1 Ratings )
Please login to rate source codes.

Click here to register a free account with us.
General Details
Scheme
Posted 76 Days Ago
94 Views
Received 1 Rating
More Codes By This Author
Splitting a list recursiv...
Tail Call Optimization
Articles By This Author
Currying in JavaScript: F...

Splitting a list recursively in Scheme


Description
If you're like me, you've been programming in Scheme and wanted to split a list into sub-lists of [semi]-equal length. I'm sure there's a library function to do this (I didn't even look), but I wanted to do it recursively. So here's how it should work:

(split 2 '(1 2 3 4))
=> ((1 2) (3 4))

(split 3 '(1 2 3 4))
=> ((1) (2) (3 4))

(split 3 '(1 2 3 4 5))
=> ((1) (2 3) (4 5))

As you can see, if the list can't be split evenly the function will create lists of as equal length as possible. I chose to take the shorter lists first.
Technical
I use Guile when testing, but I don't think it should matter.
Source Code
Comments
Please login to post comments.
 
Cinjection     Posted 72 Days Ago
 
 
I'm happy I met someone who does Scheme :). Nice little app. You should note
that the standard for closing parenthesis is something like this:
(fcn (fcn2 (fcn3 1 3 5)))

That is, do not line them up like you would with other parenthesis in something
like Java.
Page 1 of 1
More "Scheme" Source Codes By This Author
Recently Posted "Scheme" Source Codes
Recently Rated "Scheme" Source Codes
 
 
Latest News About Coder Profile
Coder Profile Poll
What is the next application you would like to be added to your profiles?

Books
Coding Challenges
Project Management
Blog
Tutorials


please login to cast your vote
and see the results of this poll
Latest Coder Profile Changes
Coder Profile was last updated
5 Days Ago
Official Blog :: Make A Donation :: Credits :: Contact Me
Terms & Conditions :: Privacy Policy :: Documents :: Wallpapers
Version 1.46.00
Copyright © 2007 - 2008, Scott Thompson, All Rights Reserved