<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<meta content="text/html; charset=UTF-8">
<style type="text/css" style="">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<div dir="ltr">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p><br>
</p>
<div id="x_Signature">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<div name="x_divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<div>
<div class="x__rp_T4" id="x_Item.MessagePartBody">> <span style="font-size:12pt">#gather: has been around since 2002, why not just use that?</span></div>
<div class="x__rp_T4" id="x_Item.MessagePartBody"><br>
</div>
<div class="x__rp_T4" id="x_Item.MessagePartBody">+1</div>
<div class="x__rp_T4" id="x_Item.MessagePartBody">See also: <a href="http://forum.world.st/The-Inbox-Collections-ct-850-mcz-tp5102416p5102476.html" class="x_OWAAutoLink" id="LPlnk776641">http://forum.world.st/The-Inbox-Collections-ct-850-mcz-tp5102416p5102476.html</a><br>
<br>
<span style="font-size:12pt"></span>
<div>Best,</div>
<div>Christoph</div>
<div class="x__rp_U4 x_ms-font-weight-regular x_ms-font-color-neutralDark x_rpHighlightAllClass x_rpHighlightBodyClass" id="x_Item.MessageUniqueBody" style="font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont">
<div dir="ltr">
<div id="x_divtagdefaultwrapper"><font face="Calibri,Helvetica,sans-serif,EmojiFont,Apple Color Emoji,Segoe UI Emoji,NotoColorEmoji,Segoe UI Symbol,Android Emoji,EmojiSymbols">
<div id="x_Signature">
<div style="margin:0px"><font style="font-family:Calibri,Arial,Helvetica,sans-serif,serif,EmojiFont"></font></div>
</div>
</font></div>
</div>
</div>
</div>
</div>
<div><font size="2" color="#808080"></font></div>
</div>
</div>
</div>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>Von:</b> Squeak-dev <squeak-dev-bounces@lists.squeakfoundation.org> im Auftrag von Tobias Pape <Das.Linux@gmx.de><br>
<b>Gesendet:</b> Samstag, 24. Oktober 2020 17:56:24<br>
<b>An:</b> The general-purpose Squeak developers list<br>
<b>Cc:</b> Beckmann, Tom<br>
<b>Betreff:</b> Re: [squeak-dev] RSChartExample almost all working.</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText"><br>
> On 24.10.2020, at 16:16, H. Hirzel <hannes.hirzel@gmail.com> wrote:<br>
> <br>
> Hello<br>
> <br>
> Regarding the missing Squeak method flatCollect: in<br>
> <br>
> Collection, Dictionary, SequenceableCollection, SortedCollection<br>
<br>
<br>
<br>
<br>
> <br>
> This could be a method to include in Squeak trunk as well. It has been<br>
> discussed in Pharo in 2009 see mail copied in below with a summary<br>
> flatCollect: and associated test cases.<br>
<br>
<br>
#gather: has been around since 2002, why not just use that?<br>
<br>
<br>
        #((1 2) (3 4) (5 3)) gather: [:ea | ea] "=>  #(1 2 3 4 5 3)"<br>
        #((1 2) (2 3) () ()) gather: [:ea | ea] "=>  #(1 2 2 3)"<br>
<br>
etc.<br>
I really do not like the "flatten" analogy too much. That said, we do have #flatten/#flattened<br>
<br>
        #((1 2) (2 3) () ()) flatten "=> #(1 2 2 3)"<br>
<br>
This is different in that is has special handling of Strings.<br>
<br>
Best regards<br>
        -Tobias<br>
