[Pharo-users] next sttep after the example tutorial

2014-11-07 Thread Roelof Wobben
Hello,

Is there a book / tutorial/ challenges that I can use to become a expert 
in Pharo ?


Roelof




Re: [Pharo-users] next sttep after the example tutorial

2014-11-07 Thread Roelof Wobben
  
  
Thanks. 
  
  By expert I mean I can write and test most of the programms and
  know very well how pharo works. 
  
  Roelof
  
  
  Peter Uhnák schreef op 7-11-2014 18:12:


  Well for start there is this http://pharo.org/documentation
(books Pharo By Example + Deep into Pharo + Pharo for the
Enterprise) and this http://pharo.gemtalksystems.com/


As far as expertise goes you can probably become an expert
  by writing a book about Pharo. :)


Peter
  
  

  
  
On Fri, Nov 7, 2014 at 6:01 PM, Roelof
  Wobben <r.wob...@home.nl>
  wrote:
  Hello,

Is there a book / tutorial/ challenges that I can use to
become a expert in Pharo ?

Roelof


  


  


  




Re: [Pharo-users] next sttep after the example tutorial

2014-11-07 Thread Roelof Wobben
  
  
oke, are there books / tutorials I can
  do so I can understand better how smalltalk works. 
  
  I was thinking of making a calculator as my first project. 
  
  Roelof
  
  
  
  kilon alios schreef op 7-11-2014 18:34:


  yes, read all the pharo documentation, read the
entire pharo code, understand the entire pharo code, make a few
hundrend pharo application and boom your are an expert :) 


Seriously though, do whatever is interesting to you and ask
  questions here and in stackoverflow. You dont need to be
  expert , just someone that finds pharo enjoyable and useful. 
  
  
On Fri, Nov 7, 2014 at 7:17 PM, Roelof
  Wobben <r.wob...@home.nl>
  wrote:
  

  Thanks. 

By expert I mean I can write and test most of the
programms and know very well how pharo works. 

Roelof


Peter Uhnák schreef op 7-11-2014 18:12:
  
  

  
Well for start there is this http://pharo.org/documentation
  (books Pharo By Example + Deep into Pharo + Pharo
  for the Enterprise) and this http://pharo.gemtalksystems.com/
  
  
  As far as expertise goes you can probably
become an expert by writing a book about Pharo.
:)
  
  
  Peter


  


  On Fri, Nov 7, 2014 at
6:01 PM, Roelof Wobben <r.wob...@home.nl>
wrote:
Hello,
  
  Is there a book / tutorial/ challenges that I
  can use to become a expert in Pharo ?
  
  Roelof
  
  

  
  

  
  

  

  


  


  




Re: [Pharo-users] next sttep after the example tutorial

2014-11-07 Thread Roelof Wobben
  
  
I did it and run into my first problem.
  
  
  There is no method finder in the tools menu.
  
  Roelof
  
  
  
  
  Peter Uhnák schreef op 7-11-2014 19:21:


  Now that you mentioned calculator, have a look at
this
https://medium.com/@svenvc/rediscovering-the-ux-of-the-legendary-hp-35-scientific-pocket-calculator-d1d497ece999



also this article is great https://medium.com/@svenvc/elegant-pharo-code-bb590f0856d0


But otherwise start with the book Pharo By Example... it
  should give you everything to get you started. You can
  download it here http://pharobyexample.org/


Peter
  
  
On Fri, Nov 7, 2014 at 7:13 PM, Roelof
  Wobben <r.wob...@home.nl>
  wrote:
  

  oke, are there books / tutorials I can do so I can
understand better how smalltalk works. 

I was thinking of making a calculator as my first
project. 

Roelof



kilon alios schreef op 7-11-2014 18:34:
  
  

  
yes, read all the pharo
  documentation, read the entire pharo code,
  understand the entire pharo code, make a few
  hundrend pharo application and boom your are an
  expert :) 
  
  
  Seriously though, do whatever is interesting
to you and ask questions here and in
stackoverflow. You dont need to be expert , just
someone that finds pharo enjoyable and useful. 


  On Fri, Nov 7, 2014 at
7:17 PM, Roelof Wobben <r.wob...@home.nl>
wrote:

  
Thanks. 
  
  By expert I mean I can write and test most
  of the programms and know very well how
  pharo works. 
  
  Roelof
  
  
  Peter Uhnák schreef op 7-11-2014 18:12:


  

  Well for start there is
this http://pharo.org/documentation
(books Pharo By Example + Deep into
Pharo + Pharo for the Enterprise)
and this http://pharo.gemtalksystems.com/


As far as expertise goes you
  can probably become an expert by
  writing a book about Pharo. :)


Peter
  
  

  
  
On Fri, Nov
  7, 2014 at 6:01 PM, Roelof Wobben
  <r.wob...@home.nl>
  wrote:
  Hello,

Is there a book / tutorial/
challenges that I can use to
become a expert in Pharo ?

Roelof


  


  


  

  

  
  

  
  

  

  


  


  




Re: [Pharo-users] next sttep after the example tutorial

2014-11-07 Thread Roelof Wobben
  
  
Thanks, 
  
  I can see a choice finder but as far as I can see I cannot use it
  for modules.
  
  Roelof
  
  
  
  
  kilon alios schreef op 7-11-2014 21:21:


  start here


http://pharo.org/documentation



here a video tutorial series i created


https://www.youtube.com/playlist?list=PLqbtQ7OkSta0ULYAd7Qdxof851ybh-_m_



you can skip first video "Why Pharo" the rest is practical
  tutorials.


if you got Pharo 3 or 4 , finder should be in the tools
  section of world menu. 
  
  
On Fri, Nov 7, 2014 at 8:13 PM, Roelof
  Wobben <r.wob...@home.nl>
  wrote:
  

  oke, are there books / tutorials I can do so I can
understand better how smalltalk works. 

I was thinking of making a calculator as my first
project. 

Roelof



kilon alios schreef op 7-11-2014 18:34:
  
  

  
yes, read all the pharo
  documentation, read the entire pharo code,
  understand the entire pharo code, make a few
  hundrend pharo application and boom your are an
  expert :) 
  
  
  Seriously though, do whatever is interesting
to you and ask questions here and in
stackoverflow. You dont need to be expert , just
someone that finds pharo enjoyable and useful. 


  On Fri, Nov 7, 2014 at
    7:17 PM, Roelof Wobben <r.wob...@home.nl>
wrote:

  
Thanks. 
  
  By expert I mean I can write and test most
  of the programms and know very well how
  pharo works. 
  
  Roelof
  
  
  Peter Uhnák schreef op 7-11-2014 18:12:


  

  Well for start there is
this http://pharo.org/documentation
(books Pharo By Example + Deep into
Pharo + Pharo for the Enterprise)
and this http://pharo.gemtalksystems.com/


As far as expertise goes you
  can probably become an expert by
  writing a book about Pharo. :)


Peter
  
  

  
  
On Fri, Nov
  7, 2014 at 6:01 PM, Roelof Wobben
  <r.wob...@home.nl>
  wrote:
  Hello,

Is there a book / tutorial/
challenges that I can use to
become a expert in Pharo ?

Roelof


  


  


  

  

  
  

  
  

  

  


  


  




Re: [Pharo-users] next sttep after the example tutorial

2014-11-07 Thread Roelof Wobben
  
  
Hello, 
  
  Sorry I mean a method. 
  
  Pharo version : 3.0
  OS : Windows 7 Home 
  Image release : 30860
  
  screenshot : http://snag.gy/ISMs7.jpg
  
  Roelof
  
  kilon alios schreef op 7-11-2014 22:08:


  also whats a module ? 
  
On Fri, Nov 7, 2014 at 10:45 PM, Roelof
  Wobben <r.wob...@home.nl>
  wrote:
  

  Thanks, 

I can see a choice finder but as far as I can see I
cannot use it for modules.

Roelof




kilon alios schreef op 7-11-2014 21:21:
  
  

  
start here
  
  
  http://pharo.org/documentation
  
  
  
  here a video tutorial series i created
  
  
  https://www.youtube.com/playlist?list=PLqbtQ7OkSta0ULYAd7Qdxof851ybh-_m_
  
  
  
  you can skip first video "Why Pharo" the rest
is practical tutorials.
  
  
  if you got Pharo 3 or 4 , finder should be in
the tools section of world menu. 


  On Fri, Nov 7, 2014 at
    8:13 PM, Roelof Wobben <r.wob...@home.nl>
wrote:

  
oke, are there books / tutorials I can
  do so I can understand better how
  smalltalk works. 
  
  I was thinking of making a calculator as
  my first project. 
  
  Roelof
  
  
  
  kilon alios schreef op 7-11-2014 18:34:


  

  yes, read all the pharo
documentation, read the entire pharo
code, understand the entire pharo
code, make a few hundrend pharo
application and boom your are an
expert :) 


Seriously though, do whatever
  is interesting to you and ask
  questions here and in
  stackoverflow. You dont need to be
  expert , just someone that finds
  pharo enjoyable and useful. 
  
  
On Fri, Nov
  7, 2014 at 7:17 PM, Roelof Wobben
  <r.wob...@home.nl>
  wrote:
  

  Thanks. 

By expert I mean I can write
and test most of the
programms and know very well
how pharo works. 

Roelof


Peter Uhnák schreef op
7-11-2014 18:12:
  
  

  
Well for
  start there is this http://pharo.org/documentation
  (books Pharo By
  Example + Deep into
   

[Pharo-users] 64 bit version

2014-03-29 Thread Roelof Wobben
Hello,

Is there a 64 bit version of Pharo.
I use a 64 bit version without the 32 bit libraries so no multilib

Roelof




Re: [Pharo-users] 64 bit version

2014-03-29 Thread Roelof Wobben
  
  
Pity. Im using Frugalware which has
  pure 32 or pure 64 bit. 
  Then I need to download the 32 bit and install that one and ty to
  make Pharos work. 
  
  Roelof
  
  
  kilon alios schreef op 29-3-2014 15:16:


  no unfortunately there is no such thing.
Fortunately most open source libraries out there still compile
for 32 bit so you should not experience any major issues. 
  


  On Sat, Mar 29, 2014 at 3:03 PM, Roelof Wobben <r.wob...@home.nl>
  wrote:
  
Hello,

Is there a 64 bit version of Pharo.
I use a 64 bit version without the 32 bit libraries so no
multilib

Roelof


  


  


  




[Pharo-users] example does not work

2014-03-29 Thread Roelof Wobben
Hello,

I have downloaded version2 on Windows 7.
Now Im following chapter 1 and have to type BouncingAtomsMorph new 
openInWorld

and then choose do it.

But instead of seeing bouncing balls I see a message that 
BouncingAtomsMorph unknown variable.


How to make it work ?

Roelof




Re: [Pharo-users] 64 bit version

2014-03-29 Thread Roelof Wobben
kilon alios schreef op 29-3-2014 16:07:
what "pure" means ? as far I know a lib can be either 64 or 32 bit , 
but not both. Yes you will need the 32 bit version to work it with 
pharo, of course you still going to need a FFI like nativeboost or to 
write a VM plugin to get it to work from inside Pharo.




With Pure I mean I do not have a multilib system so I have the 32 and 
the 64 bit libraries.
I will download the 32 bit version and install it so I can install Pharo 
on my linux system.


Roelof




Re: [Pharo-users] example does not work

2014-03-29 Thread Roelof Wobben
p...@highoctane.be schreef op 29-3-2014 16:36:


Get the morph examples in the pharoextras smalltallhub repo.

Some please point the  correct location as I am on a mobe.




Thanks,

Can then also someone tell me how I can load the examples.
I just begin with smalltalk so I have a lot to learn.

Roelof




Re: [Pharo-users] 64 bit version

2014-03-29 Thread Roelof Wobben
Pharo4Stef schreef op 29-3-2014 16:02:

no yet.
Planned for the end of the year.
Stef


Hello,

Is there a 64 bit version of Pharo.
I use a 64 bit version without the 32 bit libraries so no multilib

Roelof







Thanks,
then I have to be patience to run Smalltalk on my 64 bit box.

Roelof




Re: [Pharo-users] example does not work

2014-03-29 Thread Roelof Wobben
  
  
Nicolai Hess schreef op 29-3-2014
  17:44:


  

  2014-03-29 16:36 GMT+01:00 p...@highoctane.be
:

  Get the morph examples in the pharoextras
smalltallhub repo.
  Some please point the  correct location as I
am on a mobe.


  
  http://smalltalkhub.com/#!/~PharoExtras/MorphExamplesAndDemos
  
  Install with:
  
  Gofer new 
  url:'http://smalltalkhub.com/mc/PharoExtras/MorphExamplesAndDemos/main'
      username: ''
      password: '' ;
      package:'MorphExamplesAndDemos';
      load

  

  


Thanks, 

I copied this in a workspace and choose do it,
But nothing seems to be happen.

Roelof

  




[Pharo-users] where can I find the prefences so I make the meta-click workable

2014-03-29 Thread Roelof Wobben
Hello,

According to the Pharo by exampkle tutorial I have to do system > 
preferences to see the menu where I can change the keyboard to make a 
meta-click work,


But there is no preferences choice.
I have looked at system > settings > system but also there no keyboard.

Does anyone know where the menu is hidden or what the meta-click is on 
Windows 7.


I tried already alt-ctrl, shift-alt, shift-ctrl but no luck.

Roelof




[Pharo-users] Cannot find the method and Class window

2014-03-29 Thread Roelof Wobben
Hello,

According to the tutorial im following these schould be in the world menu.
But on 2.0 I cannot find them.

Where can I find them.

At this moment, it's a rocky start of Pharo.

Roelof




Re: [Pharo-users] Cannot find the method and Class window

2014-03-29 Thread Roelof Wobben
  
  
Esteban Lorenzano schreef op 29-3-2014
  19:58:


  
  Hi,
  
  
  you are using incorrect version of pharo.
  to follow the Pharo by Example book you need to download the
right version:
  
  
  http://pharobyexample.org/image/PBE-OneClick-1.1.app.zip
  
  
  otherwise, you will be hit by the large amount of changes. 
  the recommended way to follow the book is to use the version
you have there (which is a bit older) and when you finish, you
can jump to the newest version (it will be pharo 3 in a couple
of weeks). 
  
  
  cheers, 
  Esteban
  
  
  
  


oke, but I think I have the same problem.
Then I cannot find the same things.

Roelof


  




Re: [Pharo-users] Cannot find the method and Class window

2014-03-29 Thread Roelof Wobben
  
  
Esteban Lorenzano schreef op 29-3-2014
  20:27:


  
  
  
On 29 Mar 2014, at 16:23, Roelof Wobben <r.wob...@home.nl>
  wrote:


  
Esteban Lorenzano schreef op
  29-3-2014 19:58:

Hi,
  
  
  you are using incorrect version of pharo.
  to follow the Pharo by Example book you need to
download the right version:
  
  
  http://pharobyexample.org/image/PBE-OneClick-1.1.app.zip
  
  
  otherwise, you will be hit by the large amount of
changes. 
  the recommended way to follow the book is to use the
version you have there (which is a bit older) and when
you finish, you can jump to the newest version (it will
be pharo 3 in a couple of weeks). 
  
  
  cheers, 
  Esteban
  
  
  
  


oke, but I think I have the same problem.
Then I cannot find the same things.
  



what do you mean by “method and class window”? do you look
  for the system browser?


Esteban


  
Roelof


  

  
  


I mean the class browser and the Method finder.
Chapter 1.7 and 1.9 of the book.

Roelof

  




Re: [Pharo-users] example does not work

2014-03-29 Thread Roelof Wobben
  
  
Thanks, I see what I forget.
  
  I have to learn to select it and then do it.
  Maybe for me its better I follow the interactive tutorial first.
  As soon as I figured it out how to make it start on 2.0 
  
  Roelof
  
  
  Nicolai Hess schreef op 29-3-2014 20:52:


  This works form me in Pharo 2:


  
  

2014-03-29 18:25 GMT+01:00 Roelof
  Wobben <r.wob...@home.nl>:
  

  Nicolai Hess schreef op 29-3-2014 17:44:
  
  

  

  2014-03-29 16:36
GMT+01:00 p...@highoctane.be <p...@highoctane.be>:

  Get the morph examples in the
pharoextras smalltallhub repo.
  Some please point the  correct
location as I am on a mobe.


  
  http://smalltalkhub.com/#!/~PharoExtras/MorphExamplesAndDemos
  
  Install with:
  
  Gofer new 
  url:'http://smalltalkhub.com/mc/PharoExtras/MorphExamplesAndDemos/main'
      username: ''
      password: '' ;
      package:'MorphExamplesAndDemos';
      load

  

  


  
  Thanks, 
  
  I copied this in a workspace and choose do it,
  But nothing seems to be happen.
  
  Roelof
  

  


  


  




Re: [Pharo-users] 64 bit version

2014-03-29 Thread Roelof Wobben
  
  
Pharo4Stef schreef op 29-3-2014 21:07:


  
  


  
  
Pity. 
  



You know there is no magic powder. We are already really
  grateful that eliot is pushing the vm work. 
Esteban will help on the 64 bits and clement probably too
  or spur and new bytecodes plus language side optimisations. If
  we could pay 3 full time engineers in the future… but this is
  not the case.

  


I know that and it's not that i think the developer do a bad job.
It's more a expresiion of my feeling.

Roelof

  




Re: [Pharo-users] Cannot find the method and Class window

2014-03-29 Thread Roelof Wobben
  
  
Esteban Lorenzano schreef op 29-3-2014
  21:07:


  
  both are in the world menu (that you get it by right clicking on
  the world canvas). 
  
  
  1) class browser is the first option (“class browser”)
  2) method finder is in “tools”, then “method finder”.
  
  
  cheers, 
  Esteban
  


