Dear Friends at Squeakland:
I need to get a random number between two numbers to be determined as the result of some actions. Could you tell me how to get such result with the random tile function which does not accept a variable as its argument?
I appreciate your help.
PolloGus (Quito-Ecuador)
This is why there is no parameter on the random tile. It is good for children to realize that they can get a random number in any interval by simple addition.
The random number tile generates numbers between 1 and the number that is set on it. So if we want to generate random numbers between 15 and 21, then we can do this by the sum: 14 + random 7. Often it is a good idea to make a new variable to hold such calculations: newRandom <- 14 + random 7 would be a typical line in a script.
In general it is good to help children to do "automatic arithmetic" whenever they see numbers. There are other places in the etoys where one might also put "a feature", but where having the children do a simple relationship from scratch is better for them.
Cheers,
Alan
At 11:20 AM 4/11/2005, Gustavo Correa H. wrote:
Dear Friends at Squeakland:
I need to get a random number between two numbers to be determined as the result of some actions. Could you tell me how to get such result with the random tile function which does not accept a variable as its argument?
I appreciate your help.
PolloGus (Quito-Ecuador)
Squeakland mailing list Squeakland@squeakland.org http://squeakland.org/mailman/listinfo/squeakland
Alan:
I can understand that not all possible features should be included in eToys but, could you help me in obtaining a Random number when you do not know before hand the limits of the numbers range but it depends on the results of some script calculations?
Regards
PolloGus (Quito-Ecuador)
-----Mensaje original----- De: Alan Kay [mailto:alan.kay@squeakland.org] Enviado el: Lunes, 11 de Abril de 2005 22:04 Para: gustavo.correa@coheco.com; squeakland@squeakland.org CC: Javier Diaz-Reinoso Asunto: Re: [Squeakland] Random
This is why there is no parameter on the random tile. It is good for children to realize that they can get a random number in any interval by simple addition.
The random number tile generates numbers between 1 and the number that is set on it. So if we want to generate random numbers between 15 and 21, then we can do this by the sum: 14 + random 7. Often it is a good idea to make a new variable to hold such calculations: newRandom <- 14 + random 7 would be a typical line in a script.
In general it is good to help children to do "automatic arithmetic" whenever they see numbers. There are other places in the etoys where one might also put "a feature", but where having the children do a simple relationship from scratch is better for them.
Cheers,
Alan
At 11:20 AM 4/11/2005, Gustavo Correa H. wrote:
Dear Friends at Squeakland:
I need to get a random number between two numbers to be determined as the result of some actions. Could you tell me how to get such result with the random tile function which does not accept a variable as its argument?
I appreciate your help.
PolloGus (Quito-Ecuador)
Squeakland mailing list Squeakland@squeakland.org http://squeakland.org/mailman/listinfo/squeakland
Ah, now I understand what you were asking! Good question!
I'll ask Scott Wallace for his opinion here also.
I think the simplest answer is that this should be like the feature "forward" (which can be made from simpler stuff in etoys but is not worth putting the children through the process early on -- so it is provided as a feature). That we can't simply drop a variable name on Random (and extend it for arithmetic) is a bug and should be fixed in this version of etoys or the next.
It is possible (and illuminating) to make a random number generator by hand in etoys, but I don't think this should be an early burden on 11 year olds!
What do you think Scott?
Cheers,
Alan
At 08:11 AM 4/12/2005, Gustavo Correa H. wrote:
Alan:
I can understand that not all possible features should be included in eToys but, could you help me in obtaining a Random number when you do not know before hand the limits of the numbers range but it depends on the results of some script calculations?
Regards
PolloGus (Quito-Ecuador)
-----Mensaje original----- De: Alan Kay [mailto:alan.kay@squeakland.org] Enviado el: Lunes, 11 de Abril de 2005 22:04 Para: gustavo.correa@coheco.com; squeakland@squeakland.org CC: Javier Diaz-Reinoso Asunto: Re: [Squeakland] Random
This is why there is no parameter on the random tile. It is good for children to realize that they can get a random number in any interval by simple addition.
The random number tile generates numbers between 1 and the number that is set on it. So if we want to generate random numbers between 15 and 21, then we can do this by the sum: 14 + random 7. Often it is a good idea to make a new variable to hold such calculations: newRandom <- 14 + random 7 would be a typical line in a script.
In general it is good to help children to do "automatic arithmetic" whenever they see numbers. There are other places in the etoys where one might also put "a feature", but where having the children do a simple relationship from scratch is better for them.
Cheers,
Alan
At 11:20 AM 4/11/2005, Gustavo Correa H. wrote:
Dear Friends at Squeakland:
I need to get a random number between two numbers to be determined as the result of some actions. Could you tell me how to get such result with the random tile function which does not accept a variable as its argument?
I appreciate your help.
PolloGus (Quito-Ecuador)
Squeakland mailing list Squeakland@squeakland.org http://squeakland.org/mailman/listinfo/squeakland
At 8:26 AM -0700 4/12/05, Alan Kay wrote:
... That we can't simply drop a variable name on Random (and extend it for arithmetic) is a bug and should be fixed in this version of etoys or the next.
The solution to this requires implementation of support for unary numeric operators in the tile system, which we've never had, but which some people have been politely requesting for a good long time now.
I offer, attached, a preliminary fileout that actually adds functions to etoys!
Although this is not quite finished from a number of standpoints, it's probably good enough to criticize. I offer it up to those in the community who are comfortable with "filing in" change-sets such as this, for your comments. [Caution: projects saved using this will only be intelligible to other Squeak images that also also have this code in them.)
Once you file it in to a Squeakland system, numeric functions will become available at any time for any numeric-valued quantity in any tile script, in the following two ways:
(1) If you bring up the halo on the "pad" that holds any numeric value in a script, you'll see in the halo menu a new item "place into a function". (Holding down the shift key as you click through the halo layers will make it easier to zero in on the object you want to give the halo to.)
(2) Also, if you hold down the *shift* key while you click on an extension (right-facing) caret, it is interpreted as a request to place the numeric tile within a function call.
As you'll see, when you do either of these, the former numeric quantity, whether it be a simple constant or slot, or a numeric expression of whatever complexity, will sprout an "abs" function around it. You can then click on the arrows to cycle among the available functions (I've provided 15 to start with,) or you can click on the function name to get a pop-up of all the choices.
The dual of this is that if *have* a function and you want to eliminate it, bring up the halo on the Function and choose "remove function."
What do you think?
Cheers,
-- Scott
squeakland@lists.squeakfoundation.org