AlgoML
FR

Generated code, language by language

What each AlgoML instruction becomes in C, Java and Python.

This page shows how the generator translates each part of the language. It helps to read the generated code and to move from AlgoML to a real language.

Types

AlgoMLCJavaPython
INTintintint
REALdoubledoublefloat
STRINGchar[]Stringstr
BOOLEANboolbooleanbool
ARRAY[5] of INTint t[5]int[] t = new int[5]list

Instructions

AlgoMLCJavaPython
x <- 5x = 5;x = 5;x = 5
read(n)scanf("%d", &n);n = scanner.nextInt();n = int(input())
write("n = ", n)printf("n = %d", n);System.out.print("n = " + n);print("n = ", n, sep="", end="")
if c then ... end ifif (c) { ... }if (c) { ... }if c:
for i in 1 to n dofor (i = 1; i <= n; i += 1)for (i = 1; i <= n; i += 1)for i in range(1, n + 1):
tab[i]tab[i - 1]tab[i - 1]tab[i - 1]
while c dowhile (c)while (c)while c:
repeat ... until cdo { ... } while (!(c));do { ... } while (!(c));while True: and break

Operators

AlgoMLCJavaPython
<>!=!=!=
a div ba / ba / ba // b
a mod ba % ba % ba % b
AND, OR, NOT&&, ||, !&&, ||, !and, or, not

Program layout

  • C: global variables at the top, then the functions, then main.
  • Java: one class named after the algorithm, with static fields and methods, and a Scanner for input.
  • Python: one function per AlgoML function, and a main() function called at the end of the file.

Every example on this site shows the real generated code: switch the tabs to compare.

Report a problem with this page