predefined list

[] is Nil

x # xs is Cons x xs

[x1,...xn ] is x1#....#xn#[]

xs@ys is app xs ys

fun length::" 'a list =>nat" where

"length Nil = 0"|"length (Cons x xs) =Suc(length xs)"

fun map::" ('a => 'b)  => 'a list => 'b list" where

"map f Nil = Nil"|"map f(Cons x xs) = Cons(f x)(map f xs)"

fun hd::"'a list ⇒'a" where
"hd (x # xs) = x"

fun tl::"'a list ⇒ 'a list" where
"tl [] = []"|"tl (x#xs) = xs"

posted on 2017-11-22 21:18  apple平哥  阅读(74)  评论(0编辑  收藏  举报

导航