doc-src/TutorialI/ToyList2/ToyList1
author haftmann
Mon, 20 Apr 2009 09:32:40 +0200
changeset 30954 cf50e67bc1d1
parent 27015 f8537d69f514
child 38430 254a021ed66e
permissions -rw-r--r--
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure

theory ToyList
imports Datatype
begin

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

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