<br>
<br>
<br>
> <br>
> But it is probably better to copy the code from a current Pharo<br>
> implementation and adapt it.<br>
> <br>
> --Hannes<br>
> <br>
> ---------------------------------------------<br>
> Stéphane Ducasse<stephane.ducasse@inria.fr>   Sun, Dec 27, 2009 at 4:26 PM<br>
> Reply-To: Pharo-project@lists.gforge.inria.fr<br>
> To: "Pharo-project@lists.gforge.inria.fr Development"<br>
> <Pharo-project@lists.gforge.inria.fr><br>
> Reply | Reply to all | Forward | Print | Delete | Show original<br>
> hi<br>
> <br>
> here are the collection extensions we use in Moose.<br>
> I copied them to PharoTaskForces so that we can discuss and tweak the<br>
> code if wanted.<br>
> <br>
> My favorite is<br>
>        flatCollect:/flatCollectAsSet:<br>
>        groupedBy:<br>
> <br>
>        There are really useful.<br>
> <br>
> Stef<br>
> <br>
> <br>
> testFlatCollectArray<br>
>        "self debug: #testFlatCollectArray"<br>
> <br>
>        self assert: ((#((1 2) (3 4) (5 3)) flatCollect: [ :each ]) =<br>
> #(1 2 3 4 5 3)).<br>
>        self assert: ((#((1 2) (2 3) (1 3 4)) flatCollect: [:each]) =<br>
> #(1 2 2 3 1 3 4)).<br>
> <br>
>        self assert: ((#((1 2) (2 3) () ()) flatCollect: [:each]) = #(1 2 2 3)).<br>
> <br>
>        self assert: ((#((1 2) (2 3) (1 3 4)) flatCollect: [:each|<br>
> Array with: each])<br>
>                                        =  #(#(1 2) #(2 3) #(1 3 4))).<br>
> <br>
>        self assert: ((#((1 2) (2 3) (1 3 4)) flatCollect: [:each| Set<br>
> with: each])<br>
>                                        =  #(#(1 2) #(2 3) #(1 3 4))).<br>
> <br>
> <br>
> testFlatCollectSet<br>
>        "self debug: #testFlatCollectSet"<br>
> <br>
>        self assert: ((#((1 2) (1 2) (1 3 4)) asSet  flatCollect:<br>
> [:each]) = #(1 1 2 3 4) asSet).<br>
>        self assert: ((#() asSet flatCollect: [:each]) = #() asSet).<br>
> <br>
>        self assert:  ((#((1 2) () (1 3 4)) asSet  flatCollect:<br>
> [:each]) = #(1 1 2 3 4) asSet).<br>
>        self assert:  ((#((1 2) #((99)) (1 3 4)) asSet  flatCollect: [:each])<br>
>                                        = #(1 1 2 3 4 (99)) asSet).<br>
>        self assert:  ((#((1 2) #(()) (1 3 4)) asSet  flatCollect: [:each])<br>
>                                        = #(1 1 2 3 4 ()) asSet).<br>
> <br>
> testCollectAsSet<br>
>        "self debug: #testCollectAsSet"<br>
> <br>
>        self assert: ((#() collectAsSet: [:each | each odd]) = Set new).<br>
>        self assert: (#(1 2 3 4 5 6) collectAsSet: [:each | each odd])<br>
>                                         = (Set with: true with: false).<br>
>        self assert: (#(1 3 5 7 9 11) collectAsSet: [:each | each odd])<br>
>                                        = (Set with: true).<br>
> <br>
>        self assert: (#(1 2 3 4 5 4 3 2 1) collectAsSet: [:each |<br>
> each]) = (1 to: 5) asSet.<br>
> <br>
> <br>
> testGroupedByArray<br>
>        "self debug: #testGroupedByArray"<br>
> <br>
>        | res |<br>
>        res := #(1 2 3 4 5) groupedBy: [:each | each odd].<br>
>        self assert:   (res at: true) = #(1 3 5).<br>
>        self assert: (res at: false) = #(2 4)<br>
> <br>
> <br>
> <br>
> Set>>flatCollect: aBlock<br>
> <br>
> <br>
>        ^self flatCollectAsSet: aBlock<br>
> <br>
> <br>
> Symbol>>value<br>
>        "Allow this object to act as a ValueHolder on itself."<br>
> <br>
>        ^self<br>
> <br>
> OrderedCollection>>removeAtIndex: anIndex<br>
>        "Remove the element of the collection at position anIndex.<br>
> Answer the object removed."<br>
> <br>
>        | obj |<br>
>        obj := self at: anIndex.<br>
>        self removeIndex: anIndex + firstIndex - 1.<br>
>        ^obj<br>
> <br>
> Collection<br>
> ==============================<br>
> <br>
> collectAsSet: aBlock<br>
>        "Evaluates aBlock for each element of the receiver and collects<br>
>        the resulting values into a Set."<br>
> <br>
>        "This is an efficient shorthand for [ (self collect: aBlock) asSet ]."<br>
>        "originally developed by a. kuhn and released under MIT."<br>
> <br>
>        ^self inject: Set new into: [ :set :each |<br>
>                set add: (aBlock value: each); yourself ].<br>
> <br>
> <br>
> copyEmpty: aSize<br>
>        "Answer a copy of the receiver that contains no elements.<br>
> <br>
>        This method should be redefined in subclasses that add<br>
>        instance variables, so that the state of those variables<br>
>        is preserved"<br>
> <br>
>        ^self class new: aSize<br>
> <br>
> <br>
> flatCollect: aBlock<br>
>        "Evaluate aBlock for each of the receiver's elements and answer the<br>
>        list of all resulting values flatten one level. Assumes that<br>
> aBlock returns some kind<br>
>        of collection for each element. Equivalent to the lisp's mapcan"<br>
>        "original written by a. Kuhn and released under MIT"<br>
> <br>
>        | stream |<br>
>        self isEmpty ifTrue: [ ^ self copy ].<br>
>        stream := (self species new: 0) nsWriteStream.<br>
>        self do: [ :each | stream nextPutAll: (aBlock value: each) ].<br>
>        ^ stream contents<br>
> <br>
> flatCollectAsSet: aBlock<br>
>        "Evaluate aBlock for each of the receiver's elements and answer the<br>
>        list of all resulting values flatten one level. Assumes that<br>
> aBlock returns some kind<br>
>        of collection for each element. Equivalent to the lisp's mapcan"<br>
> <br>
>        "original written by a. Kuhn and released under MIT"<br>
> <br>
>        | set |<br>
>        self isEmpty ifTrue: [^self copy ].<br>
>        set := Set new.<br>
>        self do: [ :each |<br>
>                set addAll: (aBlock value: each) ].<br>
>        ^set<br>
> <br>
> <br>
> flatten<br>
>        "Recursively collect each non-collection element of the<br>
> receiver and its descendant<br>
>        collections.  Please note, this implementation assumes that<br>
> strings are to be treated<br>
>        as objects rather than as collection."<br>
> <br>
>        ^self gather: [ :each ]<br>
> <br>
> groupedBy: aBlock<br>
>        "Return a dictionary whose keys are the result of evaluating<br>
> aBlock for all elements in<br>
>         the collection, and the value for each key is the collection<br>
> of elements that evaluated<br>
>         to that key. e.g.<br>
>             #(1 2 3 4 5) groupedBy: [:each | each odd]<br>
>           a Dictionary<br>
>             true ---> #( 1 3 5)<br>
>             false --> #(2 4)<br>
>        originally developed by a. kuhn and released under MIT."<br>
> <br>
>        | result |<br>
>        result := Dictionary new.<br>
>        self do:<br>
>                [:each | | key collection |<br>
>                key := aBlock value: each.<br>
>                collection := result at: key ifAbsentPut:<br>
> [OrderedCollection new].<br>
>                collection add: each].<br>
>        self species ~~ OrderedCollection ifTrue:<br>
>                ["Convert the result collections to be the right type.<br>
>                  Note that it should be safe to modify the dictionary<br>
>                  while iterating because we only replace values for<br>
> existing keys"<br>
>                result keysAndValuesDo:<br>
>                        [:key :value | result at: key put: (self<br>
> species withAll: value)]].<br>
> <br>
>        ^result<br>
> <br>
> includesAll: aCollection<br>
>        "Answer true if the receiver includes all elements of<br>
> aCollection with at<br>
>        least as many occurrences as in aCollection. For a less strict<br>
> comparison<br>
>        please refer to supersetOf: and its inverse subsetOf:."<br>
> <br>
> <br>
>        ^(aCollection isCollection) and: [<br>
>                aCollection size <= self size and: [<br>
>                        aCollection allSatisfy: [ :each |<br>
>                                (aCollection occurrencesOf: each) <=<br>
> (self occurrencesOf: each) ]]]<br>
> <br>
> nilSafeGroupedBy: aBlock<br>
>        ^ self groupedBy: [ :each |<br>
>                | value |<br>
>                value := aBlock value: each.<br>
>                value ifNil: [ UndefinedObject ].<br>
>        ]<br>
> <br>
> selectAsSet: aBlock<br>
>        "Evaluate aBlock with each of the receiver's elements as the argument.<br>
>        Collect into a new set, only those elements for which<br>
>        aBlock evaluates to true.  Answer the new collection."<br>
> <br>
>        | newSet |<br>
>        newSet := Set new.<br>
>        self do: [:each | (aBlock value: each) ifTrue: [newSet add: each]].<br>
>        ^newSet<br>
> <br>
> shuffle<br>
>        "Swaps the receiver's elements at random."<br>
> <br>
>        self shuffle: (self size * self size log) asInteger<br>
> <br>
> sum: aSymbolOrBlock<br>
> <br>
>        ^self<br>
>                inject: 0<br>
>                into: [:sum :each | sum + (aSymbolOrBlock value: each)]<br>
> <br>
> shuffle: times<br>
>        "Swaps random elements of the receiver."<br>
> <br>
>        | size random |<br>
>        size := self size.<br>
>        random := Random new.<br>
>        times timesRepeat: [<br>
>                self swap: (random next * size) floor + 1 with:<br>
> (random next * size) floor + 1<br>
>        ].<br>
> <br>
> <br>
> <br>
> <br>
> <br>
> On 10/24/20, gettimothy via Squeak-dev<br>
> <squeak-dev@lists.squeakfoundation.org> wrote:<br>
>> Hi Folks,<br>
>> <br>
>> <br>
>> <br>
>> I am going through the RSChartExample examples.<br>
>> <br>
>> <br>
>> <br>
>> Most are working.<br>
>> <br>
>> <br>
>> <br>
>> The one below prefaced with an 'x' are not working , those without the 'x'<br>
>> are working...<br>
>> <br>
>> <br>
>> <br>
>> <br>
>> <br>
>> RSChartExample new example01Markers open.<br>
>> <br>
>> RSChartExample new example02ScatterPlot open.<br>
>> <br>
>> RSChartExample new example03Plot open.<br>
>> <br>
>> RSChartExample new example04WithTick open.<br>
>> <br>
>> RSChartExample new example05WithTick open.<br>
>> <br>
>> RSChartExample new example06CustomNumberOfTicks open.<br>
>> <br>
>> RSChartExample new example07AdjustingFontSize open.<br>
>> <br>
>> RSChartExample new example08TwoCharts open.<br>
>> <br>
>> RSChartExample new example09LinearSqrtSymlog open.<br>
>> <br>
>> RSChartExample new example10BarPlot open.<br>
>> <br>
>> RSChartExample new example11BarplotCombinedWithLine open.<br>
>> <br>
>> RSChartExample new example12ScatterPlotAndNormalizer open.<br>
>> <br>
>> xRSChartExample new example13AreaPlot open.<br>
>> <br>
>> xRSChartExample new example14AreaPlotWithError open.<br>
>> <br>
>> xRSChartExample new example15AreaBox open.<br>
>> <br>
>> xRSChartExample new example16Series open.<br>
>> <br>
>> xRSChartExample new example17CLPvsUSD open.<br>
>> <br>
>> xRSChartExample new example18Animation open.<br>
>> <br>
>> <br>
>> <br>
>> <br>
>> <br>
>> <br>
>> <br>
>> The ones with the 'x' are failing on a method I have imported from pharo<br>
>> <br>
>> <br>
>> <br>
>> Collection, Dictionary, SequenceableCollection, SortedCollection need to<br>
>> implement flatCollect:<br>
>> <br>
>> Collection >>flatCollect: aBlock<br>
>> <br>
>> "Evaluate aBlock for each of the receiver's elements and answer the<br>
>> <br>
>> list of all resulting values flatten one level. Assumes that aBlock returns<br>
>> some kind<br>
>> <br>
>> of collection for each element. Equivalent to the lisp's mapcan"<br>
>> <br>
>> <br>
>> <br>
>> "( #((3 4) (1 2)) flatCollect: [:each | each ] )>>> #(3 4 1 2)"<br>
>> <br>
>> "( #(3 4 1 2) flatCollect: [:each | { each } ] ) >>> #(3 4 1 2)"<br>
>> <br>
>> <br>
>> <br>
>> ^ self flatCollect: aBlock as: self species<br>
>> <br>
>> <br>
>> <br>
>> etc...<br>
>> <br>
>> <br>
>> <br>
>> The error I am getting is an 'Attempt to index a non-existent element in an<br>
>> OrderedCollection from the flatCollect in SequenceableCollection...(The<br>
>> breaks and method vars are mine as I attempt to grok this)<br>
>> <br>
>> <br>
>> <br>
>> SequenceableCollection >> flatCollect: aBlock<br>
>> <br>
>> "Evaluate aBlock for each of the receiver's elements and answer the<br>
>> <br>
>> list of all resulting values flatten one level. Assumes that aBlock returns<br>
>> some kind<br>
>> <br>
>> of collection for each element. optimized version for Sequencable Collection<br>
>> and subclasses<br>
>> <br>
>> implementing #writeStream"<br>
>> <br>
>> <br>
>> <br>
>> "(#( (2 -3) (4 -5) #(-6)) flatCollect: [ :e | e abs  ]) >>> #(2 3 4 5 6)"<br>
>> <br>
>> <br>
>> <br>
>> "(#( (2 -3) #((4 -5)) #(-6)) flatCollect: [ :e | e abs  ]) >>> #(2 3 #(4 5)<br>
>> 6)"<br>
>> <br>
>> |x i|<br>
>> <br>
>> self isEmpty<br>
>> <br>
>> ifTrue: [ ^ self copy ].<br>
>> <br>
>> i := 0.<br>
>> <br>
>> x := self species<br>
>> <br>
>> new: 0<br>
>> <br>
>> streamContents: [ :stream | self do: [ :each |<br>
>> <br>
>> i := i +1.<br>
>> <br>
>> stream nextPutAll: (aBlock value: each).  <--BARFS HERE<br>
>> <br>
>> self break.  <--NEVER REACHED<br>
>> <br>
>> ]].<br>
>> <br>
>> <br>
>> <br>
>> ^x.<br>
>> <br>
>> <br>
>> <br>
>> <br>
>> <br>
>> <br>
>> <br>
>> The above fails in<br>
>> <br>
>> <br>
>> <br>
>> SequenceableCollection >> replaceFrom: start to: stop with: replacement<br>
>> startingAt: repStart<br>
>> <br>
>> "This destructively replaces elements from start to stop in the receiver<br>
>> <br>
>> starting at index, repStart, in the sequenceable collection,<br>
>> <br>
>> replacementCollection. Answer the receiver. No range checks are<br>
>> <br>
>> performed."<br>
>> <br>
>> <br>
>> <br>
>> | index repOff |<br>
>> <br>
>> repOff := repStart - start.<br>
>> <br>
>> index := start - 1.<br>
>> <br>
>> [(index := index + 1) <= stop]<br>
>> <br>
>> whileTrue: [self at: index put: (replacement at: repOff + index)]   <- BARF<br>
>> HERE<br>
>> <br>
>> <br>
>> <br>
>> <br>
>> <br>
>> at the at: put:<br>
>> <br>
>> <br>
>> <br>
>> I will be figuring this out next.<br>
>> <br>
>> <br>
>> <br>
>> <br>
>> <br>
>> FWIW, using the Git Browser on the pharo repo...I make the pharo9 "current'<br>
>> and then am able to get GradientPaint and required classes into Squeak....<br>
>> <br>
>> <br>
>> <br>
>> steps are these:<br>
>> <br>
>> <br>
>> <br>
>> <br>
>> <br>
>> From Git Browser....<br>
>> <br>
>> <br>
>> <br>
>> Switch to Pharo9 branch.<br>
>> <br>
>> <br>
>> <br>
>> src/Athens-Core browse Edition in Selected Version<br>
>> <br>
>> in the browser...Athens-Core-Paints->AthensAbstractPaint<br>
>> <br>
>> load class.<br>
>> <br>
>> same for, GradientPaint  LinearGradientPaint and RadialGradientPaint<br>
>> <br>
>> <br>
>> <br>
>> anyhoo, progress.<br>
>> <br>
>> <br>
>> <br>
>> <br>
>> <br>
>> Also, the Morphic folks, once we get this working, will probably want to<br>
>> poke around to make the BalloonMorphs behave.<br>
> <br>
<br>
<br>
<br>
</div>
</span></font>
</body>
</html>