Language guide
Control Flow
Conditionals and loops - the building blocks of any real program.
If statement - jo
jo means “if”. The condition goes between jo and the opening brace. No parentheses required.
jskkem bhai aa temp che 38 jo temp > 37 { bhai bol "Fever!" } aavjo bhai
Fever!
If-Else - jo / nahi to
nahi to means “otherwise”. It must immediately follow the closing brace of the jo block.
jskkem bhai aa age che 16 jo age >= 18 { bhai bol "Can vote" } nahi to { bhai bol "Cannot vote yet" } aavjo bhai
Cannot vote yet
Chained conditions
kemlang-py has no else if keyword. Nest another jo inside a nahi to block instead.
jskkem bhai aa score che 74 jo score >= 90 { bhai bol "A grade" } nahi to { jo score >= 75 { bhai bol "B grade" } nahi to { jo score >= 60 { bhai bol "C grade" } nahi to { bhai bol "Fail" } } } aavjo bhai
C grade
While loop - farvu / jya sudhi
farvu means “to do”. jya sudhi means “as long as”. The body executes first, then the condition is checked - similar to a do-while in other languages.
jskkem bhai aa i che 1 farvu { bhai bol i i che i + 1 } jya sudhi i <= 5 aavjo bhai
1 2 3 4 5
Infinite loop with break
Use bhai chhe (true) as the condition for an infinite loop, then break out with tame jao.
jskkem bhai aa n che 1 farvu { bhai bol n n che n + 1 jo n > 3 { tame jao } } jya sudhi bhai chhe aavjo bhai
1 2 3
Break - tame jao
tame jao (you go) exits the innermost loop immediately. Execution resumes after the loop.
jskkem bhai aa i che 0 farvu { i che i + 1 jo i == 5 { bhai bol "Found 5!" tame jao } } jya sudhi i < 100 bhai bol "Loop ended at: " + i aavjo bhai
Found 5! Loop ended at: 5
Continue - aagal vado
aagal vado (move forward) skips the rest of the current iteration and jumps straight to the condition check.
jskkem bhai // print only odd numbers 1-9 aa i che 0 farvu { i che i + 1 jo i % 2 == 0 { aagal vado } bhai bol i } jya sudhi i < 10 aavjo bhai
1 3 5 7 9
Truthy and falsy values
Conditions accept any value - not just booleans. The following values are falsy; everything else is truthy.