Foldr Zen Zone

MaSH

Arithmetic Operators

MaSH can perform standard arithmetic operations.

Natural

mash
# Declare two numeric variables

set a to 4
printline "a is set to {{ a }}"

set b to 9
printline "b is set to {{ b }}"

# Add b to a
printline "a plus b is {{ a + b }}"

# Subtract b from a
printline "b subtract a is {{ b - a }}"

# Multiply a by b
printline "a multplied by b is {{ a * b }}"

# Divide b by a
printline "b divided by a is {{ b / a }}"

# Remainder of a divided by b
printline "remainder of a divided by b is {{ a % b }}"

# Raise b to power of a
printline "b to the power of a is {{ b ** a }}"

Standard

mash
# Declare two numeric variables

a = 4
printline("a is set to {{ a }}")

b = 9
printline("b is set to {{ b }}")

# Add b to a
printline("a plus b is {{ a + b }}")

# Subtract b from a
printline("b subtract a is {{ b - a }}")

# Multiply a by b
printline("a multplied by b is {{ a * b }}")

# Divide b by a
printline("b divided by a is {{ b / a }}")

# Remainder of a divided by b
printline("remainder of a divided by b is {{ a % b }}")

# Raise b to power of a
printline("b to the power of a is {{ b ** a }}")

Output

output
a is set to 4
b is set to 9
a plus b is 13
b subtract a is 5
a multplied by b is 36
b divided by a is 2.25
remainder of a divided by b is 4
b to the power of a is 6561

Operators can also be chained together. They follow normal order of operations and you should use parentheses to indicate an alternative order:-

Natural

mash
# Declare two numeric variables

set a to 5
set b to 10

# This will print 7.5

printline b - a / 2

# This will print 2.5

printline (b - a) / 2

Standard

mash
# Declare two numeric variables

a = 5
b = 10

# This will print 7.5

printline(b - a / 2)

# This will print 2.5

printline((b - a) / 2)

Output

output
7.5
2.5
Every journey begins with a single step

Declutter, Focus, Zone In. Repeat.

Begin your File Zen Journey