Dear all,
attached are updated file-outs. I fixed a couple of annoyances that slipped through yesterday evening. Most notable:
1) Random generator now works.
2) Early termination via Reduced exception does MNU anymore.
3) Printing a transducer holding a block does not MNU anymore.
Please, give it a spin and tell me your impressions. (At least) The coin-flipping the example from the package comment works now:
scale := [:x | (x * 2 + 1) floor] map.
sides := #(heads tails) replace.
count := 1000 take.
collect := [:bag :c | bag add: c; yourself].
experiment := (scale * sides * count) transform: collect.
"experiment cannot be re-used"
samples := Random new
�� �� �� �� �� �� �� reduce: experiment
�� �� �� �� �� �� �� init: Bag new.
"transform and reduce in one step"
samples := Random new
�� �� �� �� �� �� �� transduce: scale * sides * count
�� �� �� �� �� �� �� reduce: collect
�� �� �� �� �� �� �� init: Bag new.
"assemble coin (eduction) and flip (reduction) objects"
coin := sides <~ scale <~ Random new.
flip := Bag <~ count.
"flip coin =)"
samples := flip <~ coin.
Cheers!
Steffen
Am .06.2017, 23:08 Uhr, schrieb Steffen M��rcker <merkste@web.de>:
Thanks, this appears to work.�� Attached you'll find the file-out from
VisualWorks and the file-out from Pharo (includes package comment).
Cheers!
Steffen
Am .06.2017, 20:06 Uhr, schrieb Yanni Chiu <yanni.code@gmail.com>:
To get the extension methods into the Transducers package, the following
worked for me - edit the category to have the prefix '*Transducers-'
2710c2710
< !Number methodsFor: 'transforming' stamp: ' 2/6/17 15:38'!
---
!Number methodsFor: '*Transducers-transforming' stamp: ' 2/6/17 15:38'!
On Fri, Jun 2, 2017 at 11:05 AM, Steffen M��rcker <merkste@web.de> wrote:
Dear all,
thanks for the many suggestions. I didn't had time to test all
import/export ways yet. But for now, I can report on two:
1) NGFileOuter
Unfortunately It raised several MNUs in my image. I'll investigate them
later.
2) FileOut30 (VW Contributed)
I was able to file out the code except for the package definition.
Replacing {category: ''} in the class definitions with {package:
'Transducers'} fixed that. However, methods that extend existing classes
did not end up in the Transducers package. Is there a similar easy
change
to the file-out making that happen? Also I'd like to add the package
comment if that's possible.
Most things appear to work as far as I can see. Two exceptions:
1) Random is a subclass of Stream in VW and in Pharo it is not. Hence,
I'll have to copy some methods from Stream to Random.
2) I used #beImmutable in VW but I couldn't yet figure out how to make
objects immutable in Pharo.
However, until the tests are ported, I cannot guarantee. Porting the
test
suite will be another beast, since I rely on the excellent
mocking/stubbing
library DoubleAgents by Randy Coulman. I am not sure how I will handle
that. In general, I think it would be really worth the effort to be
ported
to Pharo, too. DoubleAgents is pretty powerful and produces easy to read
and understand mocking/stubbing code. Personally, I prefer it clearly,
e.g., over Mocketry (no offence intended!).
Attached you'll find the file-out that I loaded into Pharo. The issues
above are not addressed yet. However, the following example works:
| scale sides count collect experiment random samples coin flip |
scale := [:x | (x * 2 + 1) floor] map.
sides := #(heads tails) replace.
count := 1000 take.
collect := [:bag :c | bag add: c; yourself].
experiment := (scale * sides * count) transform: collect.
random := #(0.1 0.3 0.4 0.5 0.6 0.7 0.8 0.9).
samples := random
�� �� �� �� �� �� �� reduce: experiment
�� �� �� �� �� �� �� init: Bag new.
samples := random
�� �� �� �� �� �� �� transduce: scale * sides * count
�� �� �� �� �� �� �� reduce: collect
�� �� �� �� �� �� �� init: Bag new.
coin := sides <~ scale <~ random.
flip := Bag <~ count.
samples := flip <~ coin.
Best, Steffen
Am .06.2017, 08:16 Uhr, schrieb Stephane Ducasse
<stepharo.self@gmail.com
>:
There is a package for that NGFileOuter or something like that on cincom
store.
We used it for mobydic code.
On Wed, May 31, 2017 at 6:35 PM, Alexandre Bergel <
alexandre.bergel@me.com>
wrote:
If I remember correctly, there is a parcel in VisualWorks to export a
file
out (Squeak format).
@Milton, can you give a hand to Steffen?
Alexandre
--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel�� http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
On May 31, 2017, at 10:32 AM, Steffen M��rcker <merkste@web.de> wrote:
Thanks for the encouraging response! First question: Which is the
recommended (friction free) way to exchange code between VW and Pharo?
Cheers!
Steffen
Am .05.2017, 16:22 Uhr, schrieb Alexandre Bergel <
alexandre.bergel@me.com
>:
I second Sven. This is very exciting!
Let us know when you have something ready to be tested.
Alexandre