|
-
Oct 7th, 2004, 05:43 PM
#1
Thread Starter
Stuck in the 80s
[Resolved] Logic Question
Let's say we have this: P -> Q...how do you write that as an if statement?
Code:
if ( /* P -> Q */) {
}
I'm so lost on this.
Last edited by The Hobo; Oct 10th, 2004 at 11:32 PM.
-
Oct 8th, 2004, 12:37 AM
#2
If Statement in what syntax, maybe VB?
Code:
if P=Q then
'code something
end if
If that'S what you want.
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Oct 8th, 2004, 06:31 AM
#3
Thread Starter
Stuck in the 80s
That's not what I'm looking for.
-
Oct 8th, 2004, 08:03 AM
#4
Thread Starter
Stuck in the 80s
The truth table for P->Q is:
Code:
P | Q | P --> Q
--+---+--------
T | T | T
T | F | F
F | F | T
F | T | T
So the best I could come up with is:
Code:
if (Q || (!P && ! Q)) {
// ...
}
Because if Q is true, the statement is always true, and if both P and Q are false, the statement is true.
Or possibly:
Code:
if (!(P && !Q)) {
//...
}
-
Oct 8th, 2004, 12:24 PM
#5
Easy peasy.
In Vb6 it would have been:
VB Code:
'VB6
If p Imp q then
...
End If
But Imp (implication) is no longer supported in VB.net so...
VB Code:
'VB.Net
If (not p) or q then
...
End If
I don't live here any more.
-
Oct 8th, 2004, 02:11 PM
#6
What does -> mean? The only thing I know of for that is for referencing members through pointers in C++. However, that's not a logic question, so I assume that it means something else.
My usual boring signature: Nothing
 
-
Oct 8th, 2004, 03:14 PM
#7
i was going to post the same thing last night, but thought that I was missing something. I still don't get it. How coud P imply Q?
-
Oct 8th, 2004, 03:36 PM
#8
I thoght he ment P goes to Q. Like if you are using the SUM sign. Or like with limits...
-
Oct 8th, 2004, 06:19 PM
#9
I looked up Imp(). It does a bitwise comparison of identically positioned bits in two numeric expressions and sets the corresponding bit in result according to a table
a b c a=bit in expression1 is
0 0 1 b=bit in expression2 is
0 1 1 c=the results is
1 0 0
1 1 1
i thought this was a VB question, anyways
-
Oct 10th, 2004, 11:32 PM
#10
Thread Starter
Stuck in the 80s
Thanks for all the help. All I know about -> is the truth table that my math book gave me. I honestly don't understand it myself. They talk about it as if it's an if statement, but it's confusing. But it's my general opinion that this math book is not well written at all.
-
Oct 11th, 2004, 08:43 AM
#11
Originally posted by The Hobo
Thanks for all the help. All I know about -> is the truth table that my math book gave me. I honestly don't understand it myself. They talk about it as if it's an if statement, but it's confusing. But it's my general opinion that this math book is not well written at all.
Track down the author, crush his head with a rock and wear his skin to work.
-
Oct 31st, 2004, 03:22 PM
#12
Not NoteMe
Hee's how it was explained to me:
I propose that if it is raining then there are clouds in the sky.
So P = "It's raining"
and Q = "There are clouds in the sky"
If P then Q
It differs from a straight if statement because of the truth table.
If you observe that it's raining and there are clouds in the sky then the statement is true.
If you observe that it's raining but there aren't any clouds in the sky then the statement is false.
If you observe that it's not raining then it doesn't matter whether there are clouds or not (since you can't test the implication because the first part (P) is false), so the statement could be true and you assume it is.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
-
Nov 1st, 2004, 06:16 AM
#13
So our programs won't work when the weather is sunny?
How does the computer know what it's like outside?
I don't live here any more.
-
Nov 15th, 2004, 03:45 PM
#14
Not NoteMe
Originally posted by wossname
So our programs won't work when the weather is sunny?
Not unless you shield them using SandpaperTM
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
-
Nov 16th, 2004, 03:24 AM
#15
I don't live here any more.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|