Page 1 of 1

Logic Operators and how they are interpreted

#1 polymath  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 52
  • View blog
  • Posts: 670
  • Joined: 04-April 08

Posted 31 May 2008 - 08:51 AM

The attached file is a tutorial on Logic Operators.

I used some elements that i didn't know how to use in BBcode, such as tables, so if anyone could tell me how to make a table for my tutorials, that would be appreciated. For now, here it is in Rich Text (hope you can open it).

:)

Attached File(s)


Is This A Good Question/Topic? 0
  • +

Replies To: Logic Operators and how they are interpreted

#2 mikeblas  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 43
  • View blog
  • Posts: 390
  • Joined: 08-February 08

Posted 01 June 2008 - 09:43 AM

Unfortunately, BBCode doesn't support any sort of tables.
Was This Post Helpful? 0
  • +
  • -

#3 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Posted 01 June 2008 - 02:36 PM

Well, what you can do is use some creative work to create tables.

First set you font to a fixed width font (courier or new courier work well).

Next layout your table as you would like it using ascii art.

Then use your text editor (something that has RegEx replaces works best -- I use ProgrammersNotepad) to replaces spaces with a period (or other small character).

Then replace all of the instances of that character with [color=#FFFFFF](spaces char here)[/color]

I use Programmer's Notepad's RegEx replace to do this. It works well. but since Dream In Code's background is not exactly white the characters are still visible but barely, and if someone copies your text then they get all of those characters.

example:

+---------+---------+----------+
|````X````|````Y````|`(X`&&`Y)`|
+---------+---------+----------+
|`Flase```|`False```|`False````|
+---------+---------+----------+
|`False```|`True````|`False````|
+---------+---------+----------+
|`True````|`False```|`False````|
+---------+---------+----------+
|`True````|`True````|`True`````|
+---------+---------+----------+


[font=Courier New]+---------+---------+----------+
|[color=#FFFFFF]````[/color]X[color=#FFFFFF]````[/color]|[color=#FFFFFF]````[/color]Y[color=#FFFFFF]````[/color]|[color=#FFFFFF]`[/color](X[color=#FFFFFF]`[/color]&&[color=#FFFFFF]`[/color]Y)[color=#FFFFFF]`[/color]|
+---------+---------+----------+
|[color=#FFFFFF]`[/color]Flase[color=#FFFFFF]```[/color]|[color=#FFFFFF]`[/color]False[color=#FFFFFF]```[/color]|[color=#FFFFFF]`[/color]False[color=#FFFFFF]````[/color]|
+---------+---------+----------+
|[color=#FFFFFF]`[/color]False[color=#FFFFFF]```[/color]|[color=#FFFFFF]`[/color]True[color=#FFFFFF]````[/color]|[color=#FFFFFF]`[/color]False[color=#FFFFFF]````[/color]|
+---------+---------+----------+
|[color=#FFFFFF]`[/color]True[color=#FFFFFF]````[/color]|[color=#FFFFFF]`[/color]False[color=#FFFFFF]```[/color]|[color=#FFFFFF]`[/color]False[color=#FFFFFF]````[/color]|
+---------+---------+----------+
|[color=#FFFFFF]`[/color]True[color=#FFFFFF]````[/color]|[color=#FFFFFF]`[/color]True[color=#FFFFFF]````[/color]|[color=#FFFFFF]`[/color]True[color=#FFFFFF]`````[/color]|
+---------+---------+----------+[/font]

Was This Post Helpful? 0
  • +
  • -

#4 herefishyfishy  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 7
  • View blog
  • Posts: 60
  • Joined: 01-May 08

Posted 02 June 2008 - 06:07 PM

I'd just like to comment on your distributive property of logic.

There IS a way to simplify !(A&&B). It's the same as !A||!B.

Likewise, !(A||B) is logically equivalent to !A&&!B.

It's called De Morgan's law. (Yes, I am such a nerd. I know.)

This post has been edited by herefishyfishy: 02 June 2008 - 06:08 PM

Was This Post Helpful? 0
  • +
  • -

#5 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3093
  • View blog
  • Posts: 19,139
  • Joined: 14-September 07

Posted 03 June 2008 - 04:40 AM

Nice! I also like math theory go De Morgan!
Was This Post Helpful? 0
  • +
  • -

#6 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5780
  • View blog
  • Posts: 12,595
  • Joined: 16-October 07

Posted 03 June 2008 - 05:58 AM

View Postherefishyfishy, on 2 Jun, 2008 - 09:07 PM, said:

There IS a way to simplify !(A&&B). It's the same as !A||!B.


Good point. From a computer standpoint, !A||!B might be preferable to !(A&&B).

The reason is that if !A is true, the compiler doesn't have to resolve !B and usually won't. For A&&B the same thing, If !A is can just stop. However, further logic is to be applied, it would have to resolve the entire thing. That's assuming the compiler doesn't distribute the logic first, but it's something to be aware of.
Was This Post Helpful? 0
  • +
  • -

#7 polymath  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 52
  • View blog
  • Posts: 670
  • Joined: 04-April 08

Posted 03 June 2008 - 01:15 PM

I heard about DeMorgan's Law, but thought that the tutorial was already a lot to swallow for a total beginner. Most of my tutorials (actually, i think at this point all of them) are aimed twoard beginners. Thats what i think is the most rewarding thing about writing tutorials: helping people who aren't as good as you yet. Anyway if i edit the tutorial post i will include DeMorgan's Law. Thanks for reminding me about that one thing. Also, thanks to all of you for your help.
Was This Post Helpful? 0
  • +
  • -

#8 polymath  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 52
  • View blog
  • Posts: 670
  • Joined: 04-April 08

Posted 04 June 2008 - 01:28 PM

Whats the need for the small char instead of spaces?
Was This Post Helpful? 0
  • +
  • -

#9 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Posted 14 June 2008 - 12:28 PM

The forum software will compress multiple spaces into a single space. So to keep the spacing for the table you have to insert some character in there. Then to ensure that that character is not displayed you need to mask it to the background color (which not really white, but I find that it is close enough for me).
Was This Post Helpful? 0
  • +
  • -

#10 herefishyfishy  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 7
  • View blog
  • Posts: 60
  • Joined: 01-May 08

Posted 23 June 2008 - 02:20 PM

Another comment on the supposedly nonexistent distributive property of logic...

There is a property which states that A||(B&&C)==(A||B)&&(A||C). Likewise, A&&(B||C)==(A&&B)||(A&&C).

This property just happens to be called the distributive property.

I could tell you lots of stuff...
  • A||A==A
  • A&&A==A
  • A||(!A)==true
  • A&&(!A)==false
  • A&&(A||B)==A
  • A||(A&&B)==A
  • A||B==B||A
  • A&&B==B&&A
  • (A||B)||C==A||(B||C)
  • (A&&B)&&C==A&&(B&&C)
  • !(!A)==A
  • A||(B&&C)==(A||B)&&(A||C)
  • A&&(B||C)==(A&&B)||(A&&C)
  • !(A&&B)==!A||!B
  • !(A||B)==!A&&!B
  • A||true==true
  • A&&true==A
  • A||false==A
  • A&&false==false
The list goes on and on...

This post has been edited by herefishyfishy: 23 June 2008 - 02:20 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1