[squeak-dev] Some Rosetta examples
Marcel Taeumel
marcel.taeumel at hpi.de
Thu Apr 23 11:49:52 UTC 2020
Hi Nicolas.
> from time to time, we might want to add some Rosetta snippets for our favourite Smalltalk flavor.
Absolutely. :-) Is there a place for this:
input := #( (1 2 3) (a b) (nil) ).
output := input inject: #(()) into: [:a :b | (a collect: [:i | b collect: [:j | i copyWith: j]]) reduce: #,].
"#(#(1 #a nil) #(1 #b nil) #(2 #a nil) #(2 #b nil) #(3 #a nil) #(3 #b nil))"
> One of the pitfalls is the syntax for declaring classes and methods
Reminds me of Christoph's recent DynamicObject proposal. What about this:
Class named: #SomeNewClass vars: #(a b c) withAll: {
#foo -> [:inst | 12 + inst baz].
#bar: -> [:inst :arg | arg + 12].
#baz -> [:inst | inst a].
}
... with auto-generated accessors.
Best,
Marcel
Am 22.04.2020 23:45:54 schrieb Nicolas Cellier <nicolas.cellier.aka.nice at gmail.com>:
Hi all,
from time to time, we might want to add some Rosetta snippets for our favourite Smalltalk flavor.
I have added a Squeak entry for https://rosettacode.org/wiki/Hamming_numbers#Smalltalk [https://rosettacode.org/wiki/Hamming_numbers#Smalltalk]
This is related to the discussion having taken place here about Generator(s), timesCollect: ...
I have used Xtreams for laziness capability.
It's not perfect, because the block read stream does not have absolute positioning capability.
I could have used a Generator, if only it had the capability to skip a batch of items...
The snippet is reasonably fast.
One of the pitfalls is the syntax for declaring classes and methods (bangs gives a wrong idea of what Smalltalk coding is).
I guess that's one of the reasons motivating Pharo's Tonel format (like the gnu format)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200423/ac28e626/attachment.html>
More information about the Squeak-dev
mailing list
|