[squeak-dev] The Trunk: Collections-ct.1012.mcz

Thiede, Christoph Christoph.Thiede at student.hpi.uni-potsdam.de
Mon Jun 20 12:50:56 UTC 2022


Hi Levente, Hi Marcel,


> Are those the elements you would expect to be returned?

For me, they are. However, I would also not care about
#(1 2) middle = 1 and #(a b c d) middle = #b.
When I send #middle, I think of #anyOneAboutInTheMiddle. I used this in a few scripts where I wanted to get a sample that is neither from the beginning nor from the end of the collection.
Maybe #anyOneInMiddle would be a better name?


> I think we should discuss this after the release and maybe move it to Inbox for now?

I accept that the existence and behavior of #middle might be questionary. However, this version does not introduce a new feature, it just fixes an incompatibility issue between SequenceableCollection and OrderedDictionary. I am open to any changes to SequenceableCollectino >> #middle, but until we address this, can't we just ensure basic polymorphism between these two classes? I don't see how this would hurt.


> 2. Even #median on SortedCollection is not correct in the math domain.

Fair point, let's address this separately.

Best,
Christoph

________________________________
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von Taeumel, Marcel
Gesendet: Montag, 20. Juni 2022 10:31:17
An: squeak-dev
Betreff: Re: [squeak-dev] The Trunk: Collections-ct.1012.mcz

Hi Christoph --

I think we should discuss this after the release and maybe move it to Inbox for now?

1. I don't think that #middle can be provided reasonably for an arbitrary SequenceableCollection. The +/- 1 index is probably surprising for the user.

2. Even #median on SortedCollection is not correct in the math domain. Shouldn't be the median of #(8 7 5 4 2 1) be 4.5 because there is an even number of elements? Hmm...

Hmm....

Best,
Marcel

Am 17.06.2022 22:43:14 schrieb commits at source.squeak.org <commits at source.squeak.org>:

Christoph Thiede uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ct.1012.mcz

==================== Summary ====================

Name: Collections-ct.1012
Author: ct
Time: 17 June 2022, 10:41:55.471906 pm
UUID: bb97a774-226a-7f43-b69d-4dfc884a681f
Ancestors: Collections-lrnp.1011

Implements missing #middle on OrderedDictionary, just like we already have #first, #last, #ninth etc. there for compatibility with SequenceableCollection.

=============== Diff against Collections-lrnp.1011 ===============

Item was added:
+ ----- Method: OrderedDictionary>>middle (in category 'accessing') -----
+ middle
+ "Answer the middle element of the receiver."
+
+ ^ self atIndex: self size // 2 + 1!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220620/17420d1c/attachment.html>


More information about the Squeak-dev mailing list