2023-07-01 11:58:00 -04:00
|
|
|
|
^|EMal has a dedicated Logical type expressed by the logic keyword.
|
|
|
|
|
|
|It's not nullable and holds the two values false and true.
|
|
|
|
|
|
|There are no implicit conversions, but explicit conversions
|
|
|
|
|
|
|from/to int (0,1) or text ("⊥", "⊤") are allowed.
|
|
|
|
|
|
|^
|
2024-10-16 18:07:41 -07:00
|
|
|
|
logic booleanTrue ← true
|
|
|
|
|
|
logic booleanFalse ← false
|
2023-07-01 11:58:00 -04:00
|
|
|
|
if 2 > 1 and true and not false
|
2024-10-16 18:07:41 -07:00
|
|
|
|
writeLine("true: ", true, ", false: ", false)
|
2023-07-01 11:58:00 -04:00
|
|
|
|
end
|
2024-10-16 18:07:41 -07:00
|
|
|
|
if false æ logic!0
|
2023-07-01 11:58:00 -04:00
|
|
|
|
writeLine("explicit conversion from integer")
|
|
|
|
|
|
end
|
2024-10-16 18:07:41 -07:00
|
|
|
|
if true æ logic!"⊤"
|
2023-07-01 11:58:00 -04:00
|
|
|
|
writeLine("explicit conversion from text")
|
|
|
|
|
|
end
|
|
|
|
|
|
writeLine(int!true) # is one
|
|
|
|
|
|
writeLine(text!false) # is "⊥"
|