-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathNotationModule.v
More file actions
36 lines (31 loc) · 918 Bytes
/
Copy pathNotationModule.v
File metadata and controls
36 lines (31 loc) · 918 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
From Coq Require Import List.
Section Array.
Context (A:Type).
Notation list := (list A).
Implicit Types (l:list) (n:nat) (x:A).
Fixpoint assign l n x' : list :=
match l with
| nil => nil
| x::xs => match n with
| 0 => x'::xs
| S n => x::assign xs n x'
end
end.
Fixpoint index l n : option A :=
match l with
| nil => None
| x::xs => match n with
| 0 => Some x
| S n => index xs n
end
end.
End Array.
Module ArrayNotations.
Declare Scope array_scope.
Delimit Scope array_scope with array.
Notation "l [ i := v ]" := (assign l i v) (at level 10, left associativity) : array_scope.
Notation "l [ i ]" := (index l i) (at level 11, no associativity) : array_scope.
End ArrayNotations.
(* to use ArrayNotations: *)
Import ArrayNotations.
Local Open Scope array_scope. (* optional *)