Lungo Programming Language
Lungo is a dynamic programming language created just for fun.
Getting Started
Installations:
pip install --upgrade lungo
Usage:
lungo [FILE]
Syntax
You need to define variable with let statement before assignment/reference:
let x = 2;
Assign a previously defined variable:
let x = 0;
x = 42;
Define a function:
func inc(x) {
return x + 1
}
The last statement in each code block is a result of the block evaluation, so in the previous example return is not
necessary:
func inc(x) {
x + 1
}
Function definitions are just an expressions. The previous line is equivalent to:
let inc = func(x) { x + 1 }
Conditional execution:
if ( x > 0 ) {
print("Positive")
} elif ( x < 0 ) {
print("Negative")
} else {
print("X is 0")
}
while-loop:
let x = 0;
while ( x < 10 ) {
x = x + 1;
print(x)
}
for-loop:
for ( x in [1,2,3] ) {
print(x)
}
Almost everything is expression in Lungo (except for return and let statements):
let x = 10;
let message = if(x > 5) { "big" } else { "small" };
print(message)
Output:
big
Another example:
func hello(value) {
print("Hello " + value)
};
let who = "world";
hello(while(who.size < 20) { who = who + " and " + who })
Output:
Hello world and world and world and world
NOTE: A bit of syntactic bitterness. In the current implementation each statement in a code block (except for the
last one) must be followed by a semicolon ;. So the ; must be present after such expressions as function
definitions, for and while-loops, etc. This will be fixed in a future release.
Supported binary operators: +, -, *, /, &&, ||, ==, !=, >, >=, <, <=
Unary operators: !, -
Higher order functions:
func inc(x) {
x + 1
};
func comp(f, g) {
func(x) {
f(g(x))
}
}
print(comp(inc, inc)(0))
Output:
2
More sophisticated example:
func pair(a, b) {
func(acceptor) {
acceptor(a, b)
}
};
func first(p) {
p(func(a,b) { a })
};
func second(p) {
p(func(a,b) { b })
};
let p = pair(1, 2);
print(first(p));
print(second(p));
Output:
1
2
Release files for lungo 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lungo-0.1.2.tar.gz | 19.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lungo-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 42.1 kB
Release files / lungo-0.1.2.tar.gz
| Download URL | lungo-0.1.2.tar.gz |
|---|---|
| Size | 19.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
46c9f876d366eed8c844e22e26145b8abee1878f59a025e4cc04a069ac1b608f
|
|
BLAKE2b-256 checksum How to use checksums |
cc98bb86082cb129ebb470a92e531ac649a46089131ae2a98c1c4dd0099704f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.8.10 Linux/5.13.0-28-generic
|
Release files / lungo-0.1.2-py3-none-any.whl
| Download URL | lungo-0.1.2-py3-none-any.whl |
|---|---|
| Size | 22.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1cbb04db69e527b189a1c1c467d4d57eb749465a3b76877be4dceee8b2ef6677
|
|
BLAKE2b-256 checksum How to use checksums |
e58d8272c19e6b4bb648d4b548eaaa2e3537381209a4ee8e03c327f49119a426
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.8.10 Linux/5.13.0-28-generic
|