doc-src/TutorialI/ToyList2/ToyList1
author wenzelm
Fri, 15 Jul 2005 15:44:11 +0200
changeset 16860 43abdba4da5c
parent 15141 a95c2ff210ba
child 26729 43a72d892594
permissions -rw-r--r--
* Pure/library.ML: several combinators for linear functional transformations; * Pure/library.ML: canonical list combinators fold, fold_rev, and fold_yield; * Pure/term.ML: combinators fold_atyps, fold_aterms, fold_term_types, fold_types;

theory ToyList
imports PreList
begin

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

consts app :: "'a list => 'a list => 'a list"   (infixr "@" 65)
       rev :: "'a list => 'a list"

primrec
"[] @ ys       = ys"
"(x # xs) @ ys = x # (xs @ ys)"

primrec
"rev []        = []"
"rev (x # xs)  = (rev xs) @ (x # [])"