Boolean expressions (logical operators)


examples/scalars/logical_operators.p6
#!/usr/bin/perl6
use v6;

say (2 and 1);  # 1
say (1 and 2);  # 2
say (1 and 0);  # 0
say (0 and 1);  # 0
say (0 and 0);  # 0
say "---";

say (1 or 0);   # 1
say (1 or 2);   # 1
say (0 or 1);   # 1
say (0 or 0);   # 0
say "---";

say (1 // 0);     # 1
say (0 // 1);     # 0
say (0 // 0);     # 0
say "---";

say (1 xor 0);     # 1
say (0 xor 1);     # 1
say (0 xor 0);     # 0 TODO??
say (1 xor 1);     # 
say "---";

say (not 1);       # 0 TODO ?
say (not 0);       # 1
say "---";

Copyright 2006, 2007, 2008, 2009, 2010 Gabor Szabo http://szabgab.com/ Index | TOC
If you are interested in on-site trainings by the author, please contact me directly.

Online courses:

Would you like to get
updated when I publish
the next article?

Follow me:

Google Plus Twitter RSS feed