doc-src/TutorialI/ToyList/ToyList1
author blanchet
Tue, 28 Aug 2012 17:17:25 +0200
changeset 48977 ae12b92c145a
parent 48966 6e15de7dd871
permissions -rw-r--r--
updated NEWS and CONTRIBUTORS

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