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

2019-12-27 Thread Roelof Wobben via Pharo-users
--- Begin Message --- 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, Netwo

Re: [Pharo-users] Hi Community

2019-12-27 Thread Ben Coman
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

[Pharo-users] Hi Community

2019-12-27 Thread 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.

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

2019-12-27 Thread Richard O'Keefe
You know, this is an area where style opinions differ a lot. What the message is suggesting you try is aString splitOn: [:each | ' -_' includes: each] That's all. No need for anything more complicated. But there is a trade-off. Clarity vs efficiency. You should make your code clear and correct

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

2019-12-27 Thread Roelof Wobben via Pharo-users
--- Begin Message --- Hello Richard, Thanks for the feedback. I was using it because the challenge was talking about it, that yu have the use the formula a ^2  +  b ^2  =  c ^2   and the challenge was talking about the distance and not the distance squared. I think a better name schould be th

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

2019-12-27 Thread Richard O'Keefe
Myself, I see only one issue in your code, and that is the pointless use of sqrt. scoreX: anInteger y: anInteger2 | radiusSquared | radiusSquared := anInteger squared + anInteger2 squared. radiusSquared > 100 ifTrue: [ ^ 0 ]. radiusSquared > 25 ifTrue: [ ^ 1 ]. r

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

2019-12-27 Thread tbrunz
Since you're splitting a String, why not use a Regex to do this? -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html

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

2019-12-27 Thread Roelof Wobben via Pharo-users
--- Begin Message --- Hello, How can I get rid of the above error message with this code : abbreviatePhrase: aString | splitted | splitted := aString splitOn: [ :char | char = Character space or: [ char = $- or: [ char = $_ ] ] ]. ^ Strin

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

2019-12-27 Thread tbrunz
You could also accomplish this with a simple 'do:' construct by creating the associations with the the ring limits & points "staggered" (by one level), so that when (each < key) you can return the 'current' association value... Which, now that I'm looking closely at your solution, Kasper, seems to

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

2019-12-27 Thread tbrunz
Doing it the way I describe above eliminates repetitive if-then statements ('switch' or 'case' statements in other languages, which make for a maintenance mess), automatically extends for additional rings, doesn't embed "magic numbers" for defined rings within the decision logic, and takes advantag

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

2019-12-27 Thread tbrunz
I would probably set up an array of associations whose keys are the boundary limits and whose values are the target values (ordered, in this example, from outer to inner). Then loop over the array's associations using inject:into:, testing for the point where (each < key), at which point you ret

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

2019-12-27 Thread Roelof Wobben via Pharo-users
--- Begin Message --- Hello Kasper Thanks for the feedback. I also like readable and  easy to understand code but I get the feeling that it;s good practice to use as minimal as possible if then's So I wonder if and how I can achieve that here.

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

2019-12-27 Thread Kasper Østerbye
Hi First, I think your code is readable and easy to understand. I think the problem does not lend itself too much towards having “an object oriented solution”, as such. If you are looking for a one-liner using smalltalk libraries, you could do: ({10 -> 0. 5 -> 1. 1 -> 5. 0 -> 10} detect: [ :dist

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

2019-12-27 Thread Roelof Wobben via Pharo-users
--- Begin Message --- Thanks, But it looks to me I still need the ifTrue because the between gives also a true or false. Roelof Op 27-12-2019 om 20:38 schreef tbrunz: You might try Magnitude >> between: min and: max -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.htm

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

2019-12-27 Thread tbrunz
You might try Magnitude >> between: min and: max -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html

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

2019-12-27 Thread Roelof Wobben via Pharo-users
--- Begin Message --- 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 |     di