This language is designed to be high-level (Python-like), dynamically typed, and functional, suitable for solving competitive programming problems and writing ai scripts. It emphasizes usability, expressive power, and functional programming principles like immutability where practical, while supporting a REPL for interactive development.
The language supports a minimal yet expressive set of built-in data types.
- Numbers: Integers or floating-point values in decimal notation.
- Examples:
10,3.14,-42.5
- Examples:
- Booleans: Logical values.
- Examples:
True,False
- Examples:
- Strings: Sequences of characters enclosed in double quotes.
- Examples:
"Hello, world!",""
- Examples:
- Arrays: Ordered, mutable collections enclosed in square brackets.
- Examples:
[1, 2, 3],["a", 2, True]
- Examples:
- Dictionaries: Key-value mappings enclosed in curly braces.
- Examples:
{ "key": 42, "flag": True }
- Examples:
Variables are dynamically typed and lexically scoped. They are declared with let and can be reassigned with assign.
- Declaration:
let <name> = <expression>- Example:
let x = 10
- Example:
- Reassignment:
<name> assign <expression>- Example:
x assign 20
- Example:
- Scope: Variables are lexically scoped within their enclosing block or function.
Supported operators follow standard mathematical precedence:
+(addition),-(subtraction),*(multiplication),/(division),**(exponentiation),rem(remainder)- Example:
10 + 5 * 2evaluates to20(multiplication precedes addition). - Precedence:
()>**(right-associative) >* / rem(left-associative) >+ -(left-associative)
<,>,<=,>=,==,!=- Example:
10 < 20evaluates toTrue
and,or,not- Example:
True and not Falseevaluates toTrue
let(declaration),assign(reassignment)- Example:
let x = 10x assign x + 1
Control flow constructs use {} blocks for clarity and consistency.
- Syntax:
if (<condition>) { <block> } [else { <block> }] - Example:
if (x < 0) { print "Negative" } else { print "Non-negative" }
- Syntax:
while (<condition>) { <block> } - Example:
let x = 0 while (x < 5) { print x x assign x + 1 }
- Syntax:
for (let i = start to end [step s]) { <block>} - Example:
for (let i = 1 to 5) { print i }
- Syntax:
print <expression> - Example:
print "Hello, world!" - Outputs to the console; supports all data types.
Support for first-class functions, proper closures, and included tail-call elimination for recursion.
- Syntax:
func <name>(<param1>, <param2>, ...) { <block> } - Example:
func add(a, b) { return a + b }
- Syntax:
return <expression> - Example:
func square(x) { return x * x }
Functions can be assigned to variables or passed as arguments.
- Example:
let double = func(x) { return x * 2 } print double(5) // Outputs: 10
Functions capture their lexical environment.
- Example:
func counter() { let count = 0 return func() { count assign count + 1 return count } } let c = counter() print c() // Outputs: 1 print c() // Outputs: 2
The language provides error messages with line location and a REPL that doesn’t crash on errors.
- Division by zero: Raises
ZeroDivisionErrorwith line number and suggestion (e.g., "Check divisor"). - Syntax errors: Flags malformed expressions with location (e.g.,
5 +→ "SyntaxError at line 1: incomplete expression"). - Example REPL session:
> let x = 10 / 0 [line 1] Error at '/': Division by zero > print x [line 1] Error at 'x': Undefined variable 'x'
func fib(n) {
if (n <= 1) {
return n
}
return fib(n - 1) + fib(n - 2)
}
let x = 10
print "Fibonacci of " + x + " is " + fib(x)