[Pharo-users] Re: BlockClosure folding

2022-03-16 Thread Richard O'Keefe
Pattern? I'd call it an antipattern myself. Note that we can already construct { block1 . block2 . block3 } and write { block1 . block2 . block3 } allSatisfy: [:each | each value]. so we don't have to abuse the #, selector or write a single new method to get the "flattened" structu

[Pharo-users] Re: BlockClosure folding

2022-03-16 Thread Richard O'Keefe
The motivating example can be written aHasDot := a includes: $.. bHasDot := b includes: $.. ^aHasDot = bHasDot ifFalse: [bHasDot] ifTrue: [aHasDot ifTrue: [a < b] ifFalse: [a > b]] (Dijkstra was right. People *do* forget that '='

[Pharo-users] Re: BlockClosure folding

2022-03-15 Thread Hernán Morales Durand
This is an interesting pattern. Thank you for sharing. Hernán El mar, 15 mar 2022 a las 4:43, Julián Maestri () escribió: > Not satisfying the equality, but you can use polymorphism. > > Block >> , aBlock > ^ BlockCompositor andAll: OrderedCollection with: self with: aBlock > > BlockComposit

[Pharo-users] Re: BlockClosure folding

2022-03-15 Thread Hernán Morales Durand
Exactly. This was what I was looking for. Thank you Sean. Hernán El mar, 15 mar 2022 a las 19:15, escribió: > ComplexCondition as described in Andres Valloud, "A Mentoring Course on > Smalltalk" > > is available at

[Pharo-users] Re: BlockClosure folding

2022-03-15 Thread sean
ComplexCondition as described in [Andres Valloud, "A Mentoring Course on Smalltalk"](http://www.lulu.com/product/paperback/a-mentoring-course-on-smalltalk/3788890) is available at http://www.squeaksource.com/ComplexCondition.html With it, you can do something like: ``` ^[a includes: $.], [b inc

[Pharo-users] Re: BlockClosure folding

2022-03-14 Thread Julián Maestri
Not satisfying the equality, but you can use polymorphism. Block >> , aBlock ^ BlockCompositor andAll: OrderedCollection with: self with: aBlock BlockCompositor >> #, aBlock conditions add: aBlock. BlockCompositor >> value: anObject ^ conditions allSatisfy: [:e | e value: anObject ]