Hi all,
I just subscribed to the list and found that crossSum debate in the archives. I did an implementation a while ago for musinum, a fractal music generator, that can be found on squeakmap. (for a "professional implementation see also http://reglos.de/musinum )
I did it this way:
Integer >> crossSumBase: aBase self < aBase ifTrue: [^ self]. ^ self \ aBase + (self // aBase crossSumBase: aBase)
Cheers,
Markus
Markus,
That is beautiful! I started to do something similar but was trying to increase the size of the mod and it was dependent on the number of digits so I had to do a string conversion anyway. You did a very nice job!
Ron
-----Original Message----- From: beginners-bounces@lists.squeakfoundation.org [mailto:beginners- bounces@lists.squeakfoundation.org] On Behalf Of Markus Gaelli Sent: Tuesday, May 09, 2006 6:44 PM To: beginners@lists.squeakfoundation.org Subject: [Newbies] crossSum, an alternative implementation
Hi all,
I just subscribed to the list and found that crossSum debate in the archives. I did an implementation a while ago for musinum, a fractal music generator, that can be found on squeakmap. (for a "professional implementation see also http://reglos.de/musinum )
I did it this way:
Integer >> crossSumBase: aBase self < aBase ifTrue: [^ self]. ^ self \ aBase + (self // aBase crossSumBase: aBase)
Cheers,
Markus _______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Hello
As I guessed, there is more than one way to do it. Rons solution is similiar to mine, the one Markus posted is similiar to the other I mentioned before. Anyway. Both of you did it shorter. Thank you for your contributions That gives me some more inspiration.
bye Enno
Am 10.05.2006 um 16:57 schrieb Enrico Schwass:
Hello
As I guessed, there is more than one way to do it. Rons solution is similiar to mine, the one Markus posted is similiar to the other I mentioned before. Anyway. Both of you did it shorter. Thank you for your contributions That gives me some more inspiration.
Note though that Markus's solution is both more flexible by allowing other bases than 10, and more than 20 times faster for small integers (still 2x for large ones).
- Bert -
beginners@lists.squeakfoundation.org