From: Rob
Subject: Sorting A List
Date: 
Message-ID: <01bc694a$9a0ef860$a66d989e@rob-l.demon.co.uk>
Hello

I am trying to sort a list using xlisp v2.0, on a PC.

According to my Common Lispcraft book there is a sort function however this
is what happens

> (sort '(dog bark cow) '>)
error: bad argument type - BARK
>

Can anyone help ?

Thanks In Advance

Rob Langley

From: Jong-won Choi
Subject: Re: Sorting A List
Date: 
Message-ID: <3388D5E2.71A9@lgsemicon.co.kr>
Rob,

The elements of '(dog bark cow) are not numbers, but you tried sort them
with number comparison - >.

(sort '(dog bark cow) #'(lambda (sym1 sym2) (string> (symbol-name sym1)
(symbol-name sym2))))

may what you want.

- jwchoi
PS: I don't know Xlisp is an implementation of Common Lisp. If above
code doesn't work try (lambda ... instead of #'(lambda ....

Rob wrote:
> 
> Hello
> 
> I am trying to sort a list using xlisp v2.0, on a PC.
> 
> According to my Common Lispcraft book there is a sort function however this
> is what happens
> 
> > (sort '(dog bark cow) '>)
> error: bad argument type - BARK
> >
> 
> Can anyone help ?
> 
> Thanks In Advance
> 
> Rob Langley
From: John Atwood
Subject: Re: Sorting a list
Date: 
Message-ID: <5mcjut$8u6$1@news.nero.net>
>> I am trying to sort a list using xlisp v2.0, on a PC.
>> According to my Common Lispcraft book there is a sort functionhowever...
>> 
>> > (sort '(dog bark cow) '>)
>> error: bad argument type - BARK

>The elements of '(dog bark cow) are not numbers, but you tried sort them
>with number comparison - >.
>
>(sort '(dog bark cow) #'(lambda (sym1 sym2) (string> (symbol-name sym1)
>(symbol-name sym2))))
>
>may what you want.
>PS: I don't know Xlisp is an implementation of Common Lisp. If above
>code doesn't work try (lambda ... instead of #'(lambda ....

or:
> (sort '(dog cow bark) 'string-greaterp)
(DOG COW BARK)
> (sort '(dog cow bark) 'string>)
(DOG COW BARK)

this works because a symbol is a string-designator, denoting the string
that is its name. 

John
-- 
--Office phone: 541-737-5583 (Batcheller 349) home: 757-8772
  Office mail:  303 Dearborn Hall, OSU, Corvallis, OR  97331
--As for a picture, if it isn't worth a thousand words, 
  the hell with it.  -- Ad Reinhardt, PM, July 7, 1946
From: Rob
Subject: Re: Sorting A List
Date: 
Message-ID: <01bc6a03$9050ecc0$a66d989e@rob-l.demon.co.uk>
Thanks to everyone who e-mailed

The #'lambda suggestions worked fine

Rob Langley