I think that the `sort' issue is hopeless, since there are many
features you need to make everyone happy. But:
On Oct 2, John Cowan wrote:
> Marcin 'Qrczak' Kowalczyk scripsit:
> > If any sorting is adopted, I call for making Schwartzian transform
> > available.
Please don't use that name. It's obnoxious to put a label that
credits a Perl hacker for rediscovering a popular Lisp feature, and
making the result sound like some method in calculus.
> > People must not be advised to pass
> > (lambda (x y) (< (car x) (car y)))
> > as the comparison. They should pass
> > car <
> > as two separate arguments (or just car with < being the default).
>
> If this is a convenience feature, I'm against it. If it supposedly
> provides improved performance or function of some sort, I'd like to
> see how.
Marcin gave an example that doesn't show the saving. Compare
(sort file-names
(lambda (f1 f2) (< (file-date f1) (file-date f2))))
and
(map cdr
(sort (map (lambda (f) (cons (file-date f) f)) file-names)
(lambda (p1) (< (car p1) (car p2)))))
The scond version is doing half the number of FS accesses. Some Lisp
implementations will do something similar when receiving a `:key'
argument. (And a Perl hacker took it, and it turned to the above
"Transform", as wikipedia will happily tell you.) I personally think
that since
(lambda (x y) (compare (access x) (access y)))
is a very common pattern, then an additional key argument is a good
thing to have for convenience.
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://www.barzilay.org/ Maze is Life!
Received on Mon Oct 02 2006 - 17:55:55 UTC