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

Username:   Password: 
 RegisterRegister   
 procedures and functions-project ideas needed?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Jimbo1991




PostPosted: Tue Apr 22, 2008 12:08 pm   Post subject: procedures and functions-project ideas needed?

i have a final project to do with turing, in which procedures and functions need to be used, can anybody give me some ideas that i could do for it? thanks
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Tue Apr 22, 2008 12:31 pm   Post subject: RE:procedures and functions-project ideas needed?

absolutely anything. You should be refactoring your code into usable functions anyway.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Jimbo1991




PostPosted: Tue Apr 22, 2008 12:33 pm   Post subject: Re: procedures and functions-project ideas needed?

and what exactly does that mean? im a noob when it comes to turing
Tony




PostPosted: Tue Apr 22, 2008 12:35 pm   Post subject: RE:procedures and functions-project ideas needed?

not just Turing
Wikipedia: Refactoring
Quote:
Code refactoring is any change to a computer program's code that improves its readability or simplifies its structure without changing its results.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Jimbo1991




PostPosted: Tue Apr 22, 2008 12:37 pm   Post subject: RE:procedures and functions-project ideas needed?

im still lost, even with wikipedia, how about an example please?
Tony




PostPosted: Tue Apr 22, 2008 12:42 pm   Post subject: RE:procedures and functions-project ideas needed?

Turing:

function say_hello()
   put "hello"
end say_hello

put "the program will now greed you"
say_hello()
put "the program is now finished"
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Jimbo1991




PostPosted: Tue Apr 22, 2008 12:45 pm   Post subject: RE:procedures and functions-project ideas needed?

o ok, il have to check it out the next time i have a computer that has turing on it
Tony




PostPosted: Tue Apr 22, 2008 12:58 pm   Post subject: RE:procedures and functions-project ideas needed?

you could read more on this in tutorials via the Turing Walkthrough
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
Saad




PostPosted: Tue Apr 22, 2008 3:22 pm   Post subject: Re: RE:procedures and functions-project ideas needed?

Tony @ Tue Apr 22, 2008 12:42 pm wrote:
Turing:

function say_hello()
   put "hello"
end say_hello

put "the program will now greed you"
say_hello()
put "the program is now finished"


Perhaps you were in a hurry but it should be procedure not function

Turing:

procedure say_hello ()
    put "hello"
end say_hello

put "the program will now greed you"
say_hello ()
put "the program is now finished"



To answer your orignal question. Functions and procedures are used to put repetative code only once.

Consider the following

Turing:

function GetInput (what : string) : string
    put what
    var input : string
    get input
    result input
end GetInput

var firstName := GetInput ("Please enter your first name")
var lastName := GetInput ("Please enter your last name")


Vs.

Turing:

var firstName, lastName : string
put "Please enter your first name"
get firstName
put "Please enter your last name"
get lastName
Jimbo1991




PostPosted: Wed Apr 23, 2008 12:52 pm   Post subject: RE:procedures and functions-project ideas needed?

finaly i understand! thanks
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  [ 10 Posts ]
Jump to:   


Style:  
Search: