Added "material impliciation" to Booleans.
[cslatevm.git] / src / core / boolean.slate
blob49bfd12dc9c67d6040d2d1319f094c8344d6a1a2
1 "Logical NOT."
2 _@True not [False].
3 _@False not [True].
5 "Boolean-conditional evaluation."
6 _@True ifTrue: block ifFalse: _ [block do].
7 _@False ifTrue: _ ifFalse: block [block do].
9 bool@(Boolean traits) ifTrue: block
10 "Some sugaring for ifTrue:ifFalse:."
12   bool ifTrue: block ifFalse: []
15 bool@(Boolean traits) ifFalse: block
16 "Some sugaring for ifTrue:ifFalse:."
18   bool ifTrue: [] ifFalse: block
21 "Logical AND and OR. This works by having True and False be children of
22 Boolean traits."
24 _@True /\ _@True [True].
25 _@(Boolean traits) /\ _@(Boolean traits) [False].
26 _@False \/ _@False [False].
27 _@(Boolean traits) \/ _@(Boolean traits) [True].
29 "Boolean Equivalence."
30 x@(Boolean traits) eqv: y@(Boolean traits) [x == y].
32 "Boolean Exclusive OR."
33 x@(Boolean traits) xor: y@(Boolean traits) [x eqv: y not].
35 "Implication (not entailment)."
36 x@(Boolean traits) --> y@(Boolean traits) [x not \/ y].
38 bool@(Boolean traits) and: block
39 "Conditional AND, but it can return the value of the block."
40 [bool ifTrue: block ifFalse: [False]].
42 bool@(Boolean traits) or: block
43 "Conditional OR, but it can return the value of the block."
44 [bool ifTrue: [True] ifFalse: block].
46 bool@(Boolean traits) and: x and: y
47 "Sugaring."
48 [(bool and: x) and: y].
50 bool@(Boolean traits) and: x and: y and: z
51 "Sugaring."
52 [((bool and: x) and: y) and: z].
54 bool@(Boolean traits) or: x or: y
55 "Sugaring."
56 [(bool or: x) or: y].
58 bool@(Boolean traits) or: x or: y or: z
59 "Sugaring."
60 [((bool or: x) or: y) or: z].
62 "Administrative/prettying methods:" (
63 _@True printName ['True'].
64 _@False printName ['False'].