Computer Science Canada Syntax Typo? |
Author: | chrispminis [ Tue Mar 14, 2006 2:48 pm ] | ||
Post subject: | Syntax Typo? | ||
Yeah, this isn't a big problem. I've just been staring at my code for about 40 minutes, and I still haven't found the problem. There are 2 errors. One is for a string literal that should end the line, the other is a syntax error expecting then.
Here's my code, I was just testing my prioritizing, for BEDMAS. I am sure the error is linked to an extra " somewhere but I can't find it! Please help. |
Author: | Delos [ Tue Mar 14, 2006 3:27 pm ] | ||
Post subject: | |||
Not sure if it achieves what you want it to though... |
Author: | chrispminis [ Tue Mar 14, 2006 3:33 pm ] |
Post subject: | |
I'm not sure what you are trying to point me towards. But where did the "\^" come from? Im trying to prioritize them, "&" is my chosen square root sign. So exponents and square root go to the same priority level. |
Author: | pavol [ Tue Mar 14, 2006 4:48 pm ] | ||||
Post subject: | |||||
im not sure, you have more knowledge in this matter than i do, but if you take ^ out of:
to make it:
i know it probably doesn't make your program do what you want, but what i'm trying to point out is that maybe "^" is the problem and maybe it is some kind of thing held special by Turing and you're not really allowed using it. hope it gives some insight into your problem ![]() |
Author: | Delos [ Tue Mar 14, 2006 4:55 pm ] |
Post subject: | |
pavol is on the right track. '^' is a 'special thing' in Turing, but you are allowed to use it, provided you know how. In this case, if you wish to use it in a string, you need to provide the escape character '\' first. This is similar to using things like '\n' or '\"'. I'm guessing the '^' would be for an exponent... |
Author: | MysticVegeta [ Tue Mar 14, 2006 6:42 pm ] |
Post subject: | |
no ** is for exponent. ^ is reserved for other string purpose, and yes you would need to put "\" before the ^ so it would be "\^", its the same as saying "^", its for the same reason as for in java when you have to put "\\+" due to regex issues. |
Author: | Delos [ Tue Mar 14, 2006 8:46 pm ] |
Post subject: | |
MysticVegeta wrote: no ** is for exponent. ^ is reserved for other string purpose, and yes you would need to put "\" before the ^ so it would be "\^", its the same as saying "^", its for the same reason as for in java when you have to put "\\+" due to regex issues.
I meant in his proggie. You know, typing in "4^3" meaning four raised to the third power... |
Author: | chrispminis [ Wed Mar 15, 2006 2:16 pm ] |
Post subject: | |
well, Ill try that, that makes sense. And Delos it is ** for exponent. Turing doesn't evaluate 2^3 = 8. Just another thing. If you wanted the backslash character (\) in a string would it be "\\"? |
Author: | [Gandalf] [ Wed Mar 15, 2006 4:39 pm ] |
Post subject: | |
^ is the more 'universal' exponent representation, while ** is what Turing uses since ^ is reserved for other things. Yes, to output a backslash you would use escape + \, or else "\\". |
Author: | Clayton [ Wed Mar 15, 2006 4:57 pm ] |
Post subject: | |
i have to ask what do you mean by using backslash as an escape character? what is an escape character and what are they used for? i know this is off topic but i didnt want to start another thread just for this |
Author: | Delos [ Wed Mar 15, 2006 10:50 pm ] |
Post subject: | |
Well, the most practical interpretation would be that you 'escape' from the literal string that you're using, and can implement a secondary command instead. So, for instance, you have "Hello /n World", which prints Hello and World on seperate lines. Since it's all in one string, the '/' allows you to drop out from the usual translation and actually do some manipulations. This is rather limited though, since any more graphically-oriented procedures (Font. etc) don't support this (seeing as they create pictures). And of course, everyone loves pictures. ![]() |