Re: [Pharo-users] Hi Community

2019-12-28 Thread Sven Van Caekenberghe
Nice indeed, well done.

> On 28 Dec 2019, at 04:28, Ben Coman  wrote:
> 
> Looks cool. Thanks for sharing.
> 
> cheers -ben
> 
> On Sat, 28 Dec 2019 at 09:55, Pablo Navarro  wrote:
> Hi everyone, my name's Pablo and I'm from Argentina. I'm taking my first 
> steps in Pharo and created this tool (https://github.com/pablo1n7/Smallbook) 
> to share with my colleagues and show them the power of Pharo.
> 
> It's a simple library to create slide presentations and show them in a web 
> browser. 
> 
> I used Zinc HTTP for the server, JS for the presentation controls and CSS for 
> the styles.
> 
> It's not 100% complete, I'm still working on it. I hope you find it useful 
> and any suggestion is welcomed
> 
> 
> Best Regards, Pablo.




Re: [Pharo-users] uses or instead of a searching literal

2019-12-28 Thread Kasper Østerbye
Are you aware of the ‘finder’ tool?, in particular the ‘examples' mode is
useful.

try: ‘aaa_bbb-ccc’. ‘_-‘. #(‘aaa’ ‘bbb’ ‘ccc’)


Best,

Kasper

On 28 December 2019 at 08.12.03, Roelof Wobben via Pharo-users (
pharo-users@lists.pharo.org) wrote:

Op 27-12-2019 om 23:33 schreef Richard O'Keefe:
> aString splitOn: ' -_' asSet

Hello Richard,

Thanks again , I find this  "aString splitOn: '_- `  asSet "   much
cleaner but on some way I does not  split for example  'Portable Network
Graphics' into  " #(Portable, Network, Graphics) ".  When I debug  it ,
it seems there is no splitting at all.

So today time to dive into it why it does not work and how to solve it.

Roelof


Re: [Pharo-users] uses or instead of a searching literal

2019-12-28 Thread Roelof Wobben via Pharo-users
--- Begin Message ---

  
  
yep. Im aware of this tool but on this
  case nothing pops up.
  
  Roelof
  
  
  
  
  Op 28-12-2019 om 09:22 schreef Kasper Østerbye:


  
  
  Are you
aware of the ‘finder’ tool?, in particular the ‘examples' mode
is useful.
  
  
  try:
‘aaa_bbb-ccc’. ‘_-‘. #(‘aaa’ ‘bbb’ ‘ccc’) 
  
  
  
  
  Best,
  
  
  Kasper

On 28 December 2019 at 08.12.03, Roelof
  Wobben via Pharo-users (pharo-users@lists.pharo.org)
  wrote:


  
Op 27-12-2019 om 23:33 schreef Richard O'Keefe:
  
  > aString splitOn: ' -_' asSet
  
  
  Hello Richard,
  
  
  Thanks again , I find this  "aString splitOn: '_- ` 
  asSet "   much 
  cleaner but on some way I does not  split for example 
  'Portable Network 
  Graphics' into  " #(Portable, Network, Graphics) ". 
  When I debug  it , 
  it seems there is no splitting at all.
  
  
  So today time to dive into it why it does not work and
  how to solve it.
  
  
  Roelof
  
  
  

  

  
  


  


--- End Message ---


Re: [Pharo-users] uses or instead of a searching literal

2019-12-28 Thread Sven Van Caekenberghe
I would go for 

  'Portable Network Graphics' findTokens: ' -_'.

> On 28 Dec 2019, at 09:35, Roelof Wobben via Pharo-users 
>  wrote:
> 
> 
> From: Roelof Wobben 
> Subject: Re: [Pharo-users] uses or instead of a searching literal
> Date: 28 December 2019 at 09:35:17 GMT+1
> To: pharo-users@lists.pharo.org
> 
> 
> yep. Im aware of this tool but on this case nothing pops up.
> 
> Roelof
> 
> 
> 
> 
> Op 28-12-2019 om 09:22 schreef Kasper Østerbye:
>> Are you aware of the ‘finder’ tool?, in particular the ‘examples' mode is 
>> useful.
>> 
>> try: ‘aaa_bbb-ccc’. ‘_-‘. #(‘aaa’ ‘bbb’ ‘ccc’) 
>> 
>> 
>> Best,
>> 
>> Kasper
>> 
>> On 28 December 2019 at 08.12.03, Roelof Wobben via Pharo-users 
>> (pharo-users@lists.pharo.org) wrote:
>> 
>>> Op 27-12-2019 om 23:33 schreef Richard O'Keefe: 
>>> > aString splitOn: ' -_' asSet 
>>> 
>>> Hello Richard, 
>>> 
>>> Thanks again , I find this  "aString splitOn: '_- `  asSet "   much 
>>> cleaner but on some way I does not  split for example  'Portable Network 
>>> Graphics' into  " #(Portable, Network, Graphics) ".  When I debug  it , 
>>> it seems there is no splitting at all. 
>>> 
>>> So today time to dive into it why it does not work and how to solve it. 
>>> 
>>> Roelof 
>>> 
>>> 
> 
> 
> 




Re: [Pharo-users] can I write this without the three if then;s

2019-12-28 Thread Dennis Schetinin
It would be an overkill to do it for this particular case, but Smalltalk
makes it possible to implement a case-like construction:

[ expression ]
 when: [ :value | condition1 ] do: [-0do :value | ... ];
 when: [ :value | condition2 ] do: [ :value | ... ];
 otherwiseDo: [ :value | ... ];
 evaluate


I am sure, something like this has been implemented already somewhere
(maybe in Squeak?). Still not sure it is practical as compared to simple
if-s, and for sure not widely used :)
...On the other hand, sometimes the case-like construction can be
considered a more intension-revealing style.

