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