]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/nlibrary/basics/list2.ma
some results on co-composition ...
[helm.git] / matita / matita / nlibrary / basics / list2.ma
1 (**************************************************************************)
2 (*       ___                                                              *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||         The HELM team.                                      *)
8 (*      ||A||         http://helm.cs.unibo.it                             *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU General Public License Version 2                  *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 include "basics/list.ma".
16 include "arithmetics/nat.ma".
17
18 nlet rec length (A:Type) (l:list A) on l ≝ 
19   match l with 
20     [ nil ⇒ 0
21     | cons a tl ⇒ S (length A tl)].
22
23 notation "|M|" non associative with precedence 65 for @{'norm $M}.
24 interpretation "norm" 'norm l = (length ? l).
25
26 nlet rec nth n (A:Type) (l:list A) (d:A)  ≝  
27   match n with
28     [O ⇒ hd A l d
29     |S m ⇒ nth m A (tail A l) d].
30