What do you think of this in core? Like a mini Aconcagua ;) Number>>#percent "e.g. 20 / 40 = 50 percent" ^ self / 100.0 ----- Cheers, Sean -- View this message in context: http://forum.world.st/Number-percent-tp4805988.html Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
I will add something like Number>>percent ^Percentage of: self And Percentage value should be The number / 100, the printOn: can show the % sign, something like '50 %'. Obviously this must behave exactly as a number. This allows to be extended in case something specific is needed for percentages. (I can use it in RenoirSt and remove one of the extensions I have) Too bad % is used as a binary selector :( . Writing 32 % is a lot better On Feb 16, 2015 1:37 PM, "Sean P. DeNigris" <sean@clipperadams.com> wrote:
What do you think of this in core? Like a mini Aconcagua ;) Number>>#percent "e.g. 20 / 40 = 50 percent" ^ self / 100.0
----- Cheers, Sean -- View this message in context: http://forum.world.st/Number-percent-tp4805988.html Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
Sean, but if you need something like that, why wouldn't you load aconcagua? I'm just in the crusade of putting less in the kernel by default ^^. El Mon Feb 16 2015 at 5:54:11 PM, Gabriel Cotelli <g.cotelli@gmail.com> escribió:
I will add something like Number>>percent ^Percentage of: self
And Percentage value should be The number / 100, the printOn: can show the % sign, something like '50 %'. Obviously this must behave exactly as a number. This allows to be extended in case something specific is needed for percentages. (I can use it in RenoirSt and remove one of the extensions I have)
Too bad % is used as a binary selector :( . Writing 32 % is a lot better On Feb 16, 2015 1:37 PM, "Sean P. DeNigris" <sean@clipperadams.com> wrote:
What do you think of this in core? Like a mini Aconcagua ;) Number>>#percent "e.g. 20 / 40 = 50 percent" ^ self / 100.0
----- Cheers, Sean -- View this message in context: http://forum.world.st/Number-percent-tp4805988.html Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
Guillermo Polito wrote
Sean, but if you need something like that, why wouldn't you load aconcagua?
I'm just in the crusade of putting less in the kernel by default ^^.
Good question! The little project I was working on when I implemented that method /was/ using Aconcagua! But: 1. This is a simple, common conversion which a. could make the kernel itself a bit more intention revealing Job>>#progress ^ min >= max ifTrue: [ 1 ] ifFalse: [ (currentValue - min) / (max - min) ] could become: ^ min >= max ifTrue: [ 100 percent ] ifFalse: [ (currentValue - min) / (max - min) ] b. would've made my life a bit easier on several occasions, but feels much too lightweight to load a library for. There doesn't seem to be an entire domain behind it. One method gets you the whole thing. 2. AFAICT, Aconcagua doesn't really solve this problem. It defines families of units and conversions between them, but here there's just one concept as mentioned in 1.b. above ----- Cheers, Sean -- View this message in context: http://forum.world.st/Number-percent-tp4805988p4806047.html Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
I like it, it is just one method.
On 16 Feb 2015, at 22:41, Sean P. DeNigris <sean@clipperadams.com> wrote:
Guillermo Polito wrote
Sean, but if you need something like that, why wouldn't you load aconcagua?
I'm just in the crusade of putting less in the kernel by default ^^.
Good question! The little project I was working on when I implemented that method /was/ using Aconcagua! But: 1. This is a simple, common conversion which a. could make the kernel itself a bit more intention revealing Job>>#progress ^ min >= max ifTrue: [ 1 ] ifFalse: [ (currentValue - min) / (max - min) ] could become: ^ min >= max ifTrue: [ 100 percent ] ifFalse: [ (currentValue - min) / (max - min) ] b. would've made my life a bit easier on several occasions, but feels much too lightweight to load a library for. There doesn't seem to be an entire domain behind it. One method gets you the whole thing. 2. AFAICT, Aconcagua doesn't really solve this problem. It defines families of units and conversions between them, but here there's just one concept as mentioned in 1.b. above
----- Cheers, Sean -- View this message in context: http://forum.world.st/Number-percent-tp4805988p4806047.html Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
I'm also in favor to have it as default in the core. It is a so basic thing. I was also searching for this feature a few days ago. On another hand, one could also argue that 12/100 does the job but is less intention revealing. Another thing that I find is missing in the core is the support for currency (with a nice formatting and round: 2) Le 16 févr. 2015 à 22:55, Sven Van Caekenberghe a écrit :
I like it, it is just one method.
On 16 Feb 2015, at 22:41, Sean P. DeNigris <sean@clipperadams.com> wrote:
Guillermo Polito wrote
Sean, but if you need something like that, why wouldn't you load aconcagua?
I'm just in the crusade of putting less in the kernel by default ^^.
Good question! The little project I was working on when I implemented that method /was/ using Aconcagua! But: 1. This is a simple, common conversion which a. could make the kernel itself a bit more intention revealing Job>>#progress ^ min >= max ifTrue: [ 1 ] ifFalse: [ (currentValue - min) / (max - min) ] could become: ^ min >= max ifTrue: [ 100 percent ] ifFalse: [ (currentValue - min) / (max - min) ] b. would've made my life a bit easier on several occasions, but feels much too lightweight to load a library for. There doesn't seem to be an entire domain behind it. One method gets you the whole thing. 2. AFAICT, Aconcagua doesn't really solve this problem. It defines families of units and conversions between them, but here there's just one concept as mentioned in 1.b. above
----- Cheers, Sean -- View this message in context: http://forum.world.st/Number-percent-tp4805988p4806047.html Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
demarey wrote
I'm also in favor to have it as default in the core. It is a so basic thing.
By the way, this was integrated into 4.0 :) ----- Cheers, Sean -- View this message in context: http://forum.world.st/Number-percent-tp4805988p4813187.html Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
On 19 Mar 2015, at 14:32, Sean P. DeNigris <sean@clipperadams.com> wrote:
demarey wrote
I'm also in favor to have it as default in the core. It is a so basic thing.
By the way, this was integrated into 4.0 :)
And I am already using it. Although I must say that it should have been ^ self / 100 instead of ^ self / 100.0 It is up to the caller to decide about conversions. When computing with money, you typically don't want floating point.
I agree with that. Doru On Thu, Mar 19, 2015 at 2:47 PM, Sven Van Caekenberghe <sven@stfx.eu> wrote:
On 19 Mar 2015, at 14:32, Sean P. DeNigris <sean@clipperadams.com> wrote:
demarey wrote
I'm also in favor to have it as default in the core. It is a so basic thing.
By the way, this was integrated into 4.0 :)
And I am already using it.
Although I must say that it should have been
^ self / 100
instead of
^ self / 100.0
It is up to the caller to decide about conversions. When computing with money, you typically don't want floating point.
-- www.tudorgirba.com "Every thing has its own flow"
Tudor Girba-2 wrote
Although I must say that it should have been ^ self / 100
Good point. Let's not introduce an incorrect feature! Issue 15165: Number>>#percent shouldn't force to Float Fix in inbox. ----- Cheers, Sean -- View this message in context: http://forum.world.st/Number-percent-tp4805988p4813236.html Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
Sean P. DeNigris wrote
Issue 15165: Number>>#percent shouldn't force to Float
Integrated into 4.0. Thanks everyone. ----- Cheers, Sean -- View this message in context: http://forum.world.st/Number-percent-tp4805988p4813569.html Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
Thank you. Doru On Fri, Mar 20, 2015 at 1:01 PM, Sean P. DeNigris <sean@clipperadams.com> wrote:
Sean P. DeNigris wrote
Issue 15165: Number>>#percent shouldn't force to Float
Integrated into 4.0. Thanks everyone.
----- Cheers, Sean -- View this message in context: http://forum.world.st/Number-percent-tp4805988p4813569.html Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
-- www.tudorgirba.com "Every thing has its own flow"
participants (6)
-
Christophe Demarey -
Gabriel Cotelli -
Guillermo Polito -
Sean P. DeNigris -
Sven Van Caekenberghe -
Tudor Girba