Skip to content

Expressions and Operators

This document covers how to compute and compare values in Junlang.

What is an expression?

An expression is a piece of code that produces a value. For example, 1 + 2 is an expression, and its result is the value 3.

The simplest expression in Junlang is a number by itself.

junlang

This code alone is an expression, and its value is 1. By adding operators, you can build more complex expressions.

Arithmetic Operators

JunlangMeaningCommon Equivalent
~Addition+
.Multiplication*
..Exponentiation**
#Division/
junlang
~오오

1 + 2, so the result is 오오오(3).

junlang
오오.오오오

2 × 3, so the result is 오오오오오오(6).

junlang
오오..오오오

, so the result is 오오오오오오오오(8).

There is no subtraction operator

Junlang has no dedicated subtraction operator. Instead, combine the negative sign ? with addition ~.

junlang
~?오

1 + (-1)오?(0)

What happens when you divide by 0 or raise to a decimal power?

An error occurs. (See: Errors)

Division by zero:

text
이건 기하반도 안 하는 실수인데?

Decimal exponent:

text
준서가 어렵대

Comparison Operators

JunlangMeaningCommon Equivalent
@Equal to==
!@Not equal to!=
Less than<
Greater than>
ㅁ@Less than or equal to<=
ㅊ@Greater than or equal to>=

The result of a comparison operator is always (1, true) or 오?(0, false).

junlang
@

1 == 1(true)

junlang
오오오오오

2 < 3(true)

junlang
오오오ㅁ@오오

3 <= 2오?(false)

Don't confuse !@ with variables

Since ! is also used as a variable name, the following two pieces of code have completely different meanings.

CodeInterpretation
!@오오variable 1 == 2
!!@오오variable 1 != 2

For detailed rules, see Inline Writing Rules.

Unary Operators

Operators that require only one operand.

JunlangMeaningCommon Equivalent
?Negative sign-
!Logical NOT!
junlang
?오오

-2

junlang
!

not 1오?(0)

junlang
!오?

not 0(1)

The dual meaning of !

! is both a unary operator and a variable name. The interpreter distinguishes between them based on context.

CodeInterpretation
!오not 1 (negation operator)
!~오variable 1 + 1 (variable name)

If ! is followed by a value, it's the negation operator; if followed by an operator, it's a variable name.

Operator Precedence

When an expression contains multiple operators, those with higher precedence are computed first.

RankOperatorDescription
1 (highest)?, !Unary operators
2..Exponentiation
3., #Multiplication, Division
4~Addition
5 (lowest)@, !@, , , ㅁ@, ㅊ@Comparison operators

Operators with the same precedence are evaluated left to right (left-associative).

junlang
~오오.오오오

1 + 2 × 31 + 6오오오오오오오(7)

junlang
오오오#오오#오오

(3 ÷ 2) ÷ 20.75

Step-by-step walkthrough

오~오오.오오오 (1 + 2 × 3)

  1. Multiplication has higher precedence than addition, so it's computed first.
    • 오오.오오오2 × 3오오오오오오(6)
  2. Then addition.
    • 오~오오오오오오1 + 6오오오오오오오(7)

오오..오오오.오오 (2³ × 2)

  1. Exponentiation has higher precedence than multiplication, so it's computed first.
    • 오오..오오오오오오오오오오오(8)
  2. Then multiplication.
    • 오오오오오오오오.오오8 × 2오 오오오오오(16)

TIP

To explicitly change precedence, use 준, 서.

Assignment Operator

Used to store the result of an expression in a variable.

junlang
[expression]~준서[variable name]ㅋ

This operator assigns [expression] to [variable name].

is not part of the assignment operator

acts as a terminator at the end of a statement. (Or as a decimal point) See Statements and Blocks for details.

junlang
~준서!ㅋ

Assigns (1) to variable 1 (!).

junlang
오오오~준서!!ㅋ

Assigns 오오오(3) to variable 2 (!!).

junlang
~오오~준서!!!ㅋ

Assigns 오~오오(1 + 2 = 3) to variable 3 (!!!). The expression is evaluated first, then the result is stored in the variable.

TIP

For more on variables, see Variables.