Eliot Miranda uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-eem.369.mcz ==================== Summary ==================== Name: Collections-eem.369 Author: eem Time: 17 July 2010, 5:09:14.555 pm UUID: d00ce3cb-ed13-4fb6-8494-4ecd067c4f1d Ancestors: Collections-ar.368 Collection>>fold: and SequenceableCollection>>copyUpThrough:, extensions used by Cog VMMaker. Change to older semantics of Character>>hex for Cog VMMaker. =============== Diff against Collections-ar.368 =============== Item was added: + ----- Method: Collection>>fold: (in category 'enumerating') ----- + fold: binaryBlock + "Evaluate the block with the first two elements of the receiver, + then with the result of the first evaluation and the next element, + and so on. Answer the result of the final evaluation. If the receiver + is empty, raise an error. If the receiver has a single element, answer + that element." + "#('if' 'it' 'is' 'to' 'be' 'it' 'is' 'up' 'to' 'me') fold: [:a :b | a, ' ', b]" + + | firstValue nextValue | + firstValue := nextValue := Object new. "something that can't be in the receiver" + self do: + [:each | + nextValue := firstValue == nextValue + ifTrue: [each] + ifFalse: [binaryBlock value: nextValue value: each]]. + ^nextValue == firstValue + ifTrue: [self errorEmptyCollection] + ifFalse: [nextValue]! Item was changed: ----- Method: Character>>hex (in category 'printing') ----- hex + ^value printStringBase: 16! - ^value hex! Item was added: + ----- Method: SequenceableCollection>>copyUpThrough: (in category 'copying') ----- + copyUpThrough: anElement + "Answer all elements up to and including anObject. If there + is no such object, answer a copy of the receiver." + + ^self first: (self indexOf: anElement ifAbsent: [^ self copy])! |
On Sun, 18 Jul 2010, [hidden email] wrote:
> Eliot Miranda uploaded a new version of Collections to project The Trunk: > http://source.squeak.org/trunk/Collections-eem.369.mcz > > ==================== Summary ==================== > > Name: Collections-eem.369 > Author: eem > Time: 17 July 2010, 5:09:14.555 pm > UUID: d00ce3cb-ed13-4fb6-8494-4ecd067c4f1d > Ancestors: Collections-ar.368 > > Collection>>fold: and SequenceableCollection>>copyUpThrough:, extensions used by Cog VMMaker. > Change to older semantics of Character>>hex for Cog VMMaker. > > =============== Diff against Collections-ar.368 =============== > > Item was added: > + ----- Method: Collection>>fold: (in category 'enumerating') ----- > + fold: binaryBlock > + "Evaluate the block with the first two elements of the receiver, > + then with the result of the first evaluation and the next element, > + and so on. Answer the result of the final evaluation. If the receiver > + is empty, raise an error. If the receiver has a single element, answer > + that element." > + "#('if' 'it' 'is' 'to' 'be' 'it' 'is' 'up' 'to' 'me') fold: [:a :b | a, ' ', b]" > + > + | firstValue nextValue | > + firstValue := nextValue := Object new. "something that can't be in the receiver" > + self do: > + [:each | > + nextValue := firstValue == nextValue > + ifTrue: [each] > + ifFalse: [binaryBlock value: nextValue value: each]]. > + ^nextValue == firstValue > + ifTrue: [self errorEmptyCollection] > + ifFalse: [nextValue]! This does the same as Collection >> #reduce:, thought the implementation is different. > > Item was changed: > ----- Method: Character>>hex (in category 'printing') ----- > hex > + ^value printStringBase: 16! > - ^value hex! This keeps the semantics of the 3.10 version of Character >> #hex . In 3.8 and before Character >> #hex was just ^value hex. Levente > > Item was added: > + ----- Method: SequenceableCollection>>copyUpThrough: (in category 'copying') ----- > + copyUpThrough: anElement > + "Answer all elements up to and including anObject. If there > + is no such object, answer a copy of the receiver." > + > + ^self first: (self indexOf: anElement ifAbsent: [^ self copy])! > > > |
Free forum by Nabble | Edit this page |