Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Scheme > Re: Sort a list...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 7 of 17 Topic 4626 of 4788
Post > Topic >>

Re: Sort a list of dotted pairs

by pjb@[EMAIL PROTECTED] (Pascal J. Bourguignon) Jul 24, 2008 at 02:36 PM

"Kjetil S. Matheussen" <k.s.matheussen@[EMAIL PROTECTED]
> writes:

> On Wed, 23 Jul 2008, Pascal J. Bourguignon wrote:
>
>> BastiL2001@[EMAIL PROTECTED]
 writes:
>> 
>> > Dear group,
>> >
>> > I have a list of dotted pairs that may look something like this:
>> > ((4 . something) (2 . maybe ) (3 . this ) (7 . last ) (5 . some))
>> >
>> > I want it to be sorted after the car of each dotted pair starting
with
>> > the lowest number...
>> >
>> > ((2 . maybe) (3 . this) (4 . something) (5 . some) (7 . last))
>> >
>> > Only thing I have done so far is the sort function which does not
seem
>> > to help in that case... How could this be done? Thanks.
>> 
>> It depends on how you made this sort function.
>> If you made it like Common Lisp sort, then you can just write:
>> 
>>      (sort a-list < 'key car)
>> 
>> But if you made it like the sort we usually find in scheme libraries,
>> then  you will have to write:
>> 
>
> Not really:
>
> (sort a-list function-which-compares-cars)

How many gazillons of function-which-compares-such-and-such will you
write?

With (sort a-list < 'key car) if we have 20 ways of comparing stuff
(<, string<, symbol<, etc) and 100 ways of extracting keys (100
getters), we can sort 2000 different way.


With (sort a-list function-which-compares-cars) you would have to
write 2000 function-which-compares-some-key-some-way before.


-- 
__Pascal Bourguignon__
 




 17 Posts in Topic:
Sort a list of dotted pairs
BastiL2001@[EMAIL PROTECT  2008-07-23 08:20:08 
Re: Sort a list of dotted pairs
Grant Rettke <grettke@  2008-07-23 10:05:04 
Re: Sort a list of dotted pairs
pjb@[EMAIL PROTECTED] (P  2008-07-23 19:35:13 
Re: Sort a list of dotted pairs
Abdulaziz Ghuloum <agh  2008-07-23 11:51:56 
Re: Sort a list of dotted pairs
"Kjetil S. Matheusse  2008-07-24 10:25:16 
Re: Sort a list of dotted pairs
"Kjetil S. Matheusse  2008-07-24 12:59:28 
Re: Sort a list of dotted pairs
pjb@[EMAIL PROTECTED] (P  2008-07-24 14:36:45 
Re: Sort a list of dotted pairs
leppie <xacc.ide@[EMAI  2008-07-24 05:52:43 
Re: Sort a list of dotted pairs
leppie <xacc.ide@[EMAI  2008-07-24 05:55:43 
Re: Sort a list of dotted pairs
Grant Rettke <grettke@  2008-07-24 06:29:16 
Re: Sort a list of dotted pairs
"Kjetil S. Matheusse  2008-07-24 16:24:53 
Re: Sort a list of dotted pairs
pjb@[EMAIL PROTECTED] (P  2008-07-24 16:27:20 
Re: Sort a list of dotted pairs
"Kjetil S. Matheusse  2008-07-24 16:25:24 
Re: Sort a list of dotted pairs
leppie <xacc.ide@[EMAI  2008-07-24 07:46:52 
Re: Sort a list of dotted pairs
leppie <xacc.ide@[EMAI  2008-07-24 07:51:28 
Re: Sort a list of dotted pairs
Grant Rettke <grettke@  2008-07-24 08:43:25 
Re: Sort a list of dotted pairs
"Kjetil S. Matheusse  2008-07-24 18:09:38 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Oct 12 22:30:36 CDT 2008.