ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> squeak
squeak
Re: A suggestion
by Richard A. O'Keefe other posts by this author
Mar 13 2002 12:55AM messages near this date
Re: pruning older versions of a method | Re: A suggestion
Henrik Gedenryd <h.gedenryd@[...].uk>  wrote:
	Avoiding the discussion of sorting performance, you can provide a sort block
	to SortedCollections, which then could be something like
	
	[:a :b |
	    (1 to: (a size min: b size)) allSatisfy: [:i |
	        (a at: i) <= (b at: i)]]
	
	This avoids writing an extra method.
	
Aside from the fact that the code shown isn't even close to working
(what I need is lexicographic order, which this isn't, and
 what a sortblock must provide is a total order over the elements in
 the collection, which this doesn't)
it's the same amount of code whether it's in a block or a method.

The difference is that if it's in a method, it can be used elsewhere.

The other difference, of course, is that to implement lexicographic
order, it is convenient to use "^" to exit as soon as a difference is
found.  If I stick that in a block, it will exit the wrong chunk of
code.  The code could be twisted in various ways (some of which I _have_
considered) to avoid this, but I think it is clearest as I wrote it.

If we are allowed to add arrays (and we are), why not compare them?
And if we compare them, is lexicographic order the most suitable?
(There are other orders which are also compatible with =, such as
 - first compare the lengths,
 - then compare the elements ONLY if the lengths are the same.
 This is almost always faster, and has some nice properties.
 It's just not what Squeak uses for Strings.)
Thread:
Richard A. O'Keefe
Hannes Hirzel
Lex Spoon

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved