Pseudo-code that compiles to real programs
AlgoML is a simple algorithmic language for learning and teaching programming. Write your algorithm once and get working code in C, Java and Python.
factorial.aml
1Algorithm Factorial2version '1.0'3language C45function factorial(n : INT) : INT6begin7 if n <= 1 then8 return 19 end if10 return n * factorial(n - 1)11end function1213variable n : INT14variable result : INT1516begin17 read(n)18 result <- factorial(n)19 write(n, "! = ", result, "\n")20end21end algorithm
1#include <stdio.h>23int n;4int result;56int factorial(int n);78int factorial(int n) {9 if (n <= 1) {10 return 1;11 }12 return n * factorial((n - 1));13}1415int main() {16 scanf("%d", &n);17 result = factorial(n);18 printf("%d! = %d\n", n, result);19 return 0;20}
Input
5Output 5! = 120Learn AlgoML
Six short chapters. Each one has examples you can run and an exercise with its solution.
Cheat sheet
An AlgoML instruction and what it becomes in the language you pick.
AlgoML vs
| variable x : INT | int x; |
| x <- 5 | x = 5; |
| a <> b | a != b |
| a div b | a / b |
| a mod b | a % b |
| NOT ok AND x > 0 | !ok && x > 0 |
| for i in 1 to n do | for (i = 1; i <= n; i += 1) |
| tab[i] | tab[i - 1] |
| read(n) | scanf("%d", &n); |
| write("x = ", x) | printf("x = %d", x); |
Example programs
Every example from the docs lives in one public repository, with its input and expected output. Clone it and open it in VS Code.
git clone https://github.com/scmc24/algoml-examples.gitProjects using AlgoML
Course material, exercise sets and algorithm collections shared on GitHub.
No project listed yet. Yours could be the first one.
Add your projectStart in two minutes
Install the VS Code extension, open a .aml file and generate code with one click. Java 17 or later is needed.