aboutsummaryrefslogtreecommitdiffhomepage
path: root/theories/NArith/BinNatDef.v
diff options
context:
space:
mode:
authorGravatar letouzey <letouzey@85f007b7-540e-0410-9357-904b9bb8a0f7>2011-05-05 15:12:53 +0000
committerGravatar letouzey <letouzey@85f007b7-540e-0410-9357-904b9bb8a0f7>2011-05-05 15:12:53 +0000
commitf1c9bb9d37e3bcefb5838c57e7ae45923d99c4ff (patch)
treebea03f10fbc3ce1d19df579fc48b5b951826ea3e /theories/NArith/BinNatDef.v
parent57dfd75f85278fab4d5691299d3b34d0595f97ca (diff)
Modularization of Nnat
For instance, nat_of_Nplus is now N2Nat.inj_add Note that we add an iter function in BinNat.N git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@14105 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'theories/NArith/BinNatDef.v')
-rw-r--r--theories/NArith/BinNatDef.v16
1 files changed, 12 insertions, 4 deletions
diff --git a/theories/NArith/BinNatDef.v b/theories/NArith/BinNatDef.v
index 535f88c86..ec91dc5db 100644
--- a/theories/NArith/BinNatDef.v
+++ b/theories/NArith/BinNatDef.v
@@ -351,14 +351,22 @@ Definition testbit a n :=
Definition to_nat (a:N) :=
match a with
- | 0 => O
- | Npos p => Pos.to_nat p
+ | 0 => O
+ | Npos p => Pos.to_nat p
end.
Definition of_nat (n:nat) :=
match n with
- | O => 0
- | S n' => Npos (Pos.of_succ_nat n')
+ | O => 0
+ | S n' => Npos (Pos.of_succ_nat n')
+ end.
+
+(** Iteration of a function *)
+
+Definition iter (n:N) {A} (f:A->A) (x:A) : A :=
+ match n with
+ | 0 => x
+ | Npos p => Pos.iter p f x
end.
End N. \ No newline at end of file