Thanks, 

I think you mean the system browser. This is the first item on the
list.
And I think method finder is called finder. The first choice of the
tools menu.

Am I right or not ?

Roelof

  




Re: [Pharo-users] example does not work

2014-03-29 Thread Roelof Wobben
  
  
Pharo4Stef schreef op 29-3-2014 21:12:


  
  do not hesistate to ask questions.
  and have fun :)
  stef
  


Thanks, 

I can find the interactive tutorial on the help.
But how can I start it on 2.0

Roelof

  




Re: [Pharo-users] example does not work

2014-03-30 Thread Roelof Wobben
Ben Coman schreef op 30-3-2014 4:59:

Roelof Wobben wrote:

p...@highoctane.be schreef op 29-3-2014 16:36:


Get the morph examples in the pharoextras smalltallhub repo.

Some please point the  correct location as I am on a mobe.




Thanks,

Can then also someone tell me how I can load the examples.
I just begin with smalltalk so I have a lot to learn.

Roelof




The examples are preloaded in the Pharo By Example image
http://pharobyexample.org/image/PBE-OneClick-1.1.app.zip

cheers -ben




I found it. It's very simple.
Just type ProfSteg go in the workarea and choose do it.

Roelof




[Pharo-users] Loop problem on Dr Stef

2014-03-30 Thread Roelof Wobben
Hello,

When I select this part:

1 to: 100 do:
  [:i | Transcript show: i asString; cr ].

And do print it.

I only see 1 where I expected to see all the numbers from 1 till 100.

What went wrong ?

Roelof




Re: [Pharo-users] Loop problem on Dr Stef

2014-03-30 Thread Roelof Wobben
  
  
Thanks, 
  
  I have finished this tutorial and will go on with the first book.
  
  I wonder if there are some kind of challenges so I can pratice
  more with Smalltalk.
  
  Roelof
  
  
  
  Mark Rizun schreef op 30-3-2014 13:48:


  Hello,


You should open Transcript, and than do it, instead of
  print it.


Mark
  
  

2014-03-30 14:45 GMT+03:00 Roelof
  Wobben <r.wob...@home.nl>:
  Hello,

When I select this part:

1 to: 100 do:
  [:i | Transcript show: i asString; cr ].

And do print it.

I only see 1 where I expected to see all the numbers from 1
till 100.

What went wrong ?

Roelof


  


  


  




[Pharo-users] writing my own method problem .

2014-03-30 Thread Roelof Wobben
Hello,

I have to make my own method but when I enter this:

testShout
  self.assert: ( 'Do not panic' shout = "DO NO PANIC")

The editor makes this :

testShout
  self. Nothing more expected ->assert: ( 'Do not panic' shout = "DO NO 
PANIC")


And I do not get a message that shout does not exist.

Roelof




Re: [Pharo-users] writing my own method problem .

2014-03-30 Thread Roelof Wobben
Esteban Lorenzano schreef op 30-3-2014 16:31:

you are using a dot:

self DOT assert: is wrong syntax.

you need just a space:

self assert:

Esteban

On 30 Mar 2014, at 11:26, Roelof Wobben  wrote:


Hello,

I have to make my own method but when I enter this:

testShout
  self.assert: ( 'Do not panic' shout = "DO NO PANIC")

The editor makes this :

testShout
  self. Nothing more expected ->assert: ( 'Do not panic' shout = "DO NO PANIC")

And I do not get a message that shout does not exist.

Roelof







Thanks,
it worked,
Now a problem with the arrow above.
According to the manual I have to type ^).
But then I see the same error message as above.

Roelof



[Pharo-users] still failing test

2014-03-30 Thread Roelof Wobben
Hello,

I trying to make the make you own method work.

So I first I added this :

testShout
  self assert: ('Don''t panic' shout = 'DON""T PANIC!')

After that I added this as described in the book.
shout
  ^  self asUppercase. "!"

But still the testrunner gives that there is a failing test on testShout.

Roelof




Re: [Pharo-users] still failing test

2014-03-30 Thread Roelof Wobben
Ben Coman schreef op 30-3-2014 20:12:

Roelof Wobben wrote:

Hello,

I trying to make the make you own method work.

So I first I added this :

testShout
  self assert: ('Don''t panic' shout = 'DON""T PANIC!')

After that I added this as described in the book.
shout
  ^  self asUppercase. "!"

But still the testrunner gives that there is a failing test on 
testShout.


Roelof




Rather than just feed you a fish, a little teaching how to fish :)
I would highlight and Inspect each side of the equals sign - so you 
can look at each string next to the other.  Two things to think about:

* commas versus periods
* different types of quote marks
I'll follow up with the answer in the next post.
cheers -ben




Oke, I do not see it
I have now this : self assert: ('Dont panic!' shout = 'DONT PANIC!')
and for me it looks the same and still the test is failing.

and the other part has changed to  ^ self asUppercase, '!'

Roelof






Re: [Pharo-users] still failing test - spoiler/answer

2014-03-30 Thread Roelof Wobben
Ben Coman schreef op 31-3-2014 2:44:

Ben Coman wrote:

Roelof Wobben wrote:

Ben Coman schreef op 30-3-2014 20:12:

Roelof Wobben wrote:

Hello,

I trying to make the make you own method work.

So I first I added this :

testShout
  self assert: ('Don''t panic' shout = 'DON""T PANIC!')

After that I added this as described in the book.
shout
  ^  self asUppercase. "!"

But still the testrunner gives that there is a failing test on 
testShout.


Roelof




Rather than just feed you a fish, a little teaching how to fish :)
I would highlight and Inspect each side of the equals sign - so you 
can look at each string next to the other.  Two things to think about:

* commas versus periods
* different types of quote marks
I'll follow up with the answer in the next post.
cheers -ben




Oke, I do not see it
I have now this : self assert: ('Dont panic!' shout = 'DONT PANIC!')
and for me it looks the same and still the test is failing.

and the other part has changed to  ^ self asUppercase, '!'

Roelof

This must be a little frustrating for you :)  but like a lot of 
things its a matter a "getting your eye in".
I hope you persist. You are almost there.  You've made an additional 
change to the left hand side. I think if you again Inspect both sides 
of equals sign and compare the results it should become clear.


Now as an additional learning task, the other way to "fish" is to use 
the debugger.  Highlight...

   'Dont panic!' shout
and from the context menu choose to Debug. Then step Into the #shout 
method.  Once the debugger has moved into the #shout method, 
highlight and Inspect the following...

   self
   self asUppercase
   self asUppercase, '!'

The precise answer is my next post.
cheers -ben


You added an exclamation mark to the left hand side of the comparison 
that was not there before, so presuably the left hand side ends up as 
'DONT PANIC!!' since the #shout method also appends an exclamation 
mark using the comma operator.

cheers -ben




Thanks for learning me how to fish.
You are right. I learn more this way then simply say where I went wrong.

Roelof




[Pharo-users] Pharo 1

2014-03-31 Thread Roelof Wobben
Hello,

Im busy with book 1 and I work with version 1
Now this morning I did some changes and save it under a name.

But when I just start up Pharo I see the pharo1.img again without my 
changes.
And I also do not see a menu where I can choose which image I want to 
use as version 2 of Pharo does.


How can I proceed where I quit with the right image.

Roelof




Re: [Pharo-users] Pharo 1

2014-03-31 Thread Roelof Wobben
Stephan Eggermont schreef op 31-3-2014 14:37:

Hello Roelof,

That is a disadvantage of having a one-click that opens everywhere.
It contains a script telling the executable which image to open.
You should be able to find your image, and drag it onto the vm
to open. If you just gave it a different name, it is in
Contents\Resources
You might want to change your pharo.ini to point to the right image.

Experienced smalltalkers don’t worry too much about saving (and
disposing of) images. Source code is versioned using Monticello
(a few chapters away) and we use continuous integration to build
new images whenever source code has changed, effectively
giving us a new image to work with each morning.

Stephan



Thanks,

Next problem.
According to the manual I have to make a new "script"  on the 
initializing protocol.

So I did this :

initialize
| sampleCell width  height n |
super initialize.
n:=self CellsPerSide.
sampleCell := LOCell new.
width := sampleCell width.
height := sampleCell height.
self bounds: (5*5 extent: ((width * n ) @(height * n)) + ( 2  * 
self BorderWidth)).

cells:= Matrix new: n tabulate: [:i :j| self newCellAt: i at: j]

CellsPerSide
 "The number of cells along each side of the game"
  ^ 10

but Pharo 1 makes this :

initialize
| sampleCell width  height n |
super initialize.
n:=self CellsPerSide.
sampleCell := LOCell new.
width := sampleCell width.
height := sampleCell height.
self bounds: (5*5 extent: ((width * n ) @(height * n)) + ( 2  * 
self BorderWidth)).

cells:= Matrix new: n tabulate: [:i :j| self newCellAt: i at: j]

CellsPerSide
 "The number of cells along each side of the game"
  Nothing more expected ->^ 10

What did I do wring this time ?

Roelof




Re: [Pharo-users] Pharo 1

2014-03-31 Thread Roelof Wobben
Stephan Eggermont schreef op 31-3-2014 15:35:

Two things come to mind:
- method names start with lowercase
   CellsPerSide


you are right, I mistyped that one. I wil change it

- did you make cellsPerSide into a separate method?


You mean choose all and then type in the text.
nope, if that is the meaning then I misread the manual.

How do I make it part of the initialized protocol then,

Roelof





Re: [Pharo-users] Pharo 1

2014-03-31 Thread Roelof Wobben
Camille Teruel schreef op 31-3-2014 15:49:

On 31 mars 2014, at 15:43, Roelof Wobben  wrote:


Stephan Eggermont schreef op 31-3-2014 15:35:

Two things come to mind:
- method names start with lowercase
   CellsPerSide

you are right, I mistyped that one. I wil change it

- did you make cellsPerSide into a separate method?

You mean choose all and then type in the text.
nope, if that is the meaning then I misread the manual.

How do I make it part of the initialized protocol then,

When you write a method in the editor pane and save it, the protocol of the 
method is the one currently selected in the protocol pane (or 'as yet 
unclassified' is there is none selected).
In case of mistake, you can always reorganize your methods amongst the 
different protocols.


Roelof








Thanks all.
Now trying to solve the last typos and hopefully the games works.

Roelof




[Pharo-users] challenges

2014-03-31 Thread Roelof Wobben
Hello,

I almost get book 1 ready.

Now I wonder if there are challenges so I can practise more in Smaltalk.
I know I learn the best by doing things and not just read about it.

I like the most if the challenges can start at simple and get more complex .

As example what I mean is 99 prolog/python problems

Roelof




Re: [Pharo-users] challenges

2014-03-31 Thread Roelof Wobben
Ben Coman schreef op 31-3-2014 18:30:

Roelof Wobben wrote:

Hello,

I almost get book 1 ready.

Now I wonder if there are challenges so I can practise more in Smaltalk.
I know I learn the best by doing things and not just read about it.

I like the most if the challenges can start at simple and get more 
complex .


As example what I mean is 99 prolog/python problems

Roelof



I'm not aware of anything similar.  It does look interesting and 
probably something that should be looked into further.


Alternatively, sorry its not a challenge, but as a next step I highly 
recommend LaserGame tutorial

http://squeak.preeminent.org/tut2007/html/

for which you'll should Squeak 3.9 (a predecessor to Pharo)
http://ftp.squeak.org/3.9/

The great thing with this is it leads you through a uniquely Smalltalk 
approach to developing that is colloquially known as "developing from 
within the debugger" and it shows how to use Smalltalk facilities to 
refactor code as the design evolves. From the tutorial "Every step of 
the process is described in detail. Even when I made mistakes. The 
idea here is to show how natural it is to iterate over design and 
implementation and the confidence that builds with test driven 
development."


This tutorial is one of the things that really hooked me into Smalltalk.

cheers -ben






Thanks, this looks very interresting. And I think at first glance it can 
be done on Pharo also.


If I have enough knowlegde Im thinking about tryimg to make a sort of 
repo-browser for the linux distro I work on.

But that will take a long time before I am at that point.

Roelof





Re: [Pharo-users] Pharo 1

2014-04-01 Thread Roelof Wobben
Pharo4Stef schreef op 1-4-2014 8:22:

On which os are you?
The new image on mac should be under the ressources folder and the script just 
opens the default one.





Im on Windows 7 at the moment.

Roelof




[Pharo-users] lasergame question

2014-04-01 Thread Roelof Wobben
Hello,

Im on this page now: http://squeak.preeminent.org/tut2007/html/017.html

I do not understand one thing.

Where do I put the initialize "script"

When I put it on the initializeActiveSegments then initialize get not found.

Or must I make a seperate protocol named ActiveSegments for it.
If I made a initialize on the initiialize protocol. ActiveSegments stays 
nill.


Roelof




Re: [Pharo-users] lasergame question

2014-04-01 Thread Roelof Wobben
Camille Teruel schreef op 1-4-2014 15:08:

On 1 avr. 2014, at 14:52, Roelof Wobben  wrote:


Hello,

Hello,


Im on this page now: http://squeak.preeminent.org/tut2007/html/017.html

I do not understand one thing.

Where do I put the initialize "script"

#initialize is not a script, it's a method. When an object is instantiated (for 
ex with: MyObject new) #initialize is automatically sent to it.
This is the place to put your newly created object in a correct initial state.
In your class, you just define a protocol named for example "initialization" 
where you put all the initialization-related methods.
Note that protocols have no meaning, i.e. they don't change how your objects 
behave, they're just here to help you classify
the methods of a class by concerns.
So the tutorial tell you to create two methods: #initialize that is 
automatically called after an object has been instantiated and 
#initializeActiveSegments where you
put some other initialization logic, that's all.


When I put it on the initializeActiveSegments then initialize get not found.

Sorry, I don't understand.


Or must I make a seperate protocol named ActiveSegments for it.

No use the same protocol "initialization" or "initialize-release" or whatever.



Oke,

I changed it so I have this :

Laser-Game-Model
with as classes:
  - BlankCell
  - Grid
  - MirrorCell
  -TargetCell


BlankCell has the following protocols:
- initializing-release
- testing

Initializing - release contains the following  methods:
 - initialize
 - initializeActiveSegments

testing contains the following methods:
isOn
isOff

but when I run the test-runner I see this : MessageNotUnderstood : 
BlankCell >> activeSegments.


Roelof











Re: [Pharo-users] lasergame question

2014-04-01 Thread Roelof Wobben
  
  
Camille Teruel schreef op 1-4-2014
  16:34:


  
  
  
On 1 avr. 2014, at 16:21, Roelof Wobben <r.wob...@home.nl>
  wrote:


  Camille Teruel schreef op 1-4-2014 15:08:
On 1 avr. 2014, at 14:52, Roelof
  Wobben <r.wob...@home.nl>
  wrote:
  
  Hello,
  
  Hello,
  
  Im on this page now: http://squeak.preeminent.org/tut2007/html/017.html

I do not understand one thing.

Where do I put the initialize "script"
  
  #initialize is not a script, it's a method. When an object
  is instantiated (for ex with: MyObject new) #initialize is
  automatically sent to it.
  This is the place to put your newly created object in a
  correct initial state.
  In your class, you just define a protocol named for
  example "initialization" where you put all the
  initialization-related methods.
  Note that protocols have no meaning, i.e. they don't
  change how your objects behave, they're just here to help
  you classify
  the methods of a class by concerns.
  So the tutorial tell you to create two methods:
  #initialize that is automatically called after an object
  has been instantiated and #initializeActiveSegments where
  you
  put some other initialization logic, that's all.
  
  When I put it on the
initializeActiveSegments then initialize get not found.
  
  Sorry, I don't understand.
  
  Or must I make a seperate protocol
named ActiveSegments for it.
  
  No use the same protocol "initialization" or
  "initialize-release" or whatever.
  


Oke,

I changed it so I have this :

Laser-Game-Model
with as classes:
 - BlankCell
 - Grid
 - MirrorCell
 -TargetCell


