I've seen many people who want to have a ( )^( ) block in scratch. a few people tried to make this block, but all of the examples I have seen use repeated multiplication, so they don't work with decimal exponents. I, a simple scratcher, who knows almost nothing about squeak or smalltalk, have found a way to make an exponent reporter block without using repeated multiplication.
this is how I did it:
computeExponent: t1 raisedTo: t2 | t3 | t3 _ t1 raisedTo: t2. ^ t3
open the browser, go to scratchObjects/scriptableScratchMorph/other ops. copy and paste this into the box below. then press alt s to save.
then, go to scratchObjects/scriptableScratchMorph and click the class button below.
then go to scratchObjects/scriptableScratchMorph/block specs/block specs and copy and paste this into the block specs after you see ('%n / %n' #r #/ #- #-) in the block specs:
('%n ^ %n' #r #computeExponent:raisedTo: #- #-)
after you pasted it, press alt s to save.
close the browser and click on the operators tab. you will see a new block that will allow you to use exponents, and even allow you to use decimal exponents
to save this permanently, shift-r-click and select save screen for end user, and select yes.
WARNING: like all block hacks, this does not work online
Last edited by roger- (2010-07-24 12:51:24)
Offline
um, there's an easier method:
computeExponent: base raisedTo: exponent ^ base raisedTo: exponent
Last edited by ScratchReallyROCKS (2010-07-25 09:22:23)
Offline
ScratchReallyROCKS wrote:
um, there's an easier method:
Code:
computeExponent: base raisedTo: exponent ^ base raisedTo: exponent
*facepalm*
see, I don't know that much about squeak.
Offline
climber59 wrote:
You can also do ( {10^} of ( (exponent) * ( ( {log} of (base) ) )
What exactly IS "base"? is it the second exponent? probably not. *sigh*
[blocks]<when green flag clicked>[/blocks]
[blocks]<forever>[/blocks]
act confused
Offline
Offline
In my mod, Theblocksmod, it uses this method, but I didn't copy it from this.
Offline
Bingo uses it since 1.0.0...
maybe you might want to try with just the block spec
('%n ^ %n' r raisedTo: - -)
not sure if that will work though because i didnt use it like that
Offline
ZacIsCool wrote:
all of these return error for me! ;(
1. Don't necro 2 year old posts.
2. Pay attention to said user above you.
Offline
bbbeb wrote:
ZacIsCool wrote:
all of these return error for me! ;(
1. Don't necro 2 year old posts.
2. Pay attention to said user above you.
Actually:
1. It's fine to necropost something if a user is having a problem (less topics need to be created) or has a solution to an unanswered post. It's only bad if it's just spamming. Which his post isn't.
2. I don't see how LS97 is saying that none of the code given wouldn't work. I think s/he was referring to their own code.
ZaclsCool: Could you provide some more information on how you are trying to do this?
Last edited by Magnie (2012-05-10 11:13:34)
Offline
Magnie wrote:
bbbeb wrote:
ZacIsCool wrote:
all of these return error for me! ;(
1. Don't necro 2 year old posts.
2. Pay attention to said user above you.Actually:
1. It's fine to necropost something if a user is having a problem (less topics need to be created) or has a solution to an unanswered post. It's only bad if it's just spamming. Which his post isn't.
2. I don't see how LS97 is saying that none of the code given wouldn't work. I think s/he was referring to their own code.
ZaclsCool: Could you provide some more information on how you are trying to do this?
2. Yes, LS97 (he) was referring to his own code.
In fact, now that I know more Squeak, I can confirm that it's completely wrong
Offline
There used to be an official exponent block iirc. Whatever happened to it?
Offline
Okay then.
Last edited by SuperJedi224 (2012-11-10 16:44:06)
Offline
Well, in the functions block, there's a 10^ and a e^, if that's what you're referring to, SuperJedi.
Offline