пт, 27 дек. 2019 г., 22:18 Roelof Wobben via Pharo-users <
pharo-users@lists.pharo.org>:

> Hello,
>
> Im trying to solve a challenge from exercism where  I have to calculate
> the points somehow gets on a very simple darts board.
>
> I solved it like this :
>
>
> scoreX: anInteger y: anInteger2
> | distance |
> distance := (anInteger squared + anInteger2 squared) sqrt.
> distance > 10
> ifTrue: [ ^ 0 ].
> distance > 5
> ifTrue: [ ^ 1 ].
> distance > 1
> ifTrue: [ ^ 5 ].
> ^ 10
>
>
> but now I use three if then and I think it's ugly code.
>
> Is there a way I can make it more the smalltalk way ?
>
>
> Regards,
>
> Roelof
>
>


Re: [Pharo-users] Hi Community

2019-12-28 Thread Norbert Hartl
Hi Pablo,

welcome and great tool. If you extend it you could could consider using pillar 
document model (https://github.com/pillar-markup/pillar) 

Norbert

> Am 27.12.2019 um 23:55 schrieb Pablo Navarro :
> 
> 
> Hi everyone, my name's Pablo and I'm from Argentina. I'm taking my first 
> steps in Pharo and created this tool (https://github.com/pablo1n7/Smallbook) 
> to share with my colleagues and show them the power of Pharo.
> 
> It's a simple library to create slide presentations and show them in a web 
> browser. 
> 
> I used Zinc HTTP for the server, JS for the presentation controls and CSS for 
> the styles.
> 
> It's not 100% complete, I'm still working on it. I hope you find it useful 
> and any suggestion is welcomed
> 
> 
> Best Regards, Pablo.


Re: [Pharo-users] uses or instead of a searching literal

2019-12-28 Thread Roelof Wobben via Pharo-users
--- Begin Message ---

Hello  Sven,

Thanks. this is what im looking for.

Roelof





Op 28-12-2019 om 10:46 schreef Sven Van Caekenberghe:

I would go for

   'Portable Network Graphics' findTokens: ' -_'.


On 28 Dec 2019, at 09:35, Roelof Wobben via Pharo-users 
 wrote:


From: Roelof Wobben 
Subject: Re: [Pharo-users] uses or instead of a searching literal
Date: 28 December 2019 at 09:35:17 GMT+1
To: pharo-users@lists.pharo.org


yep. Im aware of this tool but on this case nothing pops up.

Roelof




Op 28-12-2019 om 09:22 schreef Kasper Østerbye:

Are you aware of the ‘finder’ tool?, in particular the ‘examples' mode is 
useful.

try: ‘aaa_bbb-ccc’. ‘_-‘. #(‘aaa’ ‘bbb’ ‘ccc’)


Best,

Kasper

On 28 December 2019 at 08.12.03, Roelof Wobben via Pharo-users 
(pharo-users@lists.pharo.org) wrote:


Op 27-12-2019 om 23:33 schreef Richard O'Keefe:

aString splitOn: ' -_' asSet

Hello Richard,

Thanks again , I find this  "aString splitOn: '_- `  asSet "   much
cleaner but on some way I does not  split for example  'Portable Network
Graphics' into  " #(Portable, Network, Graphics) ".  When I debug  it ,
it seems there is no splitting at all.

So today time to dive into it why it does not work and how to solve it.

Roelof










--- End Message ---


Re: [Pharo-users] Hi Community

2019-12-28 Thread Pablo Navarro
Thanks for the comments. I'll check Pillar.



Best Regards, Pablo.
El 28 de dic. de 2019 08:10 -0300, Norbert Hartl , escribió:
> Hi Pablo,
>
> welcome and great tool. If you extend it you could could consider using 
> pillar document model (https://github.com/pillar-markup/pillar)
>
> Norbert
>
> > Am 27.12.2019 um 23:55 schrieb Pablo Navarro :
> >
> > Hi everyone, my name's Pablo and I'm from Argentina. I'm taking my first 
> > steps in Pharo and created this tool 
> > (https://github.com/pablo1n7/Smallbook) to share with my colleagues and 
> > show them the power of Pharo.
> >
> > It's a simple library to create slide presentations and show them in a web 
> > browser.
> >
> > I used Zinc HTTP for the server, JS for the presentation controls and CSS 
> > for the styles.
> >
> > It's not 100% complete, I'm still working on it. I hope you find it useful 
> > and any suggestion is welcomed
> >
> >
> > Best Regards, Pablo.


[Pharo-users] how to change data on real data but not on test data

2019-12-28 Thread Roelof Wobben via Pharo-users
--- Begin Message ---

  
  

  I have this code so solve a
challenge of Advent Of Code :
process: anArray
| op |
ram := (anArray splitOn: ',') collect: [ :ea | ea asInteger ].
in := ReadStream on: ram.
[ (op := in next) = 99 ] whileFalse: [ self processOpcode: op ].
^ self at: 0
  


  

  
that works fine for the given
  tests
  

  


  

  
but on the real data I have to
  change 2 numbers
  

  


  

  
so I can do :
   
process: anArray
| op |
ram := (anArray splitOn: ',') collect: [ :ea | ea asInteger ].
self  put: 2  at: 3. 
 in := ReadStream on: ram.
[ (op := in next) = 99 ] whileFalse: [ self processOpcode: op ].
^ self at: 0

  

  


  

  
but that breaks all the tests
  

  


  

  
is there a way I can make it
  work for the tests and for the real data without breaking
  anything ?
  
  so to be clear. In the test are data given which not has
  to be changed. As soon as you have to solve the real
  problem , some data needs to be changed. 
  

  

  


  Roelof

  

  


--- End Message ---


Re: [Pharo-users] how to change data on real data but not on test data

2019-12-28 Thread Sean P. DeNigris
Pharo Smalltalk Users mailing list wrote
> so to be clear. In the test are data given which not has to be changed. As
> soon as you have to solve the real problem , some data needs to be
> changed. 

It's difficult to give good design advice with such a partial picture of the
domain, but two straightforward solutions might be:
1. self isDeploymentMode ifTrue: [ "change data" ]
2. or, self sanitizationStrategy: (NoSanitization | ProductionSanitization)



-
Cheers,
Sean
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html



Re: [Pharo-users] how to change data on real data but not on test data

2019-12-28 Thread Roelof Wobben via Pharo-users
--- Begin Message ---

  
  
Oke 
  
  Maybe it is better to give the whole challenge 
  
  On the way to your gravity
  assist around the Moon, your ship computer beeps angrily
about a "1202
  program alarm". On the radio, an Elf is already explaining
how to handle the situation: "Don't worry, that's perfectly
norma--" The ship computer bursts
  into flames.
  You notify the Elves that the computer's magic smoke
seems to have escaped. "That computer
ran Intcode programs like the gravity assist program
it was working on; surely there are enough spare parts up there
to build a new Intcode computer!"
  An Intcode program is a list of integers
separated by commas (like 1,0,0,3,99). To run one,
start by looking at the first integer (called position 0).
Here, you will find an opcode - either 1,
2, or 99. The opcode indicates what
to do; for example, 99 means that the program is
finished and should immediately halt. Encountering an unknown
opcode means something went wrong.
  Opcode 1 adds together numbers read
from two positions and stores the result in a third position.
The three integers immediately after the opcode tell
you these three positions - the first two indicate the positions
from which you should read the input values, and the third
indicates the position at which the output should be
stored.
  For example, if your Intcode computer encounters 1,10,20,30,
it should read the values at positions 10 and 20,
add those values, and then overwrite the value at position 30
with their sum.
  Opcode 2 works exactly like opcode 1,
except it multiplies the two inputs instead of adding
them. Again, the three integers after the opcode indicate where
the inputs and outputs are, not their values.
  Once you're done processing an opcode, move to the next
  one by stepping forward 4 positions.
  For example, suppose you have the following program:
  1,9,10,3,2,3,11,0,99,30,40,50
  For the purposes of illustration, here is the same program
split into multiple lines:
  1,9,10,3,
2,3,11,0,
99,
30,40,50

  The first four integers, 1,9,10,3, are at
positions 0, 1, 2, and
3. Together, they represent the first opcode (1,
addition), the positions of the two inputs (9 and 10),
and the position of the output (3). To handle this
opcode, you first need to get the values at the input positions:
position 9 contains 30, and position
10 contains 40. Add these
numbers together to get 70. Then, store this value
at the output position; here, the output position (3)
is at position 3, so it overwrites
itself. Afterward, the program looks like this:
  1,9,10,70,
2,3,11,0,
99,
30,40,50

  Step forward 4 positions to reach the next
opcode, 2. This opcode works just like the
previous, but it multiplies instead of adding. The inputs are at
positions 3 and 11; these positions
contain 70 and 50 respectively.
Multiplying these produces 3500; this is stored at
position 0:
  3500,9,10,70,
2,3,11,0,
99,
30,40,50

  Stepping forward 4 more positions arrives at
opcode 99, halting the program.
  Here are the initial and final states of a few more small
programs:
  
1,0,0,0,99 becomes 2,0,0,0,99
  (1 + 1 = 2).
2,3,0,3,99 becomes 2,3,0,6,99
  (3 * 2 = 6).
2,4,4,5,99,0 becomes 2,4,4,5,99,9801
  (99 * 99 = 9801).
1,1,1,4,99,5,6,0,99 becomes 30,1,1,4,2,5,6,0,99.
  
  Once you have a working computer, the first step is to restore
the gravity assist program (your puzzle input) to the "1202
program alarm" state it had just before the last computer caught
fire. To do this, before running the program, replace
position 1 with the value 12 and
replace position 2 with the value 2.
What value is left at position 0 after
the program halts?
  
  
  so as you can see in the tests there are no data changed so my
code works fine and all the tests are green but when you want to
work with the real data  the say that you have to replace two
values. 
  
  So my question is how to make that part work without breaking
the tests. 
  
  Roelof
  
  
  
  
  
  Op 28-12-2019 om 21:46 schreef Sean P. DeNigris:


  Pharo Smalltalk Users mailing list wrote

  
so to be clear. In the test are data given which not has to be changed. As
soon as you have to solve the real problem , some data needs to be
changed. 

  
  
It's difficult to give good design advice with such a par