BlankCell has the following protocols:
- initializing-release
- testing

Initializing - release contains the following  methods:
- initialize
- initializeActiveSegments

testing contains the following methods:
isOn
isOff

but when I run the test-runner I see this :
MessageNotUnderstood : BlankCell >> activeSegments.
  



This error means "instances of BlankCell does not
  understand the message #activeSegments" that's all, this part
  of your program is not implemented yet. 

  


Im not agree with you according to the tutorial  on this page :
http://squeak.preeminent.org/tut2007/html/019.html there is a error
with isOn and isOff. #activeSegments schould be implemented by now.


Roelof

  




Re: [Pharo-users] lasergame question

2014-04-01 Thread Roelof Wobben
  
  
Nicolai Hess schreef op 1-4-2014 16:44:


  

  2014-04-01 16:21 GMT+02:00 Roelof
Wobben <r.wob...@home.nl>:

  Camille Teruel schreef op 1-4-2014 15:08:
  

  
On 1 avr. 2014, at 14:52, Roelof Wobben <r.wob...@home.nl>
wrote:


  Hello,

Hello,


  Im on this page now: http://squeak.preeminent.org/tut2007/html/017.html
  
  I do not understand one thing.
  
  Where do I put the initialize "script"

#initialize is not a script, it's a method. When an
object is instantiated (for ex with: MyObject new)
#initialize is automatically sent to it.
This is the place to put your newly created object
in a correct initial state.
In your class, you just define a protocol named for
example "initialization" where you put all the
initialization-related methods.
Note that protocols have no meaning, i.e. they don't
change how your objects behave, they're just here to
help you classify
the methods of a class by concerns.
So the tutorial tell you to create two methods:
#initialize that is automatically called after an
object has been instantiated and
#initializeActiveSegments where you
put some other initialization logic, that's all.


  When I put it on the initializeActiveSegments then
  initialize get not found.

Sorry, I don't understand.


  Or must I make a seperate protocol named
  ActiveSegments for it.

No use the same protocol "initialization" or
"initialize-release" or whatever.

  
  

  
  Oke,
  
  I changed it so I have this :
  
  Laser-Game-Model
  with as classes:
    - BlankCell
    - Grid
    - MirrorCell
    -TargetCell
  
  
  BlankCell has the following protocols:
  - initializing-release
  - testing
  
  Initializing - release contains the following  methods:
   - initialize
   - initializeActiveSegments
  
  testing contains the following methods:
  isOn
  isOff
  
  but when I run the test-runner I see this :
  MessageNotUnderstood : BlankCell >> activeSegments.
  
  Roelof
  
  
  
  



Then you missed the last step on http://squeak.preeminent.org/tut2007/html/016.html
  Select "create instance var accessors" from the second
  popup menu.  


  

  
  

  



I also did.
See this : 

Object subclass: #BlankCell
    instanceVariableNames: 'activeSegments'
    classVariableNames: ''
    category: 'Laser-Game-Model'

Roelof

  




Re: [Pharo-users] lasergame question

2014-04-01 Thread Roelof Wobben
  
  
Ben Coman schreef op 1-4-2014 17:13:


  
  Camille Teruel wrote:
  



  On 1 avr. 2014, at 16:50, Roelof Wobben <r.wob...@home.nl>
wrote:
  
  


  Nicolai Hess schreef op
1-4-2014 16:44:
  
  

  
2014-04-01 16:21 GMT+02:00
  Roelof Wobben <r.wob...@home.nl>:
  
Camille Teruel schreef op 1-4-2014 15:08:

  

  On 1 avr. 2014, at 14:52, Roelof Wobben
  <r.wob...@home.nl>
  wrote:
  
  
Hello,
  
  Hello,
  
  
Im on this page now: http://squeak.preeminent.org/tut2007/html/017.html

I do not understand one thing.

Where do I put the initialize "script"
  
  #initialize is not a script, it's a
  method. When an object is
  instantiated (for ex with: MyObject new)
  #initialize is automatically
  sent to it.
  This is the place to put your newly
  created object in a correct initial
  state.
  In your class, you just define a protocol
  named for example
  "initialization" where you put all the
  initialization-related methods.
  Note that protocols have no meaning, i.e.
  they don't change how your
  objects behave, they're just here to help
  you classify
  the methods of a class by concerns.
  So the tutorial tell you to create two
  methods: #initialize that is
  automatically called after an object has
  been instantiated and
  #initializeActiveSegments where you
  put some other initialization logic,
  that's all.
  
  
When I put it on the
initializeActiveSegments then initialize
get not
found.
  
  Sorry, I don't understand.
  
  
Or must I make a seperate protocol named
ActiveSegments for it.
  
  No use the same protocol "initialization"
  or "initialize-release" or
  whatever.
  


  

Oke,

I changed it so I have this :

Laser-Game-Model
with as classes:
  - BlankCell
  - Grid
  - MirrorCell
  -TargetCell


BlankCell has the following protocols:
- initializing-release
- testing

Initializing - release contains the following
 methods:
 - initialize
 - initializeActiveSegments

testing contains the following methods:
isOn
isOff

but when I run the test-runner I see this :
MessageNotUnderstood :
BlankCell

[Pharo-users] create instance var accesors from menu (Pharo 3.0)

2014-04-01 Thread Roelof Wobben
Hello,

On squeeze 3.9 you can make them with a menu.

Is there a simular way I can do the same in Pharo 3.0 ?

Roelof



Re: [Pharo-users] lasergame question

2014-04-01 Thread Roelof Wobben
Mark Rizun schreef op 1-4-2014 18:12:

Hello, Roelof!

Stef is partly right. I had implemented Laser Game but on Squeak, not 
Pharo.

If you have any questions, ask me and I will try to help you.

Mark


First question :

I had a working test. I saved it to my hard disk.
Closed Pharo . re open it and the test is failing.

Roelof




[Pharo-users] lasergame problem with Blankcell

2014-04-02 Thread Roelof Wobben
Hello,

On the first part I have to make a class named BlankCell which is a 
subclass of TestCase.

So far no problem.

But when you are on the MirrorCell part BlankCell must be a subclass of 
Cell.

But then the tests will fail because should:  cannot be found.

The manual says nothing about that the new class Cell must be a part of 
TestCase.


How to solve this ?

Roelof




Re: [Pharo-users] lasergame problem with Blankcell

2014-04-02 Thread Roelof Wobben
  
  
Camille Teruel schreef op 2-4-2014
  13:40:


  
  
  
On 2 avr. 2014, at 13:21, Roelof Wobben <r.wob...@home.nl>
  wrote:

Hello,
  
  On the first part I have to make a class named BlankCell which
  is a subclass of TestCase.
  So far no problem.
But when you are on the MirrorCell part
  BlankCell must be a subclass of Cell.
  
  
But then the tests will fail because
  should:  cannot be found.




  BlankCell is a class of your domain not a test case. I
guess the tutorial ask you to create a BlankCellTests test
case.

#should is a method of TestCase. Your tests are methods whose
names begin with 'test' in subclasses of TestCase.

  


You are right. I m a little bit confused now. 

Im now here and on the first test I see a message that it fails on
testCellonState. Message not understood should: 

Roelof

  




Re: [Pharo-users] lasergame problem with Blankcell

2014-04-02 Thread Roelof Wobben
  
  
Mark Rizun schreef op 2-4-2014 13:51:


  Hi,


You probably misunderstood the task. 





  
On
  the first part I have to make a class named BlankCell
  which is a subclass of TestCase.

 
You had to create the class BlankCellTestCase (not
  BlankCell) which is a subclass of TestCase.
BlankCell and BlankCellTestCase are two different
  classes.
-BlankCell is a class that represents a model of an
  empty cell (its size, segments etc.)
-BlankCellTestCase is basically a class that helps you
  to control (and test) methods that you have on BlankCell
  class.


But
  when you are on the MirrorCell part BlankCell must be a
  subclass of Cell.

 
  

  


You are right here. 

  

  
Cell class is an abstract, which is a superclass for
  following classes: BlankCell, MirrorCell, TargetCell. 
It provides some basic behavior or properties for
  BlankCell, MirrorCell, TargetCell, which all of them have
  in common


But
  then the tests will fail because should:  cannot be found.

 

  

  


I have now these classes : 

TestCase subclass: #BlankCellTestCase
    instanceVariableNames: ''
    classVariableNames: ''
    poolDictionaries: ''
    category: 'Laser-Game-Tests'

Object subclass: #Cell
    instanceVariableNames: 'activateSegments exitSides'
    classVariableNames: ''
    poolDictionaries: ''
    category: 'Laser-Game-Model'

Cell subclass: #BlankCell
    instanceVariableNames: ''
    classVariableNames: ''
    poolDictionaries: ''
    category: 'Laser-Game-Model'

And only on this method the test fail on should: 

testCellOnState
  | cell |
  cell := BlankCell new.
  cell should: [ cell isOff ].
  cell shouldnt:  [ cell isOn ].


Roelof

  




Re: [Pharo-users] lasergame problem with Blankcell

2014-04-02 Thread Roelof Wobben
  
  
Mark Rizun schreef op 2-4-2014 14:22:


  

  

  And only on this
method the test fail on should: 

testCellOnState
  | cell |
  cell := BlankCell new.
  cell should: [ cell isOff ].
  cell shouldnt:  [ cell isOn ].

Yes it does, inasmuch on the bottom of this page ( http://squeak.preeminent.org/tut2007/html/017.html
  )
both methods return false. I think later the
  implementation of this two methods will be changed so
  don't worry.
  
  

  


Correct but on this page :
http://squeak.preeminent.org/tut2007/html/025.html
some methods are moved to another class. 

and then on this page :
http://squeak.preeminent.org/tut2007/html/026.html
The first step is to run Test runner and then it fails and only on
this test.

Roelof

  




Re: [Pharo-users] lasergame problem with Blankcell

2014-04-02 Thread Roelof Wobben
Mark Rizun schreef op 2-4-2014 14:58:

Does this test fails to assert something or it throws you some error?



Like I said earlier it fails with this message:

MessageNotUnderstood: BlankCell >> should.


Which I find wierd because I use should: also on the other test methods 
off BlankCell and not getting this error.


Roelof




Re: [Pharo-users] lasergame problem with Blankcell

2014-04-02 Thread Roelof Wobben
Mark Rizun schreef op 2-4-2014 15:07:

Could you give me the code of test that fails?




I can but I did already.

The code is :

testCellOnState
  | cell |
  cell := BlankCell new.
  cell should: [ cell isOff ].
  cell shouldnt:  [ cell isOn ].

And this is a code which succeeced:

estCellExitSides
 | cell exit |
cell := BlankCell new.
exit := cell exitSideFor: #north.
self should: [ exit = #south ].
exit := cell exitSideFor: #east.
self should: [ exit = #west ].
exit := cell exitSideFor: #south.
self should: [ exit = #north ].
exit := cell exitSideFor: #west.
self should: [ exit = #east ].

Roelof





Re: [Pharo-users] lasergame problem with Blankcell

2014-04-02 Thread Roelof Wobben
  
  
Mark Rizun schreef op 2-4-2014 15:16:


  The mistake is simple. You have to write as follows
(just replace cell for self in two lines before should and
shouldnt):


testCellOnState
   
    | cell |
   
    cell := BlankCell new.
   
    self should: [ cell isOff ].
   
    self shouldnt:  [ cell isOn ].



  
  
  


You are abolute right.
Wierd that earlier test succceed where this error also is made.

Roelof

  




[Pharo-users] leansleft problem

2014-04-02 Thread Roelof Wobben
If I understood everything well on page 26 my Cell initialize must look 
like this:


initialize
super initialize.
self initializeActiveSegments.
self initializeExitSides.
self leanleft.

The Blankcell initialize must look like this :

initialize
super initialize.
self initializeExitSides.

And the MirrorCell initialize must look like this :

initialize
super initialize
self leansLeft: true

Why then I see a message that leanleft is not Understood in Blankcell.
or do I misunderstood that page. I find it a very confusing page.

Roelof



Re: [Pharo-users] leansleft problem

2014-04-02 Thread Roelof Wobben
  
  
Nicolai Hess schreef op 2-4-2014 17:05:


  

  2014-04-02 16:40 GMT+02:00 Roelof
Wobben <r.wob...@home.nl>:

  If I understood everything well on page 26 my Cell
  initialize must look like this:
  
  initialize
      super initialize.
      self initializeActiveSegments.
      self initializeExitSides.
      self leanleft.
  
  The Blankcell initialize must look like this :
  
  initialize
      super initialize.
      self initializeExitSides.
  
  And the MirrorCell initialize must look like this :
  
  initialize
      super initialize
      self leansLeft: true
  
  Why then I see a message that leanleft is not Understood
  in Blankcell.
  or do I misunderstood that page. I find it a very
  confusing page.
  
  Roelof
  

  
  
  

No,
  Cell initialize is

super initialize.
  self initializeActiveSegments.
  


  MirrorCell initialize is
  super initialize.
  self initializeExitSides.
  self leanLeft
  



  


Thanks

Roelof

  




[Pharo-users] free learnig book

2014-04-06 Thread Roelof Wobben
Hello,

I wonder if there is a free book with a lot of exercises so I can 
practice and learn a lot about Smalltalk.


Roelof




Re: [Pharo-users] free learnig book

2014-04-07 Thread Roelof Wobben
  
  
Jean Baptiste Arnaud schreef op
  7-4-2014 8:58:


  
  Steph keeps some treasure:
  http://stephane.ducasse.free.fr/FreeBooks.html
  
  
  

  On 07 Apr 2014, at 08:43, Roelof Wobben <r.wob...@home.nl>
wrote:
  
  Hello,

I wonder if there is a free book with a lot of exercises so
I can practice and learn a lot about Smalltalk.

Roelof


  


  


Thanks,

I think I wil settle for this book
(http://stephane.ducasse.free.fr/FreeBooks/InsideST/InsideSmalltalk.pdf)


Roelof

  




[Pharo-users] best solution to store data

2014-09-01 Thread Roelof Wobben
Hello,

I want to try to make a financial app for a organisation.

There are some 50 customers so also 50 invoices a year.
Then the payments . Also 50 a year.

Cash and bank accounts . Every month some 10 - 20 things.

So on my disk on the programm I now use it costs me some 30 -  50 Kb a 
year.


What are my options for storage of those data.

I could use a database , but I wonder if there are more and better options.

Roelof



Re: [Pharo-users] best solution to store data

2014-09-02 Thread Roelof Wobben
  
  
Thanks. 
  
  Could Magna also be a good solution ?
  
  Roelof
  
  
  
  
  François Stephany schreef op 2-9-2014 9:11:


  
If you don't want a separate DB, object serialization with
  Fuel is an option. It's very easy to serialize a graph of
  objects to disk.

You can also have a look at SandstoneDB, it's pretty small
  and some people use it.
  

Cheers,

Francois

  
  

On Tue, Sep 2, 2014 at 8:17 AM, Roelof
  Wobben <r.wob...@home.nl>
  wrote:
  Hello,

I want to try to make a financial app for a organisation.

There are some 50 customers so also 50 invoices a year.
Then the payments . Also 50 a year.

Cash and bank accounts . Every month some 10 - 20 things.

So on my disk on the programm I now use it costs me some 30
-  50 Kb a year.

What are my options for storage of those data.

I could use a database , but I wonder if there are more and
better options.

Roelof

  


  


  




Re: [Pharo-users] best solution to store data

2014-09-02 Thread Roelof Wobben
  
  
Thanks all. 
  
  Is there a good tutorial how I can work with Fuel ?
  
  Roelof
  
  
  
  stepharo schreef op 2-9-2014 12:31:


  
  
  On 2/9/14 09:11, François Stephany
wrote:
  
  

  If you don't want a separate DB, object serialization
with Fuel is an option. It's very easy to serialize a graph
of objects to disk.
  
  You can also have a look at SandstoneDB, it's pretty
small and some people use it.
  

  
  pay attention that images can get corrupted so I would in addition
  use a file based approach (STON or whatever).
  

   
  
  Cheers,
  
  Francois
  


  
  On Tue, Sep 2, 2014 at 8:17 AM,
        Roelof Wobben <r.wob...@home.nl>
wrote:
Hello,
  
  I want to try to make a financial app for a organisation.
  
  There are some 50 customers so also 50 invoices a year.
  Then the payments . Also 50 a year.
  
  Cash and bank accounts . Every month some 10 - 20 things.
  
  So on my disk on the programm I now use it costs me some
  30 -  50 Kb a year.
  
  What are my options for storage of those data.
  
  I could use a database , but I wonder if there are more
  and better options.
  
  Roelof
  

  
  

  
  


  




Re: [Pharo-users] best solution to store data

2014-09-02 Thread Roelof Wobben
  
  
Hello Estaban. 
  
  Do you have a tutorial or a example how I can store my data in
  objects.
  
  Roelof
  
  
  Esteban Lorenzano schreef op 2-9-2014 15:23:


  
  problem with relational databases is that they do not match really
  well with object models. 
  nowadays you have a lot of cool solutions that allow you to
avoid them (several document-oriented databases,
object-oriented, etc.)
  
  
  so unless you are really constrained for some reason (like
imposition of customers), or you have real use cases (like doing
complex tabular projections),  I would always recommend to take
another approach than relational. 
  
  
  stay in objects as much as you can! 
  
  
  Esteban
  

  On 02 Sep 2014, at 15:18, kilon alios 
wrote:
  
  
ah yes thats it , thanks Pierce . It may come
  handy for my project Ephestos, though I prefer to keep
  things inside the Pharo image personally. 

  
  
On Tue, Sep 2, 2014 at 4:04 PM, Pierce Ng 
wrote:

  On Tue, Sep 02, 2014 at 03:55:50PM
+0300, kilon alios wrote:
> When I was coding in Python for small local
databases SQlite was
> recommended , I only have played briefly with
it but it looked to me fairly
> easy to use and with a very good performance.
But I dont know how well it
> works in Pharo, so maybe someone can jump in
and tells us about it .

  
  Give it a spin:
  
    http://www.samadhiweb.com/tags/sqlite
    http://ss3.gemtalksystems.com/ss/NBSQLite3/
  
  Pierce
  
  

  
  

  


  


  




Re: [Pharo-users] best solution to store data

2014-09-02 Thread Roelof Wobben
  
  
Hello, 
  
  I think I wil go for a Magma or a xml approach.
  
  Anyone who knows tutorials for both.
  
  Roelof
  
  
  
  Esteban Lorenzano schreef op 2-9-2014 16:50:


  
  there is no such thing as ACID or transactions in MongoDB, and
  therefore also not in Voyage. 
  instead, for MongoDB each commit is atomic. It happens or it
doesn’t :)
  
  
  Esteban 
  

  
On 02 Sep 2014, at 16:46, Pablo R. Digonzelli <pdigonze...@gmail.com>
  wrote:


  
What about transactions and ACID things with
  voyager and Mongo?






  
Ing. Pablo Digonzelli
Software
  Solutions
IP-Solutiones SRL
  Metrotec SRL
25 de Mayo 521
Email: pdigonze...@softsargentina.com
pdigonze...@gmail.com
Cel:
  5493815982714
  


De: "Tim
  Mackinnon" <tim@testit.works>
  Para: "Any question about pharo is welcome"
  <pharo-users@lists.pharo.org>
  Enviados: Martes, 2 de Septiembre 2014 6:33:26
  Asunto: Re: [Pharo-users] best solution to
  store data
  
  
  Esteban talked about Voyage at ESUG, its on the list
  of talks here: 
  http://goo.gl/E1VF53
  
  
  You can of course scale up to Gemstone (or indeed
start with that as well if you need something more
commercial and supported - there is a Gemstone talk
in that link as well).
  
  
  Tim
  

      On 2 Sep 2014, at 07:17, Roelof Wobben <r.wob...@home.nl>
wrote:
  
  Hello,


I want to try to make a financial app for a
organisation.


There are some 50 customers so also 50 invoices
a year.
Then the payments . Also 50 a year.


Cash and bank accounts . Every month some 10 -
20 things.


So on my disk on the programm I now use it costs
me some 30 -  50 Kb a year.


What are my options for storage of those data.


I could use a database , but I wonder if there
are more and better options.


Roelof


  


  



  

  
  

  


  




Re: [Pharo-users] best solution to store data

2014-09-02 Thread Roelof Wobben
I know what I want.
The steps that I have to take.

1) Users and user management.

User has username and password.

2) entering and editing plans.

Plans has sort and amount.

3) entering and editing way of payment.

this has name and sort payment

4) Entering and editing customers.

