doc-src/IsarAdvanced/Codegen/Thy/examples/fac.ML
author wenzelm
Thu, 11 Oct 2007 16:05:53 +0200
changeset 24970 050afeec89a7
parent 24421 acfb2413faa3
child 25160 72fcf0832cfe
permissions -rw-r--r--
renamed Syntax.XXX_mode to Syntax.mode_XXX; moved ProofContext.pp to Syntax.pp;

structure Nat = 
struct

datatype nat = Suc of nat | Zero_nat;

fun plus_nat (Suc m) n = plus_nat m (Suc n)
  | plus_nat Zero_nat n = n;

fun times_nat (Suc m) n = plus_nat n (times_nat m n)
  | times_nat Zero_nat n = Zero_nat;

end; (*struct Nat*)

structure Codegen = 
struct

fun fac (Nat.Suc n) = Nat.times_nat (Nat.Suc n) (fac n)
  | fac Nat.Zero_nat = Nat.Suc Nat.Zero_nat;

end; (*struct Codegen*)