Reply to topic  [ 13 posts ] 
Semantics 
Author Message
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
Just trying to work out what I think a logical/boolean expression should result in.

If a, b, c and d are all boolean values/expressions and I had an expression...

(a AND b) OR (c AND d)

then the expression is true if either a and b are both true or c and d are both true.

If I had the expression...

a AND (b OR c) AND d

then this would be true only if a and d are true and either of b or c (or both) is true.

But what if I had the expression...

a AND b OR c AND d

How would the expression work? Or would it depend on the language being used?

Purely a semantics question just out of interest.

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Last edited by Fogmeister on Thu Mar 17, 2011 12:05 pm, edited 1 time in total.



Thu Mar 17, 2011 10:46 am
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 6:36 pm
Posts: 5150
Location: /dev/tty0
Reply with quote
From the Boolean logic page on Wikipedia:
Quote:
Mathematicians and engineers often use plus (+) for OR and a product sign (.) for AND. OR and AND are somewhat analogous to addition and multiplication in other algebraic structures, and this notation makes it very easy to get sum of products form for normal algebra. NOT may be represented by a line drawn above the expression being negated. It also commonly leads to . giving a higher precedence than +, removing the need for parenthesis in some cases.


So, would it be:
(a AND b) or (c AND d)

The expression is true if both a and b are true, OR if c and d are true.


Thu Mar 17, 2011 11:16 am
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
forquare1 wrote:
From the Boolean logic page on Wikipedia:
Quote:
Mathematicians and engineers often use plus (+) for OR and a product sign (.) for AND. OR and AND are somewhat analogous to addition and multiplication in other algebraic structures, and this notation makes it very easy to get sum of products form for normal algebra. NOT may be represented by a line drawn above the expression being negated. It also commonly leads to . giving a higher precedence than +, removing the need for parenthesis in some cases.


So, would it be:
(a AND b) or (c AND d)

The expression is true if both a and b are true, OR if c and d are true.

Ah, cool!

Thank you!

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Thu Mar 17, 2011 12:05 pm
Profile WWW
Spends far too much time on here
User avatar

Joined: Thu Apr 23, 2009 9:40 pm
Posts: 4876
Location: Newcastle
Reply with quote
Easiest way is to use parenthesis as there is no penalty on excessive parenthesis usage (as it's stripped out during compilation anyway) and it aids in readability :)

_________________
Twitter
Charlie Brooker:
Macs are glorified Fisher-Price activity centres for adults; computers for scaredy cats too nervous to learn how proper computers work; computers for people who earnestly believe in feng shui.


Thu Mar 17, 2011 1:32 pm
Profile
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
finlay666 wrote:
Easiest way is to use parenthesis as there is no penalty on excessive parenthesis usage (as it's stripped out during compilation anyway) and it aids in readability :)

(((That)(')(s)) (my) (usual) (approach)(.))

:D

But just came across a bit that didn't have any and wondered how it would work. I wrote a bit of code to try some values but just thought I'd ask aswell :D

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Thu Mar 17, 2011 2:15 pm
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Fri Apr 24, 2009 7:55 am
Posts: 7935
Location: Manchester.
Reply with quote
Fogmeister wrote:
finlay666 wrote:
Easiest way is to use parenthesis as there is no penalty on excessive parenthesis usage (as it's stripped out during compilation anyway) and it aids in readability :)

(((That)(')(s)) (my) (usual) (approach)(.))

:D

But just came across a bit that didn't have any and wondered how it would work. I wrote a bit of code to try some values but just thought I'd ask aswell :D

I agree!

(.)(.) <-- For JJ :lol: :D

</Totally pointless post>

_________________
okenobi wrote:
John's hot. No denying it. But he's hardly Karen now, is he ;)

John Vella BSc (Hons), PGCE - Still the official forum prankster and crude remarker :P
Sorry :roll:
I'll behave now.
Promise ;)


Mon Mar 21, 2011 3:31 pm
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
John_Vella wrote:
Fogmeister wrote:
finlay666 wrote:
Easiest way is to use parenthesis as there is no penalty on excessive parenthesis usage (as it's stripped out during compilation anyway) and it aids in readability :)

(((That)(')(s)) (my) (usual) (approach)(.))

:D

But just came across a bit that didn't have any and wondered how it would work. I wrote a bit of code to try some values but just thought I'd ask aswell :D

I agree!

(.)(.) <-- For JJ :lol: :D

</Totally pointless post>

ROFL!

I was wondering who would be the first person to do that :D

:lol:

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Mon Mar 21, 2011 3:41 pm
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 9:40 pm
Posts: 5288
Location: ln -s /London ~
Reply with quote
John_Vella wrote:
(.)(.) <-- For JJ :lol: :D

Yoshi peering through a letter box!

_________________
timark_uk wrote:
Gay sex is better than no sex

timark_uk wrote:
Edward Armitage is Awesome. Yes, that's right. Awesome with a A.


Mon Mar 21, 2011 4:31 pm
Profile
Spends far too much time on here
User avatar

Joined: Thu Apr 23, 2009 9:40 pm
Posts: 4876
Location: Newcastle
Reply with quote
John_Vella wrote:
(.)(.) <-- For JJ :lol: :D



I prefer

( , )( , ) <-- tassels/pasties ;)

_________________
Twitter
Charlie Brooker:
Macs are glorified Fisher-Price activity centres for adults; computers for scaredy cats too nervous to learn how proper computers work; computers for people who earnestly believe in feng shui.


Mon Mar 21, 2011 4:44 pm
Profile
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
Was trying to think of another one and discovered this version of Yoshi peering through a letter box...

( .Y. )

:D

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Mon Mar 21, 2011 10:52 pm
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 9:40 pm
Posts: 5288
Location: ln -s /London ~
Reply with quote
Fogmeister wrote:
Was trying to think of another one and discovered this version of Yoshi peering through a letter box...

( .Y. )

:D

Yeah. Me and Nick (Miners) have found quite a number. He's got a dirtier mind than me, though.

_________________
timark_uk wrote:
Gay sex is better than no sex

timark_uk wrote:
Edward Armitage is Awesome. Yes, that's right. Awesome with a A.


Mon Mar 21, 2011 11:03 pm
Profile
I haven't seen my friends in so long
User avatar

Joined: Fri Apr 24, 2009 7:55 am
Posts: 7935
Location: Manchester.
Reply with quote
finlay666 wrote:
John_Vella wrote:
(.)(.) <-- For JJ :lol: :D



I prefer

( , )( , ) <-- tassels/pasties ;)


Leaking...? :lol: :roll:

_________________
okenobi wrote:
John's hot. No denying it. But he's hardly Karen now, is he ;)

John Vella BSc (Hons), PGCE - Still the official forum prankster and crude remarker :P
Sorry :roll:
I'll behave now.
Promise ;)


Wed Mar 23, 2011 3:18 pm
Profile WWW
Spends far too much time on here
User avatar

Joined: Thu Apr 23, 2009 9:40 pm
Posts: 4876
Location: Newcastle
Reply with quote
John_Vella wrote:
Leaking...? :lol: :roll:


That would be

Code:
( . ) ( . )
  .     .
  .     .

_________________
Twitter
Charlie Brooker:
Macs are glorified Fisher-Price activity centres for adults; computers for scaredy cats too nervous to learn how proper computers work; computers for people who earnestly believe in feng shui.


Wed Mar 23, 2011 3:21 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 13 posts ] 

Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.