Customers has :

name, adress, city , plan, way of payment.

5) Entering financial accounts.

name, number and so on.

6) Making invoices.

Client data like name ,adress, city , amount to be payed. (depends on 
plan), issued data, date before the invoice must be payed, date where 
the invoice is payed.


6) Making bank and cash accounts.

date, amount credit, amount debit, description, financial account

Roelof






Alain Rastoul schreef op 2-9-2014 22:23:

Hi Roelof,

This is a very broad question with a lot of options, there is no short 
answer.


If I had to choose a relational database approach from the beginning,
I would choose Sqlite, it's a very nice db, small, fast, works very 
well with Pharo (I used it some time ago with FFI, didn't know about 
native boost mapping, it's cool),

can be used with other guis and tools and, should my data or requirements
grow unexpectedly, I could move to Postgresql or some other bigger db 
without too much stress.


For an object approach , I would still choose a relational db for 
storage (same as previously) with  an object relational mapping 
framework like Glorp on top of it,
not an object system for storage (magma or gemstone - I'm not saying 
that they are bad!).


Beware that relational system (like object systems) will require some 
specific skills
at some point (I like relational systems for myself, but very often 
see they are widely misunderstood, even by those who develop with).


In any case, if I were you, I would first choose to defer my choice :) 
until I have a more detailed idea of what I want/have to do, and I 
would start very small with a file based approach (STON) and a Data 
Access Layer of my own on top of it, so that I could adapt it to my 
future requirements or choices (relational, object or nosql database 
like mongo).
I would even develop this DAL later and start with a single document 
approach (a simple read/write of the whole stuff with STON).


The most important is : don't get lost in underlying technical choices 
from the beginning (plus it's bad for health), make choices you can 
change. And stay focused on your goal : your application.


my 2c


Regards,
Alain








Re: [Pharo-users] how to get out of this mess

2019-03-25 Thread Roelof Wobben
  
  
and Ricard , I forgot to thank you for
  the explantion and the code. 
  
  Roelof
  
  
  
  Op 25-3-2019 om 08:40 schreef Roelof Wobben:


  
  Sorry. 

Is this more the OOP way. 

https://github.com/RoelofWobben/Tournament-/tree/master/Exercism-Tournament

Roelof



Op 25-3-2019 om 07:39 schreef Richard O'Keefe:
  
  


  
In OOP, you should
  not be thinking in terms of "updating a record".
You should *ask*
  an object to update *itself*.

    [aStream atEnd] whileFalse: [
      |fields team1 team2 outcome|
      fields := aStream nextLine subStrings: ';'.
      team1 := self teamNamed: (fields at: 1).
      team2 := self teamNamed: (fields at: 2).   
      outcome := fields at: 3. 
      outcome = 'win'  ifTrue: [team1 won.  team2 lost].
      outcome = 'draw' ifTrue: [team1 tied. team2 tied].
      outcome = 'loss' ifTrue: [team1 lost. team2 won
  ]].


(Extracted from a
  working solution.)


  


    
      On Mon, 25 Mar 2019 at
19:29, Roelof Wobben <r.wob...@home.nl> wrote:
  
  

  Thanks
all 

@Richard  

I did tried that way in the solution I put on the net. 
But I get stuck at the point that if I update a record
in the Team Class the collection at the Tournament class
was not updated.

But right now , I try a new way to make it work that a
new team is made and returned or a team is returned if
that team is known.

Roelof



Op 25-3-2019 om 06:18 schreef Richard O'Keefe:
  
  

  This is a
simple programming-contest sort of exercise.
  You "need"
only two classes.
  + a Team
    - knows
its name (a String of at most 30 characters)
      * This
should be passed when the Team is created;
    the
rest of the program should NOT call (Team new)
    and
should NEVER see an un#initialize-d Team instance.
  
    - knows the number of
matches it has won, drawn, and lost
      (non-negative Integers,
initially zero).
    - can report what it knows
    - can report the total match
count and point score
  
    - can be told that it has
won, drawn, or lost another match.
    
  
  + a Tournament
    - has a collection of Teams
that it knows by name
  
  
    (a Dictionary)
  - and an sequence,
  initially undefined.
  - can read a set of match
  triples from a stream,
    forwarding the
  information about wins, draws, and losses
    to Team instances, which
  are created when a new name is found,
  - can convert the values
  of the teams collection to a
    sorted collection that
  is sorted by a somewhat vague order,
    I chose
  - descending on point
  score, then
  - descending on wins,
  then
  - ascending  on
  losses, then
  - ascending  on name.
  - can write the sorted
  teams to a stream in tabular form.
  ! Has a class method that
  does
    (self new) read:
  <>; sort; write:
  <>


Frankly, formatting the
  output was the hardest part.

  

Re: [Pharo-users] how to get out of this mess

2019-03-25 Thread Roelof Wobben
  
  
I try to understand the way the streams
  works here.
  
  but as far as I can see the collection is a array.
  
  
  I tried to convert it with  aCollection readStream. 
  
  But then I see a error on the nextline 
  
  Anyone a hint  how I can make this work.
  
  Roelof
  
  
  
  Op 25-3-2019 om 08:40 schreef Roelof Wobben:


  
  Sorry. 

Is this more the OOP way. 

https://github.com/RoelofWobben/Tournament-/tree/master/Exercism-Tournament

Roelof



Op 25-3-2019 om 07:39 schreef Richard O'Keefe:
  
  


  
In OOP, you should
  not be thinking in terms of "updating a record".
You should *ask*
  an object to update *itself*.

    [aStream atEnd] whileFalse: [
      |fields team1 team2 outcome|
      fields := aStream nextLine subStrings: ';'.
      team1 := self teamNamed: (fields at: 1).
      team2 := self teamNamed: (fields at: 2).   
      outcome := fields at: 3. 
      outcome = 'win'  ifTrue: [team1 won.  team2 lost].
      outcome = 'draw' ifTrue: [team1 tied. team2 tied].
      outcome = 'loss' ifTrue: [team1 lost. team2 won
  ]].


(Extracted from a
  working solution.)


  


    
      On Mon, 25 Mar 2019 at
19:29, Roelof Wobben <r.wob...@home.nl> wrote:
  
  

  Thanks
all 

@Richard  

I did tried that way in the solution I put on the net. 
But I get stuck at the point that if I update a record
in the Team Class the collection at the Tournament class
was not updated.

But right now , I try a new way to make it work that a
new team is made and returned or a team is returned if
that team is known.

Roelof



Op 25-3-2019 om 06:18 schreef Richard O'Keefe:
  
  

  This is a
simple programming-contest sort of exercise.
  You "need"
only two classes.
  + a Team
    - knows
its name (a String of at most 30 characters)
      * This
should be passed when the Team is created;
    the
rest of the program should NOT call (Team new)
    and
should NEVER see an un#initialize-d Team instance.
  
    - knows the number of
matches it has won, drawn, and lost
      (non-negative Integers,
initially zero).
    - can report what it knows
    - can report the total match
count and point score
  
    - can be told that it has
won, drawn, or lost another match.
    
  
  + a Tournament
    - has a collection of Teams
that it knows by name
  
  
    (a Dictionary)
  - and an sequence,
  initially undefined.
  - can read a set of match
  triples from a stream,
    forwarding the
  information about wins, draws, and losses
    to Team instances, which
  are created when a new name is found,
  - can convert the values
  of the teams collection to a
    sorted collection that
  is sorted by a somewhat vague order,
    I chose
  - descending on point
  score, then
  - descending on wins,
  then
  - ascending  on
  losses, then
  - ascending  on name.
  - can write the sorted
  teams to a stream in tabular form.
  ! Has a class method that
  does
  

[Pharo-users] how to convert this with a stream

2019-03-26 Thread Roelof Wobben
Hello,

I have a SortedCollection of teams.

Now I need to convert this to a line like this :

'Allegoric Alaskans |  1 |  1 |  0 |  0 |  3'

I tried it with this :

outcome := Array
        streamContents: [ :s |
            TeamStatusSorted
                do: [ :each |
                    s << each name.
                    s << String cr ] ].
    ^ outcome


or String streamContents but it will not give me the right answer,
So please some hints how I can make this work.

Roelof




Re: [Pharo-users] how to convert this with a stream

2019-03-26 Thread Roelof Wobben
Hello

Could be , im confused now

I tried this :

outcome
        add: 'Team   | MP |  W |  D |  L |  P'.
    outcome
        add: [ String
                streamContents: [ :s |
                    TeamStatusSorted
                        do: [ :each |
                            s << each name.
                            s << String cr ] ] ].
    ^ outcome

but  get now a output of the header and then the code.

Roelof



Op 26-3-2019 om 19:38 schreef Carlo:

Hi Roelof

I think you meant
   String streamContents:
and not
   Array streamContents:



On 26 Mar 2019, at 20:12, Roelof Wobben  wrote:

Hello,

I have a SortedCollection of teams.

Now I need to convert this to a line like this :

'Allegoric Alaskans |  1 |  1 |  0 |  0 |  3'

I tried it with this :

outcome := Array
 streamContents: [ :s |
 TeamStatusSorted
 do: [ :each |
 s << each name.
 s << String cr ] ].
 ^ outcome


or String streamContents but it will not give me the right answer,
So please some hints how I can make this work.

Roelof










Re: [Pharo-users] how to convert this with a stream

2019-03-26 Thread Roelof Wobben
Carlo,

Thanks,

This gives the output I expect

outcome
        add: 'Team   | MP |  W |  D |  L |  P'.
    outcome
        add:
            (String
                streamContents: [ :s |
                    TeamStatusSorted
                        do: [ :each |
                            s << each name.
                            s << '    '.
                            s << ' |  '.
                            s << each totalPlayed.
                            s << ' |  '.
                            s << each winCount.
                            s << String cr ] ]).
    ^ outcome


but I think its ugly. Hopefully someone can give me hints how to improve 
this .


Roelof





Op 26-3-2019 om 20:14 schreef Carlo:

Hi Roelof

The block [] should be (). What's happening is that the block is being added to 
outcome which will then print itself out.

Cheers
Carlo

On 26 Mar 2019, at 20:45, Roelof Wobben  wrote:

Hello

Could be , im confused now

I tried this :

outcome
 add: 'Team   | MP |  W |  D |  L |  P'.
 outcome
 add: [ String
 streamContents: [ :s |
 TeamStatusSorted
 do: [ :each |
 s << each name.
 s << String cr ] ] ].
 ^ outcome

but  get now a output of the header and then the code.

Roelof



Op 26-3-2019 om 19:38 schreef Carlo:

Hi Roelof

I think you meant
   String streamContents:
and not
   Array streamContents:



On 26 Mar 2019, at 20:12, Roelof Wobben  wrote:

Hello,

I have a SortedCollection of teams.

Now I need to convert this to a line like this :

'Allegoric Alaskans |  1 |  1 |  0 |  0 |  3'

I tried it with this :

outcome := Array
 streamContents: [ :s |
 TeamStatusSorted
 do: [ :each |
 s << each name.
 s << String cr ] ].
 ^ outcome


or String streamContents but it will not give me the right answer,
So please some hints how I can make this work.

Roelof















Re: [Pharo-users] how to convert this with a stream

2019-03-27 Thread Roelof Wobben
  
  
@Richard , thanks a lot
  
  I was already using that way and finnaly I solved it
  
  here is my code :  https://github.com/RoelofWobben/Tournament-
  
  Someone who can give feedback to the way I solved it
  
  Roelof
  
  
  
  
  Op 27-3-2019 om 13:06 schreef Richard O'Keefe:


  
  
"I have a
  SortedCollection of Teams.  Now I need to convert *it*
 to a line like ...".
Well, no.  You need to
  convert *each team* separately to such a
line.  So something
  like
  aStream nextPutAll:
  '...header line...'; cr.
  mySortedTeams do:
  [:eachTeam |
     -write a
  formatted line describing eachTeam to aStream].


Now it gets
  interesting.  Whose responsibility is it to write
a representation of a
  Team instance to a stream?  Should it be
done by the Team
  instance, or should it be done outside?


Question 1: is there
  obviously one and only one format, or do
you think that in a
  more realistic example there might be more
than one way to print
  a Team object?  I concluded that there
might be many
  different ways to do it.  (I personally dislike
putting variable
  length fields on the left.)


Question 2: *Can* it
  be done from the outside or *must* it be
done inside?  Is there
  any information in the printed representation
that the caller cannot
  ask the team object for?  In this case, all
of the information is
  available through Team's public interface.


Question 3: Should
  Teams and printing be *coupled*?  Should a Team
know about details
  like the dividing line between columns?  In this
case, I decided that
  putting the formatting code inside the Team
object was highly
  undesirable coupling.


Question 4: Is it
  *possible* for a Team object to do the formatting
without knowing about
  all the other Teams in the collection?  In this
case, the
  specification is rather vague.  It seemed to me that all
the numeric columns
  should be the same width and should be wide enough
to hold the largest
  number with a space on each side.


In answer to question
  4, my Tournament code contains
   w := mySortedTeams
  inject: 1 into: [:acc :team |
    (team matchCount
  max: team points) printString size max: acc].
and this clearly
  requires knowledge of all the teams, so it makes no
sense to put it in
  Team. (Of course, if the column widths are fixed,
this argument fails,
  but such a choice makes no sense for large problems.)


So now you need
  something like
   aStream nextPutAll:
  team name; space: 30 - team name size.
and then a numeric
  value might be written as
   aStream nextPutAll:
  ' | '; space: w - team points printString size;
     print: team
  points.


Please do not use
  << . Historically, << had no meaning in Smalltalk.
In some Smalltalks it
  means leftwards bit shift.  It is just too
confusing.  (In a
  shell, you would use > for output, not <<, which
is used for a kind of
  input.)  It is really weird to use s << String cr
instead of s cr.  So
  idomatic Smalltalk would be
  s nextPutAll: t
  name; cr.


Why are you writing to
  (an output stream over) an Array?
  Surely you want a String?
But in any case, I
  would split this into two methods:


  printTeams: teams
  on: aStream
    -- print heading
  --
    -- print each team
  --
  printTeamsAsString:
  teams
    ^String
  streamContents: [:s | self printTeams: teams on:s]


  
  
  
On Wed, 27 Mar 2019 at 07:12,
  Roelof Wobben <r.wob...@home.nl> wrote:

Hello,
  
  I have a SortedCollection of teams.
  
  Now I need to convert this to a line like this :
  
  'Allegoric Alaskans |  1 |  1 |  0 |  0 |  3'
  
  I tried it with this :
  
  outcome := Array
       streamContents: [ :s |
           TeamStatusSorted
   

[Pharo-users] why is asDictonary a class method

2019-03-30 Thread Roelof Wobben
Hello,

Im busy with a new challenge from exercism.
Where I have to keep track of a robot , where it facing and on that 
coordinate the robot is.


so I made this function what the test wanted

createDirection: aString position: aCollection
    self robot: (Robot directionLooking: aString) yourself.
    ^ self robot asDictonary

I can see that on the first part a new robot is made with the right data.
but the test wants the data back as a Dictonary
that is why I made the self robot asDictonary line

but to my suprise the compiler wants it be a class method where I expect 
it to be a instance method.


Can someone explain to my why this is ?

Roelof




Re: [Pharo-users] why is asDictonary a class method

2019-03-30 Thread Roelof Wobben
  
  
Op 31-3-2019 om 03:47 schreef Richard
  O'Keefe:


  
  
Question 1.  Should
  that be #asDictionary?
  



yes, it does.


  
Question 2.  If not,
  what's a Dictonary?
Question 3.  I see you
  are using self-encapsulation,
 with a
  getter 'self robot'
 and a
  setter 'self robot: something'.
 Of course
  that means that outside code
 can
  freely smash your "robot" property,
 unless
  #robot: checks that its argument
 makes
  sense.  Does it?
  



no, it does not. 



  
Question 4.  What kind
  of thing *is* "robot".
 Have you
  checked that 'Robot directionLooking: ...'
 returns
  an instance of Robot?  If you accidentally
 omitted
  '^' it might return the Robot class itself.

  



yes, I forget the ^ thing 
see this code. 

directionLooking: aString
    self new direction: aString


so I have to think well how to return a instance of a Robot here. 

as far as I see  I do not have a robot yet. 

createDirection: aString position: aCollection
    self robot: (Robot directionLooking: aString) yourself.
    ^ self robot asDictionary

or I overlook something. 




  
Question 5.  Are you
  sure that 'self robot' returns
 what you
  think it does?  Have you checked?
  


yes, I checked. self Robot  give me a variable robot which is a
Robot.


  
Question 6.  Does
  Robot have an #asDictionary method?
 Does
  Robot have an #asDictonary method?
  



Yes, it does 

  
Question 7.  Why is
  "aCollection" not used in this method?
  


Because I  wanted to be  sure things are working before I added the
position which is a difficult one. 


  
Question 8.  Why are
  you using 'yourself'?
  


I thought I was needed so I get a instance of a Robot back. 


  
Question 9.  Why does
  the caller want a dictionary instead of
 a Robot? 
  What should be in that dictionary?


  


The same data as the Robot has but then in a dictionary form. 
That is what I try to achieve. 


  
There are more
  questions but those will do to be going on with.
If your #robot: method
  began like
    robot: aRobot
  (aRobot
  isKindOf: Robot)
    ifFalse:
  [aRobot error: 'not an instance of Robot'].
you would have caught
  what I suspect is your problem.
Check question 4.

    



  
  
  
On Sun, 31 Mar 2019 at 07:19,
  Roelof Wobben <r.wob...@home.nl> wrote:

Hello,
  
  Im busy with a new challenge from exercism.
  Where I have to keep track of a robot , where it facing and on
  that 
  coordinate the robot is.
  
  so I made this function what the test wanted
  
  createDirection: aString position: aCollection
   self robot: (Robot directionLooking: aString) yourself.
   ^ self robot asDictonary
  
  I can see that on the first part a new robot is made with the
  right data.
  but the test wants the data back as a Dictonary
  that is why I made the self robot asDictonary line
  
  but to my suprise the compiler wants it be a class method
  where I expect 
  it to be a instance method.
  
  Can someone explain to my why this is ?
  
  Roelof
  
  

  


  




Re: [Pharo-users] why is asDictonary a class method

2019-03-31 Thread Roelof Wobben
  
  
Tim Thanks
  
  I could not answer this because of the birtday of my wife today
  but you did a excellent job.
  
  Roelof
  
  
  
  Op 31-3-2019 om 17:29 schreef Tim Mackinnon:


  
  Hi Richard/all - thanks for helping Roelof out. He’s working
  through the exercism.io
  exercises that we’ve managed to convert so far. As they are based
  on more C like languages, they aren’t always as OO as we want
  (once we get a decent set converted, we’ll try and add some
  smallish examples - anyone’s favourites appreciated).
  
  
  The dictionary reference is normally because the exercise
tests like to assert on some description at the end (and
dictionaries tend to exist universally in most languages). So
view it more as a #printOn: like finalé (this said - Roelof
might have this behaviour in the wrong place - but we will see).
  
  
  The feedback so far, seems to have helpfully unblocked him so
thanks all.


Tim

  Sent from my iPhone
  
On 31 Mar 2019, at 12:02, Richard O'Keefe <rao...@gmail.com>
wrote:

  
  

  

  
I think
  you probably need to show us *all* the code.


directionLooking:
  aString
      self new direction: aString



Well,
  there is your problem.
There are
  two ways for a method to return a value.
One is to
  execute '^ e' for some _expression_ e,
which is
  quite like a 'return e;' statement in C.
The other
  is to execute the whole body and come to
the end of
  the method, and in that case the result
is always
  'self'.  This means that the method as you
wrote it
 - created
  an uninitialised or incompletely initialised
  
  instance of Robot (self new)
 - asked
  that instance to set its direction
 -
  discarded the result of that setting
 - forgot
  the new instance
 -
  returned the Robot class


What you
  probably meant was

  directionLooking:
aString
    ^(self new) direction: aString; yourself
  where
'yourself' has nothing to do with a new
  object
being created but with the fact that
  you want
the new object as the result, not
  whatever
#direction: returns.
  directionLooking:
aString
   
|newRobot|
   
newRobot := self new.
   
newRobot direction: aString.
   
^newRobot
  may be
clearer to you.
  
  
  By the
way, you didn't say WHY the caller wants a
Dictionary
  instead
of a Robot.  I don't think I've ever written a
program
  where
that was a good idea.
  
  
  
  
  
  

  

  
  
  
    On Sun, 31 Mar 2019 at
  19:55, Roelof Wobben <r.wob...@home.nl>
  wrote:


  
Op
  31-3-2019 om 03:47 schreef Richard O'Keefe:


  
Question
  1.  Should that be #asDictionary?
  
  

[Pharo-users] is this valid smalltalk

2019-04-04 Thread Roelof Wobben
Hello,

For a challenge of Exercism I need to check if some parenthes and 
brackets are balanced.


so for example

()  = true
([])  = true

but (])  is not true because the bracket has no opening bracket.

