doc-src/TutorialI/ToyList2/ToyList1
author wenzelm
Sat, 15 Jan 2011 18:49:42 +0100
changeset 41580 220bc60c2387
parent 38430 254a021ed66e
permissions -rw-r--r--
link HOL-Proofs/index.html, which is not reachable from regular HOL/index.html;

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 # [])"