Issue 3641 in pharo: possible new implementation of reduce:

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue 3641 in pharo: possible new implementation of reduce:

pharo
Status: Accepted
Owner: [hidden email]
Labels: Milestone-1.3

New issue 3641 by [hidden email]: possible new implementation of  
reduce:
http://code.google.com/p/pharo/issues/detail?id=3641

there is already a version of reduce: made by lukas and I would like to  
know the difference with this one (proposed by eliot because squeak did not  
got reduce:)

if people can comment on speed... and whatever it would be good.

Collection>>reduce: binaryBlock
        "Apply the argument, binaryBlock cumulatively to the elements of the  
receiver.
        For sequenceable collections the elements will be used in order, for  
unordered
        collections the order is unspecified."

         | first nextValue |
         first := true.
         self do: [ :each |
                 first
                         ifTrue: [ nextValue := each. first := false ]
                         ifFalse: [ nextValue := binaryBlock value:  
nextValue value: each ] ].
         first ifTrue: [ self errorEmptyCollection ].
         ^nextValue! !



Reply | Threaded
Open this post in threaded view
|

Re: Issue 3641 in pharo: possible new implementation of reduce:

pharo
Updates:
        Status: closed

Comment #1 on issue 3641 by [hidden email]: possible new  
implementation of reduce:
http://code.google.com/p/pharo/issues/detail?id=3641

in fact levente already analysed that version to propose the one in the  
other bug entry and that is in squeak.