Intro
I know this code is bad, for many, many reasons. But it's working..
Please report bad things on the following gitlab repos. Thanks!
Lola
I had a dream about adding meters
with kilometers
, or km/h
with m/s
...
Now I can, with my first Rust programming language, lol
I named it "Lola", because it is "lol" => really bad implementation here, still learning...
However, it has many features:
- high precision numbers, thanks to
rug
- handles something like 95% of the SI units
- variables,
- loops,
- condition statements,
- user-defined functions,
- arrays,
- exceptions,
- scopes,
- anonymous functions,
- ... lol!
Lola code example
// Returns the given string, repeated n times.
fn repeat_str(s: string, n: int) {
let output = "";
for n { output += s }
};
// Returns an array, each value having been mapped by the given function.
fn map(a: array, mapper: function) {
let output = [];
for v in a {
output += mapper(v)
}
};
input = [ "Hi", "!" ];
output = map(input, fn(s) repeat_str(s, 3));
print(output);
input = [ 2.55 km, 50cm + 700mm ];
// Tip: the "~" operator converts a value to the given unit, if possible:
output = map(input, fn(v) v ~m);
print(output);
Output of the above lola code example:
[ HiHiHi, !!! ]
[ 2550 m, 1.2 m ]
A working inline version
Be prepared for 500 or 404 responses, sorry!
The actual website frontend is written in french... But all the docs are written in english.
Code
In order to make it usable, and to learn more about Rust, I built four different projects:
lola: the core lib
The most stable project, as far as I know, and the base of all the other projects;
lola-cli: interactive cli tool
An interactive cli tool which runs Lola code (wrapper over the core lib);
lola-server: API which runs Lola code and persist it into "sessions"
An API which can run Lola code, and persist it in a database while adding the concept of "session"
(thanks to rocket.rs and diesel.rs, and using the core lib);
lola-front: a web frontend
Powered by Symfony, which needs lola-server
(just in case: if the lola API is down, get prepared
to 500s, lol!)...