[squeak-dev] The Inbox: Kernel-ct.1266.mcz

Marcel Taeumel marcel.taeumel at hpi.de
Fri Sep 6 14:58:16 UTC 2019


I put a proposal in the inbox: Collections-mt.852.

Best,
Marcel
Am 06.09.2019 16:47:05 schrieb Thiede, Christoph <christoph.thiede at student.hpi.uni-potsdam.de>:
Good point. Maybe introduce a new selector, for example #new:withEach:? It might be misleading if you really want to create a collection of blocks.

OrderedCollection
    new: 20
    withEach: [50 atRandom]

I think the block should be called with #cull:, as there are many cases where index does not matter.

Best,
Christoph
Von: Taeumel, Marcel
Gesendet: Freitag, 6. September 2019 16:40:59
An: Thiede, Christoph; gettimothy via Squeak-dev
Betreff: Re: AW: [squeak-dev] The Inbox: Kernel-ct.1266.mcz
 
I think it is better to name the kind of collection you are going to fill. 

For some of these examples, there are better ways such as "OrderedCollection new: 20 withAll: 0".

Maybe support blocks in #new:withAll:?

OrderedCollection
   new: 20
   withAll: [:index | index atRandom]


Best,
Marcel
Am 06.09.2019 16:04:49 schrieb Thiede, Christoph <christoph.thiede at student.hpi.uni-potsdam.de>:
> Especially since #timesRepeat: does not provide the iteration number to the block.
But so does #timesRepeat:? I was looking for a convenient way to evaluate a block n times and store the results. There seem to be various methods which, imho, could be written simpler:


Best,
Christoph
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von Taeumel, Marcel
Gesendet: Freitag, 6. September 2019 15:36:49
An: gettimothy via Squeak-dev
Betreff: Re: [squeak-dev] The Inbox: Kernel-ct.1266.mcz
 
Hmm... #timesCollect: seems strange. Especially since #timesRepeat: does not provide the iteration number to the block. Then, #to:collect: has a similar problem: "from x to y collect what?" The explicit from "(x to: y)" for the interval object seems more readable.

-1  ;-)

Best,
Marcel
Am 06.09.2019 13:16:54 schrieb commits at source.squeak.org <commits at source.squeak.org>:
A new version of Kernel was added to project The Inbox:
http://source.squeak.org/inbox/Kernel-ct.1266.mcz

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

Name: Kernel-ct.1266
Author: ct
Time: 6 September 2019, 1:16:39.325698 pm
UUID: a5b0464f-61cf-4749-9ad3-92e7d8c85341
Ancestors: Kernel-eem.1265

Add shorthands for interval collecting

There are enough senders of #timesRepeat: that manually fill a collection, same goes for #to:do:

=============== Diff against Kernel-eem.1265 ===============

Item was added:
+ ----- Method: Integer>>timesCollect: (in category 'enumerating') -----
+ timesCollect: aBlock
+
+ ^ (1 to: self) collect: [:i | aBlock value]!

Item was added:
+ ----- Method: Number>>to:collect: (in category 'intervals') -----
+ to: stop collect: aBlock
+ "Evaluate aBlock for each element of the interval (self to: stop by: 1) and return the results."
+
+ ^ (self to: stop) collect: aBlock!


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


More information about the Squeak-dev mailing list