doc-src/IsarAdvanced/Codegen/Thy/examples/fac.ML
author haftmann
Tue, 05 Jun 2007 15:16:08 +0200
changeset 23247 b99dce43d252
parent 22751 1bfd75c1f232
child 23850 f1434532a562
permissions -rw-r--r--
merged Code_Generator.thy into HOL.thy

structure ROOT = 
struct

structure Nat = 
struct

datatype nat = Zero_nat | Suc of 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*)

end; (*struct ROOT*)