at-m42:logical_operators
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
at-m42:logical_operators [2009/03/27 14:56] – eechris | at-m42:logical_operators [2011/01/14 12:45] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Logical Operators ====== | ||
+ | |||
+ | These notes are extracted from Appendix C.6 of //Groovy Programming// | ||
+ | |||
+ | The //logical operators// are given in Table 1. The logical //and// operator (represented as ''&&'' | ||
+ | |||
+ | **Table 1** Logical Operators | ||
+ | |||
+ | ^ Operator ^ Description ^ Associativity ^ | ||
+ | | ''&&'' | ||
+ | | '' | ||
+ | | '' | ||
+ | |||
+ | The effect of applying these operators is shown in Table 2. | ||
+ | |||
+ | **Table 2** Evaluation of Logical Expressions (Truth Tables) | ||
+ | |||
+ | ^ //P// ^ //Q// ^ //P// && //Q// ^ | ||
+ | | '' | ||
+ | | '' | ||
+ | | '' | ||
+ | |||
+ | ^ //P// ^ //Q// ^ //P// %%||%% //Q// ^ | ||
+ | | '' | ||
+ | | '' | ||
+ | | '' | ||
+ | |||
+ | ^ //S// ^ ! //S// ^ | ||
+ | | '' | ||
+ | | '' | ||
+ | |||
+ | If you are familiar with hardware logic, you may be surprised to see " | ||
+ | |||
+ | To illustrate this consider the example: | ||
+ | <code groovy 1> | ||
+ | def a = 10 | ||
+ | def b = 20 | ||
+ | def c = 30 | ||
+ | : | ||
+ | def d = (b < a) && (c == 40) | ||
+ | </ | ||
+ | |||
+ | Since the sub expression '' | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | [[Home]] | [[Lectures]] | ||
at-m42/logical_operators.txt · Last modified: 2011/01/14 12:45 by 127.0.0.1