How to express programs as data structures in ocaml?

How to represent simple programs as data structures.

How to write programs that process programs.


mutable no declaring vars (like py)

X = 6;
ANS = 1;
whileNZ (x) {
  ANS = ANS * X;
  X = X + -1;

Evaluates a factorial.

Result of computation is to look in the memory location of X.

What is a valid program in simple?

  • Legal syntax
  • Legal semantics