[squeak-dev] Re: 1.0 not a valid VersionNumber?

Matthew Fulmer tapplek at gmail.com
Fri Apr 11 05:01:12 UTC 2008


On Wed, Apr 09, 2008 at 01:35:21PM -0700, Andreas Raab wrote:
> Stephen Pair wrote:
>> Did you actually mean true? (if not, I don't actually get what you're 
>> after)...VersionNumber aside, I wonder what you could reasonably infer 
>> from answer answer of true given for '1.1.2' < '1.12.3' ...I don't think 
>> you could infer that 1.12.3 was published  after 1.1.2 for example.  I 
>> don't think you could infer that 1.12.3 includes everything in included in 
>> 1.1.2 (i.e. that 1.12.3 is derived from 1.1.2).  About all you could infer 
>> is that 1 < 12.
>
> Which is precisely what I was after.

Keith Hodges Kernel extensions has a method that does just that.
http://www.squeaksource.com/311

SequencableCollection>>#<= otherCollection

"comparison for multi key sorts. note how boolean and nil IS supported for sorting"

| a b |
1 to: (self size min: otherCollection size) do: [ :index |
    a := self at: index. b := otherCollection at: index.
    
    (a == true and: [ b == false ]) ifTrue: [ ^ false ].
    (a == false and: [ b == true ]) ifTrue: [ ^ true ].
    
    a isNil ifTrue: [ ^ true ].
    b isNil ifTrue: [ ^ false ].
            
    a ~= b ifTrue: [ ^ a <= b ].
            
].
    
^ self size <= otherCollection size

"
#(1 2) <= #(1 3)
#(1 2 3) <= #(1 2)
#(1 2 3) <= #(1 3)
#(1 3) <= #(1 1)
#(1 2 false) <= #(1 2 true)
#(1 2 true) <= #(1 2 false)
#(1 2 true) <= #(1 2 nil)
"

-- 
Matthew Fulmer -- http://mtfulmer.wordpress.com/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SequenceableCollection-<=.st
Type: text/x-squeak-fileout
Size: 820 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20080410/c9c13f98/SequenceableCollection-.bin


More information about the Squeak-dev mailing list