Ackermann function: Difference between revisions

→‎{{header|Coq}}: Updated Coq examples
(→‎{{header|Coq}}: Updated Coq examples)
Line 2,803:
 
=={{header|Coq}}==
===Standard===
<syntaxhighlight lang="coq">Require Import Arith.
Fixpoint A m := fix A_m n :=
match m with
Line 2,812 ⟶ 2,813:
| S pn => A pm (A_m pn)
end
end.</syntaxhighlight>
</syntaxhighlight>
 
===Using fold===
<syntaxhighlight lang="coq">Require Import Utf8.
Require Import Utf8.
 
Section FOLD.
Context {A : Type} (f : A → A) (a : A).
Fixpoint fold (n : nat) : A :=
match n with
| O => a
| S n'k => f (fold n'k)
end.
End FOLD.
92

edits