Copy appears to be most reliable as it does not modify the original list. Maybe 
a tiny bit slower than ->(setq L (sort L))

: (setq L (3 2 1 4 9 0]
-> (3 2 1 4 9 0)

: (sort (copy L]
-> (0 1 2 3 4 9)
: L
-> (3 2 1 4 9 0) 

: (setq L (sort L]
-> (0 1 2 3 4 9)
: L-> (0 1 2 3 4 9)

JmageK
-- 
Securely sent with Tutanota



May 4, 2019, 8:10 PM by a...@software-lab.de:

> Hi  Kashyap,
>
>> I noticed an odd behavior of sort -
>> (setq L '((2) (1) ))
>> (sort L)
>>
>
> Note that 'sort' is a destructive function, it modifies the order of cells
> in-place. Thus you must use the return value of 'sort', it may return another
> cell than was passed to it.
>
> In the above, the return value of 'sort' is ignored and thus lost.
>
> Try either
>
> : (length (sory L))
>
> or
>
> : (setq L (sort L))
>
> ☺/ A!ex
>
> -- 
> UNSUBSCRIBE: mailto:> picolisp@software-lab.de 
> <mailto:picolisp@software-lab.de>> ?subject=Unsubscribe
>


--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to