X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=matita%2Fmatita%2Flib%2Fbasics%2Flist.ma;h=798f5762933b3fd9c1d2153761e08d33e31dc689;hb=fe4df66869250943913c7fa534bb22305a320683;hp=4d99c59c8e3364f4ef0b71fd3c1227ad444f9bc1;hpb=53452958508001e7af3090695b619fe92135fb9e;p=helm.git diff --git a/matita/matita/lib/basics/list.ma b/matita/matita/lib/basics/list.ma index 4d99c59c8..798f57629 100644 --- a/matita/matita/lib/basics/list.ma +++ b/matita/matita/lib/basics/list.ma @@ -10,7 +10,7 @@ V_______________________________________________________________ *) include "basics/types.ma". -include "basics/bool.ma". +include "arithmetics/nat.ma". inductive list (A:Type[0]) : Type[0] := | nil: list A @@ -114,6 +114,21 @@ match l1 with | cons a tl ⇒ (map ??(dp ?? a) (g a)) @ dprodl A f tl g ]. +(**************************** length ******************************) + +let rec length (A:Type[0]) (l:list A) on l ≝ + match l with + [ nil ⇒ 0 + | cons a tl ⇒ S (length A tl)]. + +notation "|M|" non associative with precedence 60 for @{'norm $M}. +interpretation "norm" 'norm l = (length ? l). + +let rec nth n (A:Type[0]) (l:list A) (d:A) ≝ + match n with + [O ⇒ hd A l d + |S m ⇒ nth m A (tail A l) d]. + (**************************** fold *******************************) let rec fold (A,B:Type[0]) (op:B → B → B) (b:B) (p:A→bool) (f:A→B) (l:list A) on l :B ≝