Conditionals & Comparisons
if x then y else z

If/else statements

Like programming languages, Soulver supports conditionals. The main difference is that in Soulver a conditional is expressed over a single line
1
earnings = $45k | $45,000.00
2
3
if earnings > $30k then tax = 20% else tax = 5%
4
5
My tax paid: earnings × tax | $9,000.00
Copied!
You may omit the else statement

Comparison operators & booleans

Soulver supports standard "C" style comparison operators. Booleans are either true or false.
Name
Operator
Equal to
==
Not equal to
!=
Greater than
>
Less than
<
Greater than or equal to
>=
Less than or equal to
<=
You may assign a variable a boolean value directly
1
cost = $500
2
discount = true
3
if discount then cost = cost - 10%
4
cost | $450.00
Copied!
You can also use comparison operators outside if statements
1
20km == 20,000 m | true
2
11:30 am < 9:30 am | false
Copied!
Last modified 1yr ago