Computer Science Canada And/or in turing |
Author: | Guru [ Wed Jan 18, 2012 5:15 pm ] | ||
Post subject: | And/or in turing | ||
What is it you are trying to achieve? I was wondering if there is an and/or command or it is possible to shorten the code in an if statement instead of and and and and and or and and and and ... etc What is the problem you are having? I am creating a Yahtzee dice game and for the scoring categories there will be many more lines of code if I don't say and/or Describe what you have tried to solve this problem Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Please specify what version of Turing you are using Turing 4.1.1 or whatever is latest |
Author: | Insectoid [ Wed Jan 18, 2012 5:20 pm ] |
Post subject: | RE:And/or in turing |
&& = and || = or |
Author: | Raknarg [ Wed Jan 18, 2012 5:21 pm ] |
Post subject: | RE:And/or in turing |
Use loops. For instance, in that problem you could do something like: var valid := true for i : 1 .. 6 if dice (i) not= 1 then valid = false end if end for if valid = true then... There are ways so that you can shorten it even further, but thats just an idea |
Author: | mirhagk [ Wed Jan 18, 2012 5:21 pm ] | ||
Post subject: | RE:And/or in turing | ||
if your checking something like the above you can shorten the code by having a for loop
|