doc-src/IsarAdvanced/Codegen/Thy/examples/fac_case.ML
author wenzelm
Fri, 19 Jan 2007 22:10:35 +0100
changeset 22124 27b674312b2f
parent 21994 dfa5133dbe73
child 22751 1bfd75c1f232
permissions -rw-r--r--
renamed Isar/isar_output.ML to Thy/thy_output.ML; tuned messages; Antiquote.scan_arguments (moved from here); moved ML context stuff to from Context to ML_Context;

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 y = y;

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 n =
  (case n of Nat.Zero_nat => Nat.Suc Nat.Zero_nat
     | Nat.Suc m => Nat.times_nat n (fac m));

end; (*struct Codegen*)

end; (*struct ROOT*)