// ALNOOR Documentation
ALNOOR is a functional programming language. It may be built on Java,
but it has made emphasis on functional programming.
This is an example:
STD.FUNC.RELAY
STD.FUNC.LAMBDA
STD.IO.INT
STD.IO.CHAR
STD.IO.FORMAT
_fn int start() {
Function<Object> function = (Object... in) l> {
int x = (int)in[0], y = (int)in[1];
char op = (char)in[2];
if (op == '+') {
ret format! (
"\n{0} {1} {2} = {3}",
x, op, y,
x + y
);
} elif (op == '-') {
ret format! (
"\n{0} {1} {2} = {3}",
x, op, y,
x - y
);
} elif (op == '*') {
ret format! (
"\n{0} {1} {2} = {3}",
x, op, y,
x * y
);
} elif (op == '/') {
ret format! (
"\n{0} {1} {2} = {3}",
x, op, y,
x / y
);
}
ret "\nUnknown operation";
};
relay (
function.call (
new Object[] {
in_int (
"Enter x: "
),
in_int (
"\nEnter y: "
),
in_cha (
"\nEnter operation: "
)
}
).toString()
);
ret 0;
}
fn main() {
System.exit (
start()
);
}
To run the code, open a terminal and type:
lnrc -a path/to/main.lsmx path/to/config.vn
This program is a simple calculator that follows unconventional rules when
it comes to traditional OOP but it gets rid of the fuss that comes with OOP.
STD.FUNC.RELAY
STD.FUNC.LAMBDA
STD.IO.INT
STD.IO.CHAR
STD.IO.FORMAT
_fn int start() {
Function<Object> function = (Object... in) l> {
int x = (int)in[0], y = (int)in[1];
char op = (char)in[2];
if (op == '+') {
ret format! (
"\n{0} {1} {2} = {3}",
x, op, y,
x + y
);
} elif (op == '-') {
ret format! (
"\n{0} {1} {2} = {3}",
x, op, y,
x - y
);
} elif (op == '*') {
ret format! (
"\n{0} {1} {2} = {3}",
x, op, y,
x * y
);
} elif (op == '/') {
ret format! (
"\n{0} {1} {2} = {3}",
x, op, y,
x / y
);
}
ret "\nUnknown operation";
};
relay (
function.call (
new Object[] {
in_int (
"Enter x: "
),
in_int (
"\nEnter y: "
),
in_cha (
"\nEnter operation: "
)
}
).toString()
);
ret 0;
}
fn main() {
System.exit (
start()
);
}
lnrc -a path/to/main.lsmx path/to/config.vn