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

Username:   Password: 
 RegisterRegister   
 random procedures
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
msimard8




PostPosted: Wed Dec 22, 2004 10:42 am   Post subject: random procedures

I dont know how detailed this question has to be.

How do you make your program call random procedures.

thanks
Sponsor
Sponsor
Sponsor
sponsor
MihaiG




PostPosted: Wed Dec 22, 2004 12:29 pm   Post subject: (No subject)

procedures eh? hmmm..... i don't think its possible... because turing goes in a linear fashion it doesnt like to jump around...unlesss.... you put ur procedures in


i.e
code:

var a,b,c,pro : int
a:= 1
b:= 2
c:=3
loop
randint(pro,1,3)
     if pro = a then
     %insert procedure here
     elsif pro = b then
     %insert another procedure here
     else then
     %insert procedure here
end if
end loop

that should call up procedures randomly>?? i dunno.. i njust made it of the top of my head... sorry if there are bugs but something along those lines...we have 4 variables. the first three are going to define the procedures... and pro will choose the random procedure...
we assign a,b,c, valuies(1,2,3) we then cal apon randint function which will give pro a value of 1,2,3 we then compare var. a,b,c to pro and se which one is equal... it then is put in a if functionand calls that procedure and then loops the entire thing again... i hope this helped i think it should work correct me if i am wrong this is for turing 4.0.3x
Tony




PostPosted: Wed Dec 22, 2004 1:30 pm   Post subject: (No subject)

you could make an array of pointers to the procedures and call one of its elements on random.

the question would be - why would you want to do that?
MihaiG




PostPosted: Wed Dec 22, 2004 1:36 pm   Post subject: (No subject)

tony woulodn't my method work too.... its also understandble???
Tony




PostPosted: Wed Dec 22, 2004 1:48 pm   Post subject: (No subject)

ELCOMANDANTE wrote:
tony woulodn't my method work too....

yeah, it would. I'm just suggesting alternatives. I still don't understand what he's trying to do.
AsianSensation




PostPosted: Wed Dec 22, 2004 4:09 pm   Post subject: (No subject)

ELCOMANDANTE wrote:
woulodn't my method work too.... its also understandble???


Of course it would, but what if there were many many many many procedures? Then it wouldn't be practical. The array of pointers is the best ideal, and you can learn how to use them by learning how to use Classes.
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  [ 6 Posts ]
Jump to:   


Style:  
Search: