1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 include "basics/list.ma".
16 include "arithmetics/nat.ma".
18 let rec length (A:Type[0]) (l:
\ 5a href="cic:/matita/basics/list/list.ind(1,0,1)"
\ 6list
\ 5/a
\ 6 A) on l ≝
20 [ nil ⇒
\ 5a title="natural number" href="cic:/fakeuri.def(1)"
\ 60
\ 5/a
\ 6
21 | cons a tl ⇒
\ 5a href="cic:/matita/arithmetics/nat/nat.con(0,2,0)"
\ 6S
\ 5/a
\ 6 (length A tl)].
23 notation "|M|" non associative with precedence 60 for @{'norm $M}.
24 interpretation "norm" 'norm l = (length ? l).
26 let rec nth n (A:Type[0]) (l:
\ 5a href="cic:/matita/basics/list/list.ind(1,0,1)"
\ 6list
\ 5/a
\ 6 A) (d:A) ≝
28 [O ⇒
\ 5a href="cic:/matita/basics/list/hd.def(1)"
\ 6hd
\ 5/a
\ 6 A l d
29 |S m ⇒ nth m A (
\ 5a href="cic:/matita/basics/list/tail.def(1)"
\ 6tail
\ 5/a
\ 6 A l) d].