Now I wonder if I can premature end a #do:  like this

collection do: [:element | (condition with element) ifFalse: [^false]]

in pseudo code

is this a valid way to end the do ?
or is there a better way ?

Roelof



Re: [Pharo-users] is this valid smalltalk

2019-04-04 Thread Roelof Wobben
Op 4-4-2019 om 13:22 schreef K K Subbu:

On 04/04/19 4:46 PM, Roelof Wobben wrote:

Hello,

For a challenge of Exercism I need to check if some parenthes and 
brackets are balanced.


so for example

()  = true
([])  = true

but (])  is not true because the bracket has no opening bracket.

Now I wonder if I can premature end a #do:  like this

collection do: [:element | (condition with element) ifFalse: [^false]]


Have you looked at anySatisfy:

 #('the' 'quick' 'brown' 'fox') anySatisfy: [:s | s beginsWith: 'x' ]

Regards .. Subbu


yep,  i also  took a look at that one




Re: [Pharo-users] is this valid smalltalk

2019-04-04 Thread Roelof Wobben
  
  
I already thought to use this flow. 
  
  but I only wondered if I could use the ^false this way and
  appearently it is allowed. 
  
  so I can begin with this one. 
  
  The Pharo track is still hidden but I saw on the github page that
  in a short time it will be public with some 20 - 25 challenges. 
  
  Roelof
  
  
  Op 4-4-2019 om 14:36 schreef Richard O'Keefe:


  
  
For a change this is
  an exercism problem I know something about.
I did look at the
  exercism web site, and did all the SML exercises,
but could not find any
  for Smalltalk or Pharo.


The exercise is in
  fact about using a stack.
   stack <- empty
   for each character
  of the string
      if it is one of
  ( [ { push it on the stack
      if it is one of
  ) ] }
         if the stack
  is empty or the top element does not
            correspond
  to this character, return false
      if it is not one
  of ( ) [ ] { } just ignore it
   return (the stack
  is empty)


BOTH of the "return"
  constructs in this pseudo-code become
^ something
in Smalltalk.  "Long
  returns", where "^" occurs inside a block,
are well defined, very
  useful, and universally accepted in Smalltalk.


There is no analogue
  of "^" for returning from a block.


By the way, this has
  nothing to do with #do:.  It's about
returning from the
  method through any number of blocks.

For example, you will
  sometimes see code like
   x := aDictionary
  at: aKey ifAbsent: [^false].


  
  
  
    On Fri, 5 Apr 2019 at 00:16,
  Roelof Wobben <r.wob...@home.nl> wrote:

Hello,
  
  For a challenge of Exercism I need to check if some parenthes
  and 
  brackets are balanced.
  
  so for example
  
  ()  = true
  ([])  = true
  
  but (])  is not true because the bracket has no opening
  bracket.
  
  Now I wonder if I can premature end a #do:  like this
  
  collection do: [:element | (condition with element) ifFalse:
  [^false]]
  
  in pseudo code
  
  is this a valid way to end the do ?
  or is there a better way ?
  
  Roelof
  

  


  




[Pharo-users] can I do something like this with Double Dispatch

2019-04-06 Thread Roelof Wobben
Hello,

Just thinking how to solve the bowling challenge from exercism.

but I wonder if I can do something like this in the method that checks 
if I have the right object


I was thinking about this :

Result
-- Strike
-- Spare
-- allOther

then In  Strike something like this

checkForBonus: number1 score2: number2
  ^ number1 + number2 == 10

or am I thinking the totally wrong way to solve this?

Roelof





[Pharo-users] difference between double dispatch and the method explains here

2019-04-06 Thread Roelof Wobben
Hello,

