Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Difference between Rand.Int and randint?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
[Gandalf]




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sun Mar 13, 2005 4:05 pm   Post subject: (No subject)

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




PostPosted: Sun Mar 13, 2005 4:20 pm   Post subject: (No 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!
illu45




PostPosted: Sun Mar 13, 2005 5:39 pm   Post subject: (No 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.
Tony




PostPosted: Sun Mar 13, 2005 6:36 pm   Post subject: (No subject)

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




PostPosted: Sun Mar 13, 2005 7:59 pm   Post subject: (No subject)

all this stuff is like

Draw.Oval=drawoval
Draw.Box=drawbox

and etc.
Cervantes




PostPosted: Sun Mar 13, 2005 8:23 pm   Post subject: (No 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.
ssr




PostPosted: Sun Mar 13, 2005 9:37 pm   Post subject: (No 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
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: