src/Doc/Tutorial/ToyList/ToyList1
author nipkow
Thu, 23 Jan 2014 16:02:02 +0100
changeset 55126 9f9db4e6fabc
parent 48985 5386df44a037
permissions -rw-r--r--
merged

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