Author |
Message |
Jimbo1991
|
Posted: 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 |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: 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. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
Jimbo1991
|
Posted: 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 |
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: 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. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
Jimbo1991
|
Posted: 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? |
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: 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"
|
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
Jimbo1991
|
Posted: 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 |
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Saad
![](http://compsci.ca/v3/uploads/user_avatars/182387547249e7ebb91fb8a.png)
|
Posted: 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
|
|
|
|
|
|
![](images/spacer.gif) |
Jimbo1991
|
Posted: Wed Apr 23, 2008 12:52 pm Post subject: RE:procedures and functions-project ideas needed? |
|
|
finaly i understand! thanks |
|
|
|
|
![](images/spacer.gif) |
|