I just learned double dispatch.
And now for the Robot challenge of exercism Tim has pointed me to this 
article(https://blog.metaobject.com/2019/04/accessors-have-message-obsession.html) 




but I fail to see how the move method looks like in that article.
I had a conversation with Tim in the exercism channel and the way he 
explains it, it looks like double dispatch for me.


Am I on the right track or do I oversee something here.

Roelof






Re: [Pharo-users] difference between double dispatch and the method explains here

2019-04-06 Thread Roelof Wobben
  
  
oke, 
  
  so I need a single Object here 
  that contains this in a initialize function : 
  
  north = Direction( 0, -1)
east  = Direction( 1,  0)
south = Direction( 0,  1)
west  = Direction(-1,  0)



oke, then time to figure out how to change my functions because I have the feeling that I still miss
some of the pieces: 

Robot >> move: aInstruction
	aInstruction = $R
		ifTrue: [ ^ self direction: (PositioningSystem new turnRight: direction) ].
	aInstruction = $L
		ifTrue: [ ^ self direction: (PositioningSystem new turnLeft: direction) ].
	^ self
		position:
			(PositioningSystem new moveForWard: position direction: self direction)




  PositionSystem class >>  initialize
      Directions := {('north' -> (0 @ 1)).
      ('east' -> (1 @ 0)).
      ('south' -> (0 @ -1)).
      ('west' -> (-1 @ 0))}
  
  PositionSystem >> turnRight: aDirection
      "comment stating purpose of message"
  
      | old |
      old := Directions detect: [ :b | b key = aDirection ].
      ^ (Directions after: old ifAbsent: [ Directions first ]) key
  
  Roelof
  
  
  
  
  
  Op 6-4-2019 om 15:15 schreef K K Subbu:

On
  06/04/19 4:49 PM, Roelof Wobben wrote:
  
  Hello,


I just learned double dispatch.

And now for the Robot challenge of exercism Tim has pointed me
to this
article(https://blog.metaobject.com/2019/04/accessors-have-message-obsession.html)

but I fail to see how the move method looks like in that
article.

I had a conversation with Tim in the exercism channel and the
way he explains it, it looks like double dispatch for me.


Am I on the right track or do I oversee something here.

  
  unary methods like moveRight perform specific ops and are not
  parametric, so only a single dispatch, depending on the receiver,
  is needed.
  
  
  If you change it to move: aDistanceOrAngle, then performing
  requests like "move: 3 cms" or "move: 30 degrees" will depend not
  only on the receiver but also on the class of the argument. This
  would need double dispatch (aka multiple polymorphism). The first
  dispatch would be based on the receiver and the receiver's method
  would then dispatch it based on the class of the argument (i.e.
  Distance>>move or Angle>>move )
  
  
  HTH .. Subbu
  
  
  


  




Re: [Pharo-users] difference between double dispatch and the method explains here

2019-04-07 Thread Roelof Wobben
Op 6-4-2019 om 15:15 schreef K K Subbu:

On 06/04/19 4:49 PM, Roelof Wobben wrote:

Hello,

I just learned double dispatch.
And now for the Robot challenge of exercism Tim has pointed me to 
this 
article(https://blog.metaobject.com/2019/04/accessors-have-message-obsession.html) 


but I fail to see how the move method looks like in that article.
I had a conversation with Tim in the exercism channel and the way he 
explains it, it looks like double dispatch for me.


Am I on the right track or do I oversee something here.
unary methods like moveRight perform specific ops and are not 
parametric, so only a single dispatch, depending on the receiver, is 
needed.


If you change it to move: aDistanceOrAngle, then performing requests 
like "move: 3 cms" or "move: 30 degrees" will depend not only on the 
receiver but also on the class of the argument. This would need double 
dispatch (aka multiple polymorphism). The first dispatch would be 
based on the receiver and the receiver's method would then dispatch it 
based on the class of the argument (i.e. Distance>>move or Angle>>move )


HTH .. Subbu





hmm, still stuck

I have now a class Direction with as instance variables north, south, 
east, west

and made the accessors.

then I thought I need a initialize like this :

initialize
   north = Direction( 0, -1).
   east  = Direction( 1,  0).
   south = Direction( 0,  1).
   west  = Direction(-1,  0).

but the Direction (0,-1)  is a problem . the compiler does not like the 
(0,-1) part


to give you the big picture. I have a Robot which can turnRight , 
turnLeft and moveForward and I try to understand how the page would work 
in my case.


So I have a object Direction as described above and a Object MoveForward 
which is a subobject of Direction.

MoveForward has only 1 method :

IsMove
   ^  'A'

Roelof




Re: [Pharo-users] difference between double dispatch and the method explains here

2019-04-07 Thread Roelof Wobben
  
  
I can try to explain what I trying to
  solve. 
  
  I have a Robot which can turn left,  turn right or moveForward. 
  
  now I have a string like 'LAR'
  
  that means the robot needs to turn left (l) , move forward one
  place (A) and turn left. 
  and I have to keep track to which direction the robot is facing
  and on which coordinate it stands. 
  
  so to summarize with the above string 
  
  lets say the robot is facing north on coordinate (0,0) 
  then it has to turn left , so its facing east and still on
  coordinate (0,0) 
  then it has to move forward, so its still  facing east but are on
  coordinate(0,1) 
  then it has to turn right, so its facing north and on coordinate
  (0,1) 
  
  and TimMacKinnon has challenged me to do this with double
  dispatch. 
  
  So I think now I need a object Direction, a sub object North and a
  sub - sub object TurnLeft, turnRight and moveForward. 
  
  So I can use double dispath first the direction North, East,
  South, West 
  and then use double dispatch to find the right move. 
  
  Roelof
  
  
  
  
  
  Op 8-4-2019 om 06:50 schreef Richard O'Keefe:


  
  
It would really REALLY
  **REALLY** help if we knew what
the heck you were
  trying to do.  There is an excellent
chance that it is MUCH
  simpler than you think.  If you
cannot show us the
  Smalltalk version of the problem,
can you show us the
  version for some other language?


  
  
  
On Sun, 7 Apr 2019 at 20:15,
      Roelof Wobben <r.wob...@home.nl> wrote:

Op
  6-4-2019 om 15:15 schreef K K Subbu:
  > On 06/04/19 4:49 PM, Roelof Wobben wrote:
  >> Hello,
  >>
  >> I just learned double dispatch.
  >> And now for the Robot challenge of exercism Tim has
  pointed me to 
  >> this 
  >> article(https://blog.metaobject.com/2019/04/accessors-have-message-obsession.html)
  
  >>
  >> but I fail to see how the move method looks like in
  that article.
  >> I had a conversation with Tim in the exercism channel
  and the way he 
  >> explains it, it looks like double dispatch for me.
  >>
  >> Am I on the right track or do I oversee something
  here.
  > unary methods like moveRight perform specific ops and are
  not 
  > parametric, so only a single dispatch, depending on the
  receiver, is 
  > needed.
  >
  > If you change it to move: aDistanceOrAngle, then
  performing requests 
  > like "move: 3 cms" or "move: 30 degrees" will depend not
  only on the 
  > receiver but also on the class of the argument. This
  would need double 
  > dispatch (aka multiple polymorphism). The first dispatch
  would be 
  > based on the receiver and the receiver's method would
  then dispatch it 
  > based on the class of the argument (i.e.
  Distance>>move or Angle>>move )
  >
  > HTH .. Subbu
  >
  >
  
  
  hmm, still stuck
  
  I have now a class Direction with as instance variables north,
  south, 
  east, west
  and made the accessors.
  
  then I thought I need a initialize like this :
  
  initialize
      north = Direction( 0, -1).
      east  = Direction( 1,  0).
      south = Direction( 0,  1).
      west  = Direction(-1,  0).
  
  but the Direction (0,-1)  is a problem . the compiler does not
  like the 
  (0,-1) part
  
  to give you the big picture. I have a Robot which can
  turnRight , 
  turnLeft and moveForward and I try to understand how the page
  would work 
  in my case.
  
  So I have a object Direction as described above and a Object
  MoveForward 
  which is a subobject of Direction.
  MoveForward has only 1 method :
  
  IsMove
      ^  'A'
  
  Roelof
  
  

  


  




Re: [Pharo-users] difference between double dispatch and the method explains here

2019-04-08 Thread Roelof Wobben
  
  
Op 8-4-2019 om 10:57 schreef Richard
  O'Keefe:


  
  
One thing I have often
  seen and lamented is students
writing excessively
  complicated code with way too many
classes.  There is a
  huge difference between
  "A Robot knows its
  position and direction."
and
  "A Robot has-a
  Position and has-a Direction."
The first is the
  important one.  The second is
an over-commitment to
  too many classses.  For a
problem like this, you
  really really do not want
a Direction class, and
  you certainly have no use
for double dispatch.


A position can be
  represented by a pair of integers
x, y.  It could also
  be represented by a Point with
integer components.


A direction could be
  represented by a pair of integers
dx, dy such that
  |dx|+|dy| = 1.  It could also be
represented by a Point
  with integer components.


For movement, you need
  to be able to add the direction
to the location, which
  could be simply
x := x + dx.  y := y +
  dy.
or it could be
position := position +
  direction.
For turning, you need
  to be able to rotate a direction
vector by ninety
  degrees.  Now it so happens that
Point has methods
  #leftRotated and #rightRotated.


So we can do the
  following:
   a Robot has
  position (a Point) and direction (aPoint)
   position := 0 @ 0.
   direction := 0 @ 1.
To move forward
  without turning:
   position :=
  position + direction.
To turn left without
  moving:
   direction :=
  direction leftRotated.
To turn right without
  moving:
   direction :=
  direction rightRotated.
To obey a sequence of
  characters, commands:
   commands do: [:each
  |
  each caseOf: {
 [$A] ->
  [--move forward--].
 [$L] ->
  [--turn left--].
 [$R] ->
  [--turn right--]
  }].




One of the key ideas
  in extreme programming is
"You Ain't Gonna Need
  It", abbreviated to YAGNI!
The idea is *DON'T*
  generalise beyond your immediate
needs.  In this case,
  for example, the likelihood of
*this* program needing
  to deal with more general
kinds of movement is
  ZERO.  And the only reason for
using Point here
  instead of just using a few simple
assignment statements
  is that Point already exists,
so costs nothing to
  write, and as a familiar class,
code using it should
  be easy to read.



If someone challenges
  you to do something counter-productive,
refuse the challenge.

  
  
  
    On Mon, 8 Apr 2019 at 17:21,
  Roelof Wobben <r.wob...@home.nl> wrote:


  
I
  can try to explain what I trying to solve. 
  
  I have a Robot which can turn left,  turn right or
  moveForward. 
  
  now I have a string like 'LAR'
  
  that means the robot needs to turn left (l) , move forward
  one place (A) and turn left. 
  and I have to keep track to which direction the robot is
  facing and on which coordinate it stands. 
  
  so to summarize with the above string 
  
  lets say the robot is facing north on coordinate (0,0) 
  then it has to turn left , so its facing east and still on
  coordinate (0,0) 
  then it has to move forward, so its still  facing east but
  are on coordinate(0,1) 
  then it has to turn right, so its facing north and on
  coordinate (0,1) 
  
  and TimMacKinnon has challenged me to do this with double
  dispatch. 
  
  So I think now I need a object Direction, a sub object
  North and a sub - sub object TurnLeft, turnRight and
  moveForward. 
  
  So I can use double dispath first the direction North,
  East, South, West 
  and then use double

Re: [Pharo-users] difference between double dispatch and the method explains here

2019-04-08 Thread Roelof Wobben
allenges
  you to do something counter-productive,
refuse the challenge.

  
  
  
On Mon, 8 Apr 2019 at 17:21,
  Roelof Wobben <r.wob...@home.nl> wrote:


  
I
  can try to explain what I trying to solve. 
  
  I have a Robot which can turn left,  turn right or
  moveForward. 
  
  now I have a string like 'LAR'
  
  that means the robot needs to turn left (l) , move forward
  one place (A) and turn left. 
  and I have to keep track to which direction the robot is
  facing and on which coordinate it stands. 
  
  so to summarize with the above string 
  
  lets say the robot is facing north on coordinate (0,0) 
  then it has to turn left , so its facing east and still on
  coordinate (0,0) 
  then it has to move forward, so its still  facing east but
  are on coordinate(0,1) 
  then it has to turn right, so its facing north and on
  coordinate (0,1) 
  
  and TimMacKinnon has challenged me to do this with double
  dispatch. 
  
  So I think now I need a object Direction, a sub object
  North and a sub - sub object TurnLeft, turnRight and
  moveForward. 
  
  So I can use double dispath first the direction North,
  East, South, West 
  and then use double dispatch to find the right move. 
  
  Roelof
  
  
  
  
  
  Op 8-4-2019 om 06:50 schreef Richard O'Keefe:


  
It would
  really REALLY **REALLY** help if we knew what
the heck you
  were trying to do.  There is an excellent
chance that it
  is MUCH simpler than you think.  If you
cannot show us
  the Smalltalk version of the problem,
can you show
      us the version for some other language?


  
  
  
On Sun, 7 Apr 2019 at
  20:15, Roelof Wobben <r.wob...@home.nl>
  wrote:

Op 6-4-2019 om
  15:15 schreef K K Subbu:
  > On 06/04/19 4:49 PM, Roelof Wobben wrote:
  >> Hello,
  >>
  >> I just learned double dispatch.
  >> And now for the Robot challenge of exercism
  Tim has pointed me to 
  >> this 
  >> article(https://blog.metaobject.com/2019/04/accessors-have-message-obsession.html)
  
  >>
  >> but I fail to see how the move method looks
  like in that article.
  >> I had a conversation with Tim in the exercism
  channel and the way he 
  >> explains it, it looks like double dispatch
  for me.
  >>
  >> Am I on the right track or do I oversee
  something here.
  > unary methods like moveRight perform specific ops
  and are not 
  > parametric, so only a single dispatch, depending
  on the receiver, is 
  > needed.
  >
  > If you change it to move: aDistanceOrAngle, then
  performing requests 
  > like "move: 3 cms" or "move: 30 degrees" will
  depend not only on the 
  > receiver but also on the class of the argument.
  This would need double 
  > dispatch (aka multiple polymorphism). The first
  dispatch would be 
  > based on the receiver and the receiver's method
  would then dispatch it 
  > based on the class of the argument (i.e.
  Distance>>move or Angle>>move )
  >
  > HTH .. Subbu
  >
  >
  
  
  hmm, still stuck
  
  I have now a class Direction with as instance
  variables north, south, 
  east, west
  and made the accessors.
  
  then I thought I ne

Re: [Pharo-users] can I do something like this with Double Dispatch

2019-04-08 Thread Roelof Wobben
  
  
it is almost the same. 
  
  here exercism challenge looks like this : 
  
  Scoring Bowling
  The game consists of 10 frames. A frame is composed of one or
two ball
throws with 10 pins standing at frame initialization. There are
three
cases for the tabulation of a frame.
  

  An open frame is where a score of less than 10 is recorded
for the
frame. In this case the score for the frame is the number of
pins
knocked down.


  A spare is where all ten pins are knocked down by the
second
throw. The total value of a spare is 10 plus the number of
pins
knocked down in their next throw.


  A strike is where all ten pins are knocked down by the
first
throw. The total value of a strike is 10 plus the number of
pins
knocked down in the next two throws. If a strike is
immediately
followed by a second strike, then the value of the first
strike
cannot be determined until the ball is thrown one more time.

  
  Here is a three frame example:
  

  
Frame 1
Frame 2
Frame 3
  


  
X (strike)
5/ (spare)
9 0 (open frame)
  

  
  Frame 1 is (10 + 5 + 5) = 20
  Frame 2 is (5 + 5 + 9) = 19
  Frame 3 is (9 + 0) = 9
  This means the current running total is 48.
  The tenth frame in the game is a special case. If someone
throws a
strike or a spare then they get a fill ball. Fill balls exist to
calculate the total of the 10th frame. Scoring a strike or spare
on
the fill ball does not give the player more fill balls. The
total
value of the 10th frame is the total number of pins knocked
down.
  For a tenth frame of X1/ (strike and a spare), the total value
is 20.
  For a tenth frame of XXX (three strikes), the total value is
30.
  Requirements
  Write code to keep track of the score of a game of bowling. It
should
support two operations:
  

  roll(pins : int) is called each time the player
  rolls a ball. The
  argument is the number of pins knocked down.

  score() : int is called only at the very end of
  the game. It
  returns the total score for that game.
  
  
  and the input is like this :  
  
  test05_ConsecutiveSparesEachGetAOneRollBonus
      | result |
      result := bowlingCalculator
          scoreAfterRolling: #(5 5 3 7 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  0).
      self assert: result equals: 31
  
  Roelof
  
  
  
  
  Op 8-4-2019 om 11:43 schreef Richard O'Keefe:


  
  

  Remember, we cannot
see the Smalltalk exercises in exercism.
  We cannot help you
without knowing what problem you are
  trying to solve.  Is
this problem basically the same as
  https://www.reddit.com/r/dailyprogrammer/comments/3ntsni/20151007_challenge_235_intermediate_scoring_a/?ref=share&ref_source=link
  or is it different?
  
  
  
  Double dispatch is a
programming technique,
  not an end in
itself.
  
  
  A weird thing about
the exercism site is that you can
  see *solutions* to
problems for a language even if you
  cannot see the
*problems* themselves.  So I have seen
  *solutions* to
Bowling in several languages; some with
  no objects at all,
and some using single dispatch only.
  This is a 'medium'
problem, meaning the solution is
  maybe 2 or 3 pages.
  
  
  KEEP IT SIMPLE.
  Not every *concept*
needs to be a *class*.
  
  

  
  
  
On Sat, 6 Apr 2019 at 21:53,
  Roelof Wobben <r.wob...@home.nl> wrote:

Hello,
  
  Just thinking how to solve the bowling challenge from
  exercism.
  
  but I wonder if I can do something like this in the method
  that checks 
  if I have the right object
  
  I was thinking about this :
  
  Result
  -- Strike
  -- Spare
  -- allOther
  
  then In  Strike something like this
  
  checkForBonus: number1 score2: number2
     ^ number1 + number2 == 10
  
  or 

Re: [Pharo-users] difference between double dispatch and the method explains here

2019-04-08 Thread Roelof Wobben
  x > 0 ifTrue: [#west ] ifFalse: [#east ]]


nameToPoint: aSymbol
  aSymbol = #north
  ifTrue: [^0 @ 1].
  aSymbol = #south
  ifTrue: [^0 @ -1].
  aSymbol = #west 
  ifTrue: [^1 @ 0].
  aSymbol = #east 
  ifTrue: [^-1 @ 0].
  aSymbol error: 'not
  a compass direction in lower case'.


Another problem I had
  with exercism was a "Space-Age"
exercise where the
  README.md capitalised the planet names
but
  test_Space-Age. insisted on lower case.
That might well happen
  here.


Just for grins,
Dictionary>>
    asPoint
  ^(self at: 'x') @
  (self at: 'y')


Point>>
asDictionary
  ^(Dictionary new)
 at: 'x' put: self
  x;
 at: 'y' put: self
  y;
 yourself






  
  
  
On Mon, 8 Apr 2019 at 22:15,
  Roelof Wobben <r.wob...@home.nl> wrote:


  
Richard
  thanks. 
  
  One thing I do not see direct. 
  
  you said : 
  
  
  
  A direction
could be represented by a pair of integers
  dx, dy such that
|dx|+|dy| = 1.  It could also be
  represented by a
Point with integer components.

for me a direction is the direction the robot is facing
so something like north or east. 

the challenge also wants a output like this : 

test11_MovesTheRobotForward1SpaceInTheDirectionItIsPointingIncreasesTheYCoordinateOneWhenFacingNorth
    | result |
    result := robotSimulatorCalculator
        moveDirection: 'north'
        position:
            (Dictionary new
                add: 'x' -> 0;
                add: 'y' -> 0;
                yourself)
        instructions: 'A'.
    self
        assert: result
        equals:
            (Dictionary new
                add: 'direction' -> 'north';
                add:
                    'position'
                        ->
                            (Dictionary new
                                add: 'x' -> 0;
                                add: 'y' -> 1;
                                yourself);
                yourself)

so how do I "convert" the point you are using to the
text. 

Or do I misunderstood you somewhere wrong. 

Roelof

  
  
  
  
  Op 8-4-2019 om 10:57 schreef Richard O'Keefe:


  
One thing I
  have often seen and lamented is students
writing
  excessively complicated code with way too many
classes. 
  There is a huge difference between
  "A Robot
  knows its position and direction."
and
  "A Robot
  has-a Position and has-a Direction."
The first is
  the important one.  The second is
an
  over-commitment to too many classses.  For a
problem like
  this, you really really do not want
a Direction
  class, and you certainly have no use
for double
  dispatch.


A position can
  be represented by a pair of integers
x, y.  It
  could also be represented by a Point with
integer
  components.


A direction
  could be represented by a pair of integers
dx, dy such
  that |dx|+|dy| = 1.  It could also be
represented by
  a Point with integer components.


Re: [Pharo-users] difference between double dispatch and the method explains here

2019-04-08 Thread Roelof Wobben
  
  
Thanks, 
  
  for the discusson and lessons. 
  
  I will think about it and also think if smalltalk is for me. 
  I did the pharo Mooc and still have a lot of problems making the
  smalltalk way click in my head so I can solve little problems like
  this.
  
  Out of coriousy what dialect do you use?
  
  
  Op 8-4-2019 om 17:11 schreef Richard O'Keefe:


  
  

  You are expected to
use my code fragments for *ideas*,
  not to incorporate
them *literally* in your code.  As
  I explained,
*without seeing the specification*, I have
  no way to tell
whether the specification uses a left-handed
  or right-handed
coordinate system.
  
  
  For what it's worth,
here's a complete program in my
  Smalltalk dialect. 
It doesn't plug into the exercism
  testing framework
because I can do not know what it
  looks like.  But if
it makes the code more complicated
  that this, it's
doing it wrong.
  
  
  require: 'geometry.st' 
"Point"
require: 'print.st'
"OutputStream>>print:"
    
Object subclass: #Robot
  instanceVariableNames: 'position direction'
  poolDirectionaries:    'FileStream'

  methods for: 'initialising'
    pvtPostNew
  position  := 0@0.
  direction := 1@0.

  methods for: 'accessing'
    direction
  ^direction copy

    location
  ^location copy

    obey: commands
  commands do: [:each |
    each caseOf: {
  [$A] -> [position  := position  + direction].
  [$L] -> [direction := direction leftRotated].
  [$R] -> [direction := direction rightRotated]
    }].

  class methods for: 'main'
    start
  [StdIn atEnd] whileFalse: [
 |robot|
 robot := Robot new.
 Robot obey: StdIn nextLine.
     StdOut print: Robot location; cr].
  

  
  
  
On Tue, 9 Apr 2019 at 02:58,
  Roelof Wobben <r.wob...@home.nl> wrote:


  
yes, 
  this is a real  tests from the pharo track on exercism.io
  
  I understand what you mean but maybe I overthinking
  things. 
  But if we have a robot facing north and the robot turns to
  the left  , im my oponion it faces now to the east. 
  
  like this test is saying : 
  
test04_RotatesTheRobotsDirection90DegreesClockwiseChangesTheDirectionFromEastToSouth
      | result |
      result := robotSimulatorCalculator
          moveDirection: 'east'
          position:
              (Dictionary new
                  add: 'x' -> 0;
                  add: 'y' -> 0;
                  yourself)
          instructions: 'R'.
      self
          assert: result
          equals:
              (Dictionary new
                  add: 'direction' -> 'south';
                  add:
                      'position'
                          ->
                              (Dictionary new
                                  add: 'x' -> 0;
                                  add: 'y' -> 0;
                                  yourself);
                  yourself)
  
  
  but I cannot come to the same outcome with this code : 
  
  
  pointToName:
aPoint
    ^aPoint x
isZero
   ifTrue: 
[aPoint y > 0 ifTrue: [#north] ifFalse: [#south]]
   ifFalse:
[aPoint x > 0 ifTrue: [#west ] ifFalse: [#east ]]


maybe exercism.io is not a good
way to practice and learn smalltalk but I found not a
better one. or smalltalk is not for me. 

   

[Pharo-users] is this a valid Smalltalk way

2019-04-12 Thread Roelof Wobben
Hello,

Im thinking how to solve this one : 
https://github.com/exercism/problem-specifications/blob/master/exercises/bowling/description.md


so I thought because you throw two times for a frame to solve it like 
this :



aCollection withIndexDo: [:index :item |
   (if spare) ifTrue: take 3 items out of the score collection and sum 
them up
   (if strike) ifTrue: take 4 items out of the score collection and sum 
them up.
   (if not a spare and not a strike) : ifTrue:  take 2 items out of the 
score collection and sum them up.

   index := index + 2  // because  a frame is always two times a throw


Now I wonder if this is a valid smalltalk to do this

Roelof





Re: [Pharo-users] is this a valid Smalltalk way

2019-04-13 Thread Roelof Wobben
  
  
Hello Richard, 
  
  I do it afterwards the input looks like this : 
  
  #(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 3 7).
  
  and I solved it already like this :  
  
  scoreAfterRolling: aCollection
      | score |
      score := 0.
      1 to: aCollection size - 1 by: 2 do: [ :index | 
          score := (aCollection at: index) = 10
              ifTrue:
                  [ score + 10 + (aCollection at: index + 1) +
  aCollection at: index + 2 ]
              ifFalse: [ (aCollection at: index) + (aCollection at:
  index + 1) = 10
                      ifTrue: [ score + 10 + aCollection at: index +
  2 ]
                      ifFalse: [ score + (aCollection at: index) +
  (aCollection at: index + 1) ] ] ].
      ^ score
  
  
  but the problem I facing now that I see when someone throws a
  strike I do not need a step of 2 but a step of 1 
  I tried to make a custom step variable but that did not do the 
  job. 
  
  So right now thinking how to get out of this 
  
  Roelof
  
  
  
  
  
  Op 13-4-2019 om 11:37 schreef Richard O'Keefe:


  
  You wrote: "a frame is always two times a throw"
but the specification says "A frame is composed of one or two
ball throws"
and later we learn that the 10th frame may have three throws.


There is an issue with your Smalltalk.
aCollection withIndexDo: [:index :item |
  "You have the arguments in the wrong order.
   It is :item then :index"
   ...
   index := index + 2 "this is not legal"].
The assignment is not legal because you are not allowed
to assign to method parameters or block parameters.

You're going to have something like this:
  game := BowlingGame new.
  ... game roll: nPins.
  score := game score.
Since the score of a strike or a spare depends on the
scores of the *next* two throws, it might be easier to
process the throws backwards.
    
    
    On Sat, 13 Apr 2019 at 04:32, Roelof Wobben <r.wob...@home.nl>
wrote:
>
> Hello,
>
> Im thinking how to solve this one :
> https://github.com/exercism/problem-specifications/blob/master/exercises/bowling/description.md
>
> so I thought because you throw two times for a frame to
solve it like
> this :
>
>
> aCollection withIndexDo: [:index :item |
>     (if spare) ifTrue: take 3 items out of the score
collection and sum
> them up
>     (if strike) ifTrue: take 4 items out of the score
collection and sum
> them up.
>     (if not a spare and not a strike) : ifTrue:  take 2
items out of the
> score collection and sum them up.
>     index := index + 2  // because  a frame is always two
times a throw
>
>
> Now I wonder if this is a valid smalltalk to do this
>
> Roelof
>
>
  


  




[Pharo-users] how to model this a better way

2019-04-18 Thread Roelof Wobben
  
  
Hello, 
  
  I know I have asked earlier but im still stuck on this one : https://github.com/exercism/problem-specifications/blob/master/exercises/robot-simulator/description.md
  


  

  I tried with all double dispatch
but that will be a lot of duplicate classes

  


  

  
The problem I cannot solve right is that a robot can move or
turn. when a robot turns only the direction the robot is
facing changes and the position not. when a robot moves the
facing direction stays the same but the position changes.
but the change is dependend on the facing. Also the new
facing direction is dependend on the old facing direction/

  


  

  How can I model this the best.

  


  

  
I already have a object Robot that contains the facing
direction and the current position

  

or tried without it but then I use a lot of if then's


so it  there  a better way to model this problem so it will be all
nice and readable code. 

Roelof

  




Re: [Pharo-users] how to model this a better way

2019-04-18 Thread Roelof Wobben
  
  
yep, I have read that one 
  but I never gets a answer how I can "convert"  a point to
  something like north, east 
  
  because the challenge wants this to be the answer : 
  
  (Dictionary new
                  add: 'direction' -> 'north';
                  add:
                      'position'
                          ->
                              (Dictionary new
                                  add: 'x' -> 0;
                                  add: 'y' -> 0;
                                  yourself);
                  yourself)
  
  
  and I think I need then to use if then , which I try to avoid as
  much as possible. 
  
  Roelof
  
  
  
  Op 18-4-2019 om 18:33 schreef Richard Sargent:


  
  

  On Thu, Apr 18, 2019 at 8:57
AM Roelof Wobben <r.wob...@home.nl> wrote:
  
  

  Hello,


I know I have asked earlier but im still stuck on this
one : https://github.com/exercism/problem-specifications/blob/master/exercises/robot-simulator/description.md

  
  

  
I
  tried with all double dispatch but that will be a
  lot of duplicate classes
  

  
  

  

  The problem I cannot solve right is that a robot
  can move or turn. when a robot turns only the
  direction the robot is facing changes and the
  position not. when a robot moves the facing
  direction stays the same but the position changes.
  but the change is dependend on the facing. Also
  the new facing direction is dependend on the old
  facing direction/
  

  
  

  
How
  can I model this the best.
  

  
  

  

  I already have a object Robot that contains the
  facing direction and the current position
  

  
  or tried without it but then I use a lot of if then's
  
  
  so it  there  a better way to model this problem so it
  will be all nice and readable code. 

  
  
  
  If I remember correctly, Richard O'Keefe gave you a
viable design. 1) Use a Point for your direction vector. 2)
Use a second Point for your position.
  
  
  e.g. if you align the compass with a Cartesian plane, 0@1
is North, 0@-1 is South, 1@0 is East, and -1@0 is West. When
you move, you add the direction vector to your current
position. If you allow movements of greater than a single
unit, you multiply the direction vector by the distance
before adding that product to the position.
  
  
  
 
  Roelof
  

  

  


  




Re: [Pharo-users] how to model this a better way

2019-04-18 Thread Roelof Wobben
  
  
oke 
  
  Maybe I understand something not right,
  
  Lets say we have this scenario.
  
  Robot is on position (0,0) 
  now it turns left so the robot faces East 
  
  or this scenario
  
  Robot is on position (0,0) 
  now it turns right so the robot faces west. 
  
  it looks that dictionary cannot provide this answer. 
  or do I overlook something 
  
  Roelof
  
  
  
  Op 18-4-2019 om 19:17 schreef Richard Sargent:


  
  

  On Thu, Apr 18, 2019 at
10:01 AM Roelof Wobben <r.wob...@home.nl> wrote:
  
  

  yep,
I have read that one 
but I never gets a answer how I can "convert"  a point
to something like north, east 

because the challenge wants this to be the answer : 

(Dictionary new
                add: 'direction' -> 'north';
                add:
                    'position'
                        ->
                            (Dictionary new
                                add: 'x' -> 0;
                                add: 'y' -> 0;
                                yourself);
                yourself)
  

  
  
  
  If you have previously defined a "representation map",
you would be golden.
  
  
  e.g.
  Dictionary new
  at: self northDirectionVector put: 'north';
  at: self eastDirectionVector put: 'east';
  at: self southDirectionVector put: 'south';
  at: self westDirectionVector put: 'west';
  yourself.
  
  
  Then:
  
(Dictionary new
                add: 'direction' -> (self
directionRepresentationMap at: self directionVector);
  ...
  
  
  

   

and I think I need then to use if then , which I try to
avoid as much as possible. 

Roelof



Op 18-4-2019 om 18:33 schreef Richard Sargent:
      
  

  
On Thu, Apr 18,
  2019 at 8:57 AM Roelof Wobben <r.wob...@home.nl>
  wrote:


  
Hello,
  
  
  I know I have asked earlier but im still stuck
  on this one : https://github.com/exercism/problem-specifications/blob/master/exercises/robot-simulator/description.md
  


  

  I
tried with all double dispatch but that
will be a lot of duplicate classes

  


  

  
The problem I cannot solve right is that
a robot can move or turn. when a robot
turns only the direction the robot is
facing changes and the position not.
when a robot moves the facing direction
stays the same but the position changes.
but the change is dependend on the
facing. Also the new facing direction is
dependend on the old facing direction/

  


  

  How
can I model this the best.

  


  

  
I already have a object Robot that
contains the facing direction and the
current position

Re: [Pharo-users] how to model this a better way

2019-04-18 Thread Roelof Wobben
Ben,

I have such a dictionary in my first attempt to solve this one.
and another one for the facing.


Lets say we have this scenario:

Robot begins at (0,0) facing north
then it turns right so it faces west
then it moves one step so the new position is (-1,0)
then it turns left so it faces north again
then it moves one step so the  new position is (-1,1)

so if I see it , the position has nothing to do with the direction the 
robot is facing
this is only important for finding out a new direction or  to find out 
if the x or the y needs to change.


Roelof



Op 18-4-2019 om 19:27 schreef Ben Coman:

map := Dictionary newFromPairs: {
 'north'.  0 @  1 .
 'south'.  0 @ -1 .
 'east'.   1 @  0 .
 'west' . -1 @  0 }.
 (map at: 'north') inspect.
 (map keyAtValue: 0 @ -1) inspect






Re: [Pharo-users] how to model this a better way

2019-04-18 Thread Roelof Wobben
  
  
oke, and how must I see those classes
  and elemating the need for a lookup.
  
  it may be explained in pseudo-code.
  
  Roelof
  
  
  
  Op 18-4-2019 om 20:28 schreef Richard Sargent:


  
  On Thu, Apr 18, 2019 at 10:33 AM Roelof Wobben <r.wob...@home.nl>
wrote:

  

  oke


Maybe I understand something not right,

Lets say we have this scenario.

Robot is on position (0,0) 
now it turns left so the robot faces East 
  

  
  
  
  I don't understand what position has to do with direction
nor why that would be a problem. They are two distinct
attributes.
  Point and Dictionary are sufficient classes to model the
limited requirements of this exercise.
  You could model a new class DirectionVector which
internalizes the Point used to provide the direction and
provides its own name, eliminating the need for a look up of
any kind.
  
   
  
  

  

or this scenario

Robot is on position (0,0) 
now it turns right so the robot faces west. 

it looks that dictionary cannot provide this answer. 
or do I overlook something 

Roelof



Op 18-4-2019 om 19:17 schreef Richard Sargent:
  
  

  
On Thu, Apr 18,
  2019 at 10:01 AM Roelof Wobben <r.wob...@home.nl>
  wrote:


  
yep,
  I have read that one 
  but I never gets a answer how I can "convert" 
  a point to something like north, east 
  
  because the challenge wants this to be the
  answer : 
  
  (Dictionary new
                  add: 'direction' ->
  'north';
                  add:
                      'position'
                          ->
                              (Dictionary new
                                  add: 'x' ->
  0;
                                  add: 'y' ->
  0;
                                  yourself);
                  yourself)

  



If you have previously defined a
  "representation map", you would be golden.


e.g.
Dictionary new
at: self northDirectionVector put: 'north';
at: self eastDirectionVector put: 'east';
at: self southDirectionVector put: 'south';
at: self westDirectionVector put: 'west';
yourself.


Then:
 (Dictionary new
                  add: 'direction' -> (self
  directionRepresentationMap at: self
  directionVector);
...



  

  
  
  and I think I need then to use if then , which
  I try to avoid as much as possible. 
  
  Roelof
  
  
  
  Op 18-4-2019 om 18:33 schreef Richard Sargent:

    
      

  On Thu,
Apr 18, 2019 at 8:57 AM Roelof Wobben
<r.wob...@home.nl>
   

Re: [Pharo-users] how to model this a better way

2019-04-19 Thread Roelof Wobben
  
  
yep, 
  
  there are some 14 tests and I do not want to put them all on this
  ML. 
  
  That is why I pointed to the orginal question 
  
  but to give another case. 
  
  the robot can also facing north and turn and facing north and turn
  right or move.
  but it can also be  facing south, turn left or facing south and
  turn right or move.
  and so on 
  
  Roelof
  
  
  
  Op 19-4-2019 om 08:50 schreef Richard Sargent:


  
  You are so right!
  
  Q: now that I've gotten to the bottom of the Grand Canyon and
  found a narrow spot, how do I cross the river?
  
  A: WTF are you doing down there
  
  
  On April 18, 2019 11:41:48 PM PDT, Andres
Valloud  wrote:

  I can't escape the feeling that this answer is leaving a lot on the 
table because the question is asked from a narrow perspective.

On 4/18/19 10:01 , Roelof Wobben wrote:
 because the challenge wants this to be the answer :

 (Dictionary new
 add: 'direction' -> 'north';
 add:
 'position'
 ->
 (Dictionary new
 add: 'x' -> 0;
 add: 'y' -> 0;
 yourself);
 yourself)


  


  




Re: [Pharo-users] how to model this a better way

2019-04-24 Thread Roelof Wobben
Thanks all.

Because of all the differences of oponion here what Object Oriented is 
and im still very stuck at some exercises of exercism , I have to decide 
to quit smalltalk.


One says to not use classes , the other says use classes. im more and 
more confused.


Maybe later I come back when I have a beter understanding what Object 
Oriented is and how I can use it to solve more difficult problems.


Roelof


Op 24-4-2019 om 18:07 schreef Ben Coman:

On Wed, 24 Apr 2019 at 16:52, Richard O'Keefe  wrote:

The one method needed to solve the problem is 18 lines.
The test code, including all available test cases, is 27
lines, of which 18 lines is the test data.  Tests were
needed primarily to sort out what the problem actually *was*;
exercism doesn't even try to provide good specifications.
No debugging time at all was needed, precisely because the
code was so simple and obvious.

But we do want to showcase our debugger and demonstrate how to get the
most out of it.
The way the exercises are structured is to sequentially enable one
test at a time, see how that fails and fix it, so students will be
regularly interacting with debugger.



If it *had* been needed,
viewing the result right next to the expression that yielded
it would have given me all the context I needed, in one window.

If you want to learn how to design a good set of classes,
this is an absolutely dreadful problem.  In fact ALL of the
exercism problems are going to be dreadful for *that*
purpose because they are provided for languages that do not
*have* classes.

Yes, we noticed that.
Do you have any problems more suited to class creation that we might
contribute to the Exercism problem specifications?



If you want to learn how to *solve problems*,
then you need to learn to write code that is simple, clear,
testable, and so on.  You certainly need to learn how to use
what is already there in the language (except where that is
expressly forbidden).

My understanding of the Exercism's purpose is:
* not to teach how to solve programming problems; but
* to facilitate existing programmers to develop fluency in new
languages (although that doesn't preclude complete beginners using
it).
[ref: search "fluency" at
https://opensource.com/article/17/1/interview-katrina-owen-founder-exercism]



I completely agree that designing a good set of classes is
a very very important skill for anyone who wants to do OOP.
I completely agree that practising this on problems you can
hold in your head is a good idea.
I completely agree that if *that* is your objective,
writing minimalist code is not the best strategy.
On Wed, 24 Apr 2019 at 16:59, Richard O'Keefe  wrote:

TL;DR version:
   "But if the purpose of problems is to lead students in new ways of
thinking about structuring OO solutions for maintainability"
It would be very good
if somebody did craft such a set of exercises, and Pharo would be a very
good environment for them.  The exercism exercises will not do.

If the existing set of exercises is not great for this, hopefully we
can produce some to demonstrate Pharo's facility for it.



The problem with exercism is that while it does have a
criterion by which you can tell whether you have *solved the
problem*, it provides *no* way to assess your class design.
You don't get told "this is good, that is bloated"; there is
no feedback about the *quality* of your code except via
comments from those few people who can be bothered to look
at other people's solutions and comment on them.  And since
many of them will also be beginners, their comments may not
always help.

Hopefully we can grow participation of experienced mentors
to share the load providing *quality* feedback to distinguish the
benefits of Pharo.


This particular problem is very similar to a "Langton's Ant"
problem my old department gave to students, who were expected
to solve it in two or three hours.  And ALWAYS, the thing that
held them back was creating classes they didn't need and
agonising over what data and methods should go where (and then
getting it wrong, such is the nature of Java).

My immediate reaction to that is that  agonizing  and  getting it wrong
are a useful part of the learning process, but I recognize I could
just be being contrary :) .
I'll keep your observations in mind.


When a problem can be solved quite directly in 18 lines of
clean code, you are going to have a very hard time persuading
me that even one more class pays for itself, especially in a
system with a rich class library of stuff you don't have to write.

Not trying to persuade you personally.
Just providing an alternative viewpoint for anyone to consider.

cheers -ben







Re: [Pharo-users] how to model this a better way

2019-04-24 Thread Roelof Wobben
  
  
Hello Ricard O'  Keefe 
  
  For my exercism is a way of practising smalltalk and get familair
  with the concepts. 
  So sometimes for me totally new concepts like Double Dispatch.  so
  in your questions some of the thirth and fourth question. And I
  try to solve the challenges like there are real world problems. 
  
  Because Tim like to push me further then sometimes the challenges
  needed so I learn new concepts or practice things I already
  learned. 
  
  I agree totally with you that I always look if existing classes
  can do the job before I write my own objects.
  
  The problem that I faced is that I not always see which objects I
  need and what the responsibility is. 
  
  Right now my thoughts are this : 
  
  RobotTests  they contain all the tests. 
  Robot . Responsibility for keeping track of what the position is
  and which direction it faces. 
  Direction. Responsibility for calculating a new position or a new
  direction the robot faces. 
  
  Thanks for you suggestion to solve it first in a language that im
  familiar with but I not so familiair with a langugae I can solve
  "all"  the problems.  Because smalltalk is OO  I sometimes look at
  ruby code to see how they solve things. 
  
  Roelof
  
  
  
  
  
  Op 25-4-2019 om 06:23 schreef Richard O'Keefe:


  
  
PS: in this thread
  nobody has disagreed about what OO programming is.
The disagreement was
  about *how to apply it*.
There actually seems
  to be quite a lot of agreement that the
answer depends on what
  your underlying goal is:
 - is this throw-away
  code for a specific problem?
 - is this code to be
  included in a useful program?
 - is this just for
  practice in an unfamiliar language
   where you already
  understand all the concepts?
 - is this for
  learning about radically new concepts?
And everyone agrees
  that test cases are good for all of these.


You might find it
  useful to join another exercism thread and
solve some of these
  problems in a language that you are
comfortable with, then
  solve them in Smalltalk (or Ruby).
This will help to
  separate "how do I solve this problem?"
from "how do I express
  this solution in language X?"
Another thing you
  might find useful, having solved a
problem, is to try to
  solve it a different way.


For example, in a
  functional language, you might solve a
problem first in a
  C-like way using mutable objects freely.
Then you might solve
  it again using immutable values.
And then you might
  solve it again using higher-order functions.
And then you might
  solve it again using point-free style as
much as you can.


For another example,
  in R, or Fortran 90, or Matlab, you
might solve a problem
  first in an element-at-a-time way,
and then you might try
  it again using vectorisation to
eliminate as many
  loops as you can.


And in *this* example,
  don't suppose that there is One Right
Way To Do It.  Get ONE
  solution going.  ANY solution.  I would
suggest my approach,
  because (a) of course I would, and (b) it
really is a struggle
  with exercism to find out what the problem
actually is, and you
  want to get to SOME solution quickly.  But
it doesn't matter so
  much, because the point is to try it MORE
ways than one.  This
  is one way to learn design.  Try more than
one approach and
  discover which ones work out better.


I started out using
  Point.  Then I tried again just using bare
coordinates.  I
  started with position and velocity as instance
variables.  Then I
  tried again with them as method temporaries.
I eliminated one thing
  after another until I was left with
obviously correct
  code, and I felt no shame in using
#caseOf: to classify
  characters, even though there are books
that will tell you
  that using "if" and "case" is anti-OO.
I could do it again
  eliminating #caseOf: in terms of "if" if

I saw any value in
  doing so.



  In this particular exercise, you are
simulating
  ONE instance (the robot) of ONE kind
of thing (Robots)

[Pharo-users] upload a stack trace with playground

2019-05-15 Thread Roelof Wobben
Hello,

I tried to upload a stack trace with playground  with upload to cloud 
but I see then a 400 bad request error message.

I was a file of 3Kb.

Is there a alternative so I can upload a stack trace.

Roelof




[Pharo-users] can I do this with a stream or a format

2019-05-16 Thread Roelof Wobben
  
  
Hello, 

Im testing all my solutions with critiz and can solve almost all
problems,

Only this one I cannot figure out. 

I have this code
(gifts allButLast
inject: ''
into: [ :str :each | str , each , ', ' ]) , 'and ' , gifts last ]

and critiz says I should use a stream .

How can I make this work ? 

Roelof


  




Re: [Pharo-users] can I do this with a stream or a format

2019-05-16 Thread Roelof Wobben
  
  
oke, and then do something like : 
  
  stream := 
  String streamContents: [:stream |
  gifts 
do: [:each | stream nextPutAll: each ]
separatedBy: [ stream nextPut: $,; space ]
]

stream nextputAll: 'all' 
stream nextPut: ','
stream nextPut: gifts last


Roelof

  
  
  Op 16-5-2019 om 21:30 schreef Esteban Maringolo:


  
  

  Maybe this is a better way to build what you want.
  String streamContents: [:stream |
  gifts 
do: [:each | stream nextPutAll: each ]
separatedBy: [ stream nextPut: $,; space ]
]
  



  Esteban A. Maringolo


  
  
  
On Thu, May 16, 2019 at 4:21
  PM Roelof Wobben <r.wob...@home.nl> wrote:


   Hello, 

Im testing all my solutions with critiz and can solve almost
all problems,

Only this one I cannot figure out. 

I have this code
(gifts allButLast
inject: ''
into: [ :str :each | str , each , ', ' ]) , 'and ' , gifts last ]

and critiz says I should use a stream .

How can I make this work ? 

Roelof


  

  


  




Re: [Pharo-users] can I do this with a stream or a format

2019-05-16 Thread Roelof Wobben
  
  
I think this is better 

 ^  String streamContents: [:stream |
  
   gifts 
do: [:each | stream nextPutAll: each ]
separatedBy: [ stream nextPut: $,; space ]
  stream nextputAll: 'all'; nextPut: ','; nextPut: gifts last] 

  
  
  Op 16-5-2019 om 21:47 schreef Roelof Wobben:


  
  oke, and then do something like : 

stream := 
String streamContents: [:stream |
  gifts 
do: [:each | stream nextPutAll: each ]
separatedBy: [ stream nextPut: $,; space ]
  

  
stream nextputAll: 'all'; nextPut: ','; nextPut: gifts last

  

]

stream nextputAll: 'all' 
stream nextPut: ','
stream nextPut: gifts last


Roelof



Op 16-5-2019 om 21:30 schreef Esteban Maringolo:
  
  


  
Maybe this is a better way to build what you want.
String streamContents: [:stream |
  gifts 
do: [:each | stream nextPutAll: each ]
separatedBy: [ stream nextPut: $,; space ]
]


  
  
Esteban A. Maringolo
  
  


    
      On Thu, May 16, 2019 at 4:21
PM Roelof Wobben <r.wob...@home.nl> wrote:
  
  
 Hello, 
  
  Im testing all my solutions with critiz and can solve
  almost all problems,
  
  Only this one I cannot figure out. 
  
  I have this code
  (gifts allButLast
inject: ''
into: [ :str :each | str , each , ', ' ]) , 'and ' , gifts last ]

and critiz says I should use a stream .

How can I make this work ? 

Roelof



  

  
  


  




Re: [Pharo-users] can I do this with a stream or a format

2019-05-16 Thread Roelof Wobben
  
  
nope, it takes also the last one and
  that schould not be used. 
  
  
  Op 16-5-2019 om 21:51 schreef Roelof Wobben:


  
  I think this is better 
  
   ^  String streamContents: [:stream | 
 gifts 
do: [:each | stream nextPutAll: each ]
separatedBy: [ stream nextPut: $,; space ]
  stream nextputAll: 'all'; nextPut: ','; nextPut: gifts last] 



Op 16-5-2019 om 21:47 schreef Roelof Wobben:
  
  

oke, and then do something like : 
  
  stream := 
  String streamContents: [:stream |
  gifts 
do: [:each | stream nextPutAll: each ]
separatedBy: [ stream nextPut: $,; space ]

  
    
  stream nextputAll: 'all'; nextPut: ','; nextPut: gifts last
  

  ]

stream nextputAll: 'all' 
stream nextPut: ','
stream nextPut: gifts last


Roelof

  
  
  Op 16-5-2019 om 21:30 schreef Esteban Maringolo:


  
  

  Maybe this is a better way to build what you want.
  String streamContents: [:stream |
  gifts 
do: [:each | stream nextPutAll: each ]
separatedBy: [ stream nextPut: $,; space ]
]
  



  Esteban A. Maringolo


  
  
  
    On Thu, May 16, 2019 at
  4:21 PM Roelof Wobben <r.wob...@home.nl>
  wrote:


   Hello, 

Im testing all my solutions with critiz and can solve
almost all problems,

Only this one I cannot figure out. 

I have this code
(gifts allButLast
inject: ''
into: [ :str :each | str , each , ', ' ]) , 'and ' , gifts last ]

and critiz says I should use a stream .

How can I make this work ? 

Roelof


  

  


  
  


  




Re: [Pharo-users] can I do this with a stream or a format

2019-05-16 Thread Roelof Wobben
  
  
and this is working 
  
  String
                  streamContents: [ :stream | 
                      gifts allButLast
                          do: [ :each | stream nextPutAll: each ]
                          separatedBy: [ stream
                                  nextPut: $,;
                                  space ].
                      stream
                          nextPut: $,;
                          nextPutAll: ' and ';
                          nextPutAll: gifts last ] ]
  
  Thanks Estaban for the hint. 
  
  Roelof
  
  
  
  Op 16-5-2019 om 21:51 schreef Roelof Wobben:


  
  I think this is better 
  
   ^  String streamContents: [:stream | 
 gifts 
do: [:each | stream nextPutAll: each ]
separatedBy: [ stream nextPut: $,; space ]
  stream nextputAll: 'all'; nextPut: ','; nextPut: gifts last] 



Op 16-5-2019 om 21:47 schreef Roelof Wobben:
  
  

oke, and then do something like : 
  
  stream := 
  String streamContents: [:stream |
  gifts 
do: [:each | stream nextPutAll: each ]
separatedBy: [ stream nextPut: $,; space ]

  
    
  stream nextputAll: 'all'; nextPut: ','; nextPut: gifts last
  

  ]

stream nextputAll: 'all' 
stream nextPut: ','
stream nextPut: gifts last


Roelof

  
  
  Op 16-5-2019 om 21:30 schreef Esteban Maringolo:


  
  

  Maybe this is a better way to build what you want.
  String streamContents: [:stream |
  gifts 
do: [:each | stream nextPutAll: each ]
separatedBy: [ stream nextPut: $,; space ]
]
  



  Esteban A. Maringolo


  
  
  
    On Thu, May 16, 2019 at
  4:21 PM Roelof Wobben <r.wob...@home.nl>
  wrote:


   Hello, 

Im testing all my solutions with critiz and can solve
almost all problems,

Only this one I cannot figure out. 

I have this code
(gifts allButLast
inject: ''
into: [ :str :each | str , each , ', ' ]) , 'and ' , gifts last ]

and critiz says I should use a stream .

How can I make this work ? 

Roelof


  

  


  
  


  




Re: [Pharo-users] can I do this with a stream or a format

2019-05-16 Thread Roelof Wobben
  
  
I made the error somehow. 
  Sorry for the confusion.
  
  Roelof
  
  
  Op 16-5-2019 om 22:29 schreef Esteban Maringolo:


  
  Oh... the expected output was 'e1, e2, e3 and e4',
I read "all" instead of "and".


Now it makes sense.



  

  Esteban A. Maringolo


  

  
  
  
On Thu, May 16, 2019 at 5:09
  PM Roelof Wobben <r.wob...@home.nl> wrote:


  
and
  this is working 
  
  String
                  streamContents: [ :stream | 
                      gifts allButLast
                          do: [ :each | stream nextPutAll:
  each ]
                          separatedBy: [ stream
                                  nextPut: $,;
                                  space ].
                      stream
                          nextPut: $,;
                          nextPutAll: ' and ';
                          nextPutAll: gifts last ] ]
  
  Thanks Estaban for the hint. 
  
  Roelof
  
  
  
      Op 16-5-2019 om 21:51 schreef Roelof Wobben:


  I
think this is better 
  
   ^  String streamContents: [:stream | 
 gifts 
do: [:each | stream nextPutAll: each ]
separatedBy: [ stream nextPut: $,; space ]
  stream nextputAll: 'all'; nextPut: ','; nextPut: gifts last] 

    
        
Op 16-5-2019 om 21:47 schreef Roelof Wobben:
  
  
oke,
  and then do something like : 
  
  stream := 
  String streamContents: [:stream |
  gifts 
do: [:each | stream nextPutAll: each ]
separatedBy: [ stream nextPut: $,; space ]

  
    
  stream nextputAll: 'all'; nextPut: ','; nextPut: gifts last
  

  ]

stream nextputAll: 'all' 
stream nextPut: ','
stream nextPut: gifts last


Roelof

  
  
  Op 16-5-2019 om 21:30 schreef Esteban Maringolo:


  

  Maybe this is a better way to build what you want.
  String streamContents: [:stream |
  gifts 
do: [:each | stream nextPutAll: each ]
separatedBy: [ stream nextPut: $,; space ]
]
  



  Esteban
A. Maringolo


  
      
  
On Thu, May 16,
  2019 at 4:21 PM Roelof Wobben <r.wob...@home.nl>
  wrote:


   Hello, 

Im testing all my solutions with critiz and can
solve almost all problems,

Only this one I cannot figure out. 

I have this code
(gifts allButLast
inject: ''
into: [ :str :each | str , each , ', ' ]) , 'and ' , gifts last ]

and critiz says I should use a stream .

How can I make this work ? 

Roelof


  

  


  
  


  

  


  




[Pharo-users] Why do I not see the transactions when opening a customer

2019-08-16 Thread Roelof Wobben
  
  
Hello, 

I try now to make this challege work on Pharo which is orginal a c#
problem to practice OOP.

The challenge is this : 

Consider the following situation:
You have a bank account. Bank account has a password which is hidden and you can access data within bank 
account only by providing the right credentials.
Bank acount has a whole bunch of transaction history. 
Transaction is basically a record with name, description, amount (either positive or negative) 
and specific account linked to it (your bank accounts can have multiple accounts for money). 

You need to: ask each user for credentials and output how much money do they have in each bank account.

Classes: Customer, Transaction, BankAccount.

So far I have this : https://github.com/rwobben/bankaccount

but when I do this on playground:

customer := Customer new. 
bankAccount := Bankaccounts new.
bankAccount password: 'secret'.
customer AddBankAccountToCustomer: bankAccount.

transaction = Transactions new. 
bankAccount addToBankAccount:  transaction.

customer. 


and I inspect the customer I do not see the transaction addded to the bankaccounts collection. 

What do I do wrong ? 

Roelof
 



  




  1   2   3   4   >