src/Doc/Tutorial/ToyList/ToyList1
author haftmann
Thu, 01 May 2014 09:30:36 +0200
changeset 56812 baef1c110f12
parent 48985 5386df44a037
permissions -rw-r--r--
centralized upper/lowercase name mangling

theory ToyList
imports Datatype
begin

datatype 'a list = Nil                          ("[]")
                 | Cons 'a "'a list"            (infixr "#" 65)

(* This is the append function: *)
primrec app :: "'a list => 'a list => 'a list"  (infixr "@" 65)
where
"[] @ ys       = ys" |
"(x # xs) @ ys = x # (xs @ ys)"

primrec rev :: "'a list => 'a list" where
"rev []        = []" |
"rev (x # xs)  = (rev xs) @ (x # [])"