On Sun, 12 Jun 2005 11:52:10 +0100 (BST), <[EMAIL PROTECTED]> wrote: > > but when one uses :from-end t to specify keeping the first > occurrence the arguments to the test function get flipped.
Someone reused the :from-end nil code.... > I discovered this when I was reading CLtL1. On page 247 > Steele writes > > You may depend on the order in which arguments are given > to /testfn/; this permits the use of non-commutative > test functions in a predictable manner.... > > I thought "That is cool!". It means that I can generate a > short list of prime numbers in `Sieve of Eratosthenes' style When I first read this, I thought it was neat. You start from the end of the sequence and drop anything that (zerop (mod candidate prime)). But this approach will only compare adjacent pairs, or even surviving adjacent pairs. For the short sequence (2 3 4 5 6), adjacent pairs doesn't seem to work in my mind. Then I learned that :from-end only refers to the test pair, not the sequence. "The elements of sequence are compared pairwise, and if any two match, then the one occurring earlier in sequence is discarded, unless from-end is true, in which case the one later in sequence is discarded" > CL-USER(4): (remove-duplicates > '(2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20) > :test (lambda (prime candidate) > (zerop (mod candidate prime))) > :from-end t) >=> (2 3 5 7 11 13 17 19) > > but CMUCL 19b lets all the numbers through the sieve. The interesting test here was : (remove-duplicates '(20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2) :test (lambda (prime candidate) (zerop (mod candidate prime))) :from-end t) ==> (20 19 18 17 16 15 14 13 12 11) This is still 19a-April-2004. I guess that now I better set the work aside and upgrade. -- A sharp edge requires constant honing.