chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] sorted? bug?


From: Christian Kellermann
Subject: Re: [Chicken-users] sorted? bug?
Date: Tue, 11 Oct 2011 09:16:37 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

* Paul Colby <address@hidden> [111011 05:14]:
> Hi,
> 
> I noticed what I feel is an incorrect behavior for the function sorted?
> My understanding is that (sorted? list test) should return #t if pairwise
> the elements of list (test e-n e-n+1) is true for all n. However, I get 
> the following I think rather odd behavior using 4.7.0 interpreted,
> 
>    (sorted? '(1 2 3) < )  is #t. good so far
>    (sorted? '(1 1 3) <)   is #t  but should be #f since (< 1 1) is #f 
>    (sorted? '(1 1 3) <=) is #f  but should be #t since (<= 1 1) is #t
> 
> Am I missing something? 

Please note that the semantics of the third parameter is less?,
i.e. the predicat should return #t only if element i-1 is less than
i.

The actual result is calculated as
(not (less? (list-ref list i) (list-ref list (- i 1)))).

for each element i, where i is 1 <= i <= m, for a list or vector
if size m.

so for your list '(1_a 1_b 3) it asks is 1_b less than 1_a and the
answer is #t so your statement is false altogether.

(The i starts at 1 but list-ref is 0-based).

Does that make sense?

Cheers,

Christian

-- 
Who can (make) the muddy water (clear)? Let it be still, and it will
gradually become clear. Who can secure the condition of rest? Let
movement go on, and the condition of rest will gradually arise.
 -- Lao Tse. 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]