Computer Science Canada

Difference between Rand.Int and randint?

Author:  [Gandalf] [ Sun Mar 13, 2005 3:51 pm ]
Post subject:  Difference between Rand.Int and randint?

What is the difference, if there is one? I have looked around these forums, and took a look at the desciptions in Turing Help, but the descriptions are exactly the same... This has been at the back of my mind since I got Turing 4.05 (before I was using DOS Turing Smile ), and I feel its time I should know.

It's the same for Rand.Next/randnext and randseed/Rand.Seed and other things like that too. Confused

Author:  Tony [ Sun Mar 13, 2005 4:05 pm ]
Post subject: 

one's a function, another is a procedure that takes a pointer to a variable as an argument.

Author:  [Gandalf] [ Sun Mar 13, 2005 4:20 pm ]
Post subject: 

Alright, I see - is there any difference on how they generate random numbers? I can use both of them in my situation, but is there any advantage to using one over the other? Thanks!

Author:  illu45 [ Sun Mar 13, 2005 5:39 pm ]
Post subject: 

Using the Documentation, Rand.Int (low, high : int) : int seems to be the same as randint ( var i : int, low, high : int ) except for the fact that for fandint you have to assign a variable (var i), whereas in Rand.Int you don't.

Author:  Tony [ Sun Mar 13, 2005 6:36 pm ]
Post subject: 

since Rand.Int() is a function, it could be used in chains

Author:  person [ Sun Mar 13, 2005 7:59 pm ]
Post subject: 

all this stuff is like

Draw.Oval=drawoval
Draw.Box=drawbox

and etc.

Author:  Cervantes [ Sun Mar 13, 2005 8:23 pm ]
Post subject: 

No. Draw.Box is a procedure. drawbox is a procedure. They are the same. THAT is like colourback and colorback. However, Rand.Int is a function, whereas randint is a procedure. They are different.
Rand.Int is better, because as tony says, it can be used in chains. ie.
code:

Draw.FillOval (Rand.Int (100, 200), Rand.Int (200, 300), Rand.Int (3, 10), Rand.Int (5, 12), Rand.Int (1, 16))

vs.
code:

var x, y, xradius, yradius, clr : int
randint (x, 100, 200)
randint (y, 200, 300)
randint (xradius, 3, 10)
randint (yradius, 5, 12)
randint (clr, 1, 16)
Draw.FillOval (x, y, xradius, yradius, clr)

1 line vs. 7 lines. And the randint approach also means declaring lots of extra, messy, unnecessary variables.

Author:  ssr [ Sun Mar 13, 2005 9:37 pm ]
Post subject: 

tnx for the tutorial and tnx for clearing that out
Cervantes
Laughing
I was confused with it
it could've save me a lot of time, and lines
:p


: