From: Kimmo T Takkunen
Subject: :test argument question
Date: 
Message-ID: <slrnbm0iq4.575.ktakkune@sirppi.helsinki.fi>
Is the order of parameters to :test function specified in the standard?
Can I use non-commutative test functions like '< etc.

 Kimmo
-- 
((lambda (integer) ;; http://www.iki.fi/kt/ 
   (coerce (loop for i upfrom 0 by 8 below (integer-length integer)
                 collect (code-char (ldb (byte 8 i) integer))) 'string))
 100291759904362517251920937783274743691485481194069255743433035)

From: Rob Warnock
Subject: Re: :test argument question
Date: 
Message-ID: <9-mcnSOAFJNZxf2iXTWc-w@speakeasy.net>
Kimmo T Takkunen <········@cc.helsinki.fi> wrote:
+---------------
| Is the order of parameters to :test function specified in the standard?
+---------------

Yes. See CLHS "17.2.1 Satisfying a Two-Argument Test":

	A :TEST argument, if supplied to F, is a designator
	for a function of two arguments, O and Zi.

[where "Zi" is the value of the :KEY function, if any, or else is
an element "Ei" of the argument sequence.]

That is, with (FIND FOO <seq> :TEST #'BAR), FOO will always be the
first argument given to BAR.

+---------------
| Can I use non-commutative test functions like '< etc.
+---------------

Yes, you can, but be careful to ensure that the result would actually
be what you want it to be. (It might not always be obvious, e.g., with
SET-DIFFERENCE or INTERSECTION, etc.).


-Rob

-----
Rob Warnock, PP-ASEL-IA		<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Wolfhard Buß
Subject: Re: :test argument question
Date: 
Message-ID: <m38yovo6ty.fsf@buss-14250.user.cis.dfn.de>
Kimmo T Takkunen:
> +---------------
> | Is the order of parameters to :test function specified in the standard?
> +---------------

Rob Warnock:
> Yes. See CLHS "17.2.1 Satisfying a Two-Argument Test":
> 
> 	A :TEST argument, if supplied to F, is a designator
> 	for a function of two arguments, O and Zi.
> 
> [where "Zi" is the value of the :KEY function, if any, or else is
> an element "Ei" of the argument sequence.]

CLtL2 is a bit more elaborate on this issue:

`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. The order of the arguments to testfn corresponds
to the order in which those arguments (or the sequences containing
those arguments) were given to the sequence function in question. If a
sequence function gives two elements from the same sequence argument
to testfn, they are given in the same order in which they appear in
the sequence.'

However, Lispniks know that CltL2 is not the authoritative  source.


-- 
"Hurry if you still want to see something. Everything is vanishing."
                                       --  Paul C�zanne (1839-1906)
From: Thomas A. Russ
Subject: Re: :test argument question
Date: 
Message-ID: <ymiy8wv2rqo.fsf@sevak.isi.edu>
········@cc.helsinki.fi (Kimmo T Takkunen) writes:

> 
> Is the order of parameters to :test function specified in the standard?

Yes.

> Can I use non-commutative test functions like '< etc.

Yes.

(find 3 '(1 2 3 4 5 6 7) :test #'<)    ==> 4


-- 
Thomas A. Russ,  USC/Information Sciences Institute