Logic Functions#
and
- Logic AND#
Evaluate logic AND of the arguments. Must have at least two arguments. If more than two arguments are given, all are ANDed.
import ison
dicData = {
"__locals__": {
"lA": [True, False, True]
},
"result": "$and{*$lA}"
}
dicResult = ison.run.Run(xData=dicData)
print(ison.run.ToString(dicResult))
{
"result": false
}
eq
- Equal#
Test for equality of all arguments.
import ison
dicData = {
"__locals__": {
"lA": [1, 1.0, 1, 1]
},
"result a==a": "$eq{a, a}",
"result a==b": "$eq{a, b}",
"result list": "$eq{*$lA}"
}
dicResult = ison.run.Run(xData=dicData)
print(ison.run.ToString(dicResult))
{
"result a==a": true,
"result a==b": false,
"result list": true
}
if
- Conditional Parsing#
$if{[condition], [true clause], [false clause]}
If the result of the parsing of the condition is true, the second argument is parsed and the result is returned. Otherwise, the second argument is parsed. Note that the true and false clauses are only parsed, after the appropriate condition has been evaluated. The respectively other argument is not parsed at all.
import ison
dicData = {
# Since the condition is true, only the second argument is parsed,
# and therefore only 'Hello' is printed.
"result 1": "$if{true, $print{Hello}, $print{World}}",
"result 2": "$if{false, $print{To}, $print{Day}}"
}
dicResult = ison.run.Run(xData=dicData)
print(ison.run.ToString(dicResult))
Hello
Day
{
"result 1": "Hello",
"result 2": "Day"
}
not
- Logic NOT#
Evaluate logic NOT of the argument. Must have exactly 1 argument.
import ison
dicData = {
"__locals__": {
"iA": 0, "fA": 0.0, "bA": False
},
"result": {"iB": "$not{$iA}", "fB": "$not{$fA}", "bB": "$not{$bA}"},
}
dicResult = ison.run.Run(xData=dicData)
print(ison.run.ToString(dicResult))
{
"result": {
"iB": true,
"fB": true,
"bB": true
}
}
or
- Logic OR#
Evaluate logic OR of the arguments. Must have at least two arguments. If more than two arguments are given, all are ORed.
import ison
dicData = {
"__locals__": {
"lA": [True, False, True]
},
"result": "$or{*$lA}"
}
dicResult = ison.run.Run(xData=dicData)
print(ison.run.ToString(dicResult))
{
"result": true
}