[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Order of arguments to sequence :TEST functions
- To: Moon@stony-brook.scrc.symbolics.com
- Subject: Order of arguments to sequence :TEST functions
- From: gls@Think.COM
- Date: Mon, 29 Feb 88 15:04:44 EST
- Cc: DCP@quabbin.scrc.symbolics.com, email@example.com
- In-reply-to: David A. Moon's message of Mon, 29 Feb 88 13:55 EST <19880229185550.0.MOON@EUPHRATES.SCRC.Symbolics.COM>
Date: Mon, 29 Feb 88 13:55 EST
From: David A. Moon <Moon@stony-brook.scrc.symbolics.com>
Date: Mon, 29 Feb 88 09:34 EST
From: David C. Plummer <DCP@QUABBIN.SCRC.Symbolics.COM>
CLtL page 247 says
... (funcall testfn item (keyfn x)) ...
I'm curious to know why this order was chosen instead of
... (funcall testfn (keyfn x) item) ...
The design rationale is given just a few lines lower on the same
page. The order of arguments to the testfn is kept consistent with
the order of arguments to the sequence function in question.
The moral is: When in doubt...
What I was trying to do was use FIND to find an item of a certain type,
(find type sequence :test #'typep)
but the order of the arguments as defined in CLtL is backwards.
Looks like a job for LAMBDA.
Or, for a general solution, try the C combinator:
(defun C (fn) #'(lambda (x y) (funcall fn y x)))
(find type sequence :test (C #'typep))
(find 3 numlist :text (C #'<)) ;find something less than 3