asomiya 0.2.0

Control flow

Variables

A variable is a name for a value. Create one with ধৰা (dhora), which means “suppose” or “let”, just like in Assamese maths books: ধৰা হওক x = ৫.

Create a variable

ধৰা নগৰ = "গুৱাহাটী"
ধৰা জনসংখ্যা = ১১২৮০০০
কোৱা(নগৰ, জনসংখ্যা)
Output
গুৱাহাটী ১১২৮০০০
dhora nogor = "Guwahati"
dhora jonoxonkhya = 1128000
kowa(nogor, jonoxonkhya)
Output
Guwahati 1128000

Names can use Assamese or English letters, digits and _, but can’t start with a digit. Assamese conjuncts like ক্ষ work as you’d expect.

Change a value

After a variable exists, assign a new value with = (without ধৰা):

ধৰা গণনা = ০
গণনা = গণনা + ১
গণনা = গণনা + ১
কোৱা(গণনা)
Output
২
dhora gonona = 0
gonona = gonona + 1
gonona = gonona + 1
kowa(gonona)
Output
2

Watch out

Using a name before creating it is an error (R001). So is creating the same name twice in the same block (R002).

Variables without a value

A variable created without a value holds খালী (khali, “empty”):

ধৰা ফল
কোৱা(ফল)
Output
খালী
dhora fol
kowa(fol)
Output
khali

Scope

A variable lives inside the block { … } where it was created. Code inside a block can see the variables outside it, but not the other way round:

ধৰা বাহিৰ = "বাহিৰ"
যদি (সঁচা) {
    ধৰা ভিতৰ = "ভিতৰ"
    কোৱা(বাহিৰ, ভিতৰ)
}
কোৱা(বাহিৰ)
Output
বাহিৰ ভিতৰ
বাহিৰ
dhora bahir = "bahir"
jodi (xosa) {
    dhora bhitor = "bhitor"
    kowa(bahir, bhitor)
}
kowa(bahir)
Output
bahir bhitor
bahir

Ending statements

Each statement ends at the end of the line. To put several on one line, separate them with ; or the danda ।:

ধৰা ক = ১। ধৰা খ = ২। কোৱা(ক + খ)
Output
৩
dhora k = 1; dhora kh = 2; kowa(k + kh)
Output
3