• R/O
  • SSH
  • HTTPS

descartes: Commit


Commit MetaInfo

Revision1652 (tree)
Time2013-01-01 14:28:08
Authorhniwa

Log Message

update of example

Change Summary

Incremental Difference

Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
--- trunk/descartes/example/translator/pl0.4/f2.c (revision 1651)
+++ trunk/descartes/example/translator/pl0.4/f2.c (revision 1652)
@@ -1,30 +1,28 @@
11 #include <stdio.h>
22 #include <stdlib.h>
33
4-int main()
4+int main()
55 {
6-const int n = 10;
7-int f(const int n)
8-{
9-{
10-if (n <= 1) {
11-return 1;
6+ int f(const int n) {
7+ {
8+ if (n <= 1) {
9+ return 1;
10+ }
11+ const int a = f(n - 2), b = f(n - 1);
12+ const int c = a + b;
13+ return c;
14+ }
15+ }
16+ {
17+ printf("%d ", f(1));
18+ printf("\n");
19+ printf("%d ", f(2));
20+ printf("\n");
21+ printf("%d ", f(3));
22+ printf("\n");
23+ printf("%d ", f(4));
24+ printf("\n");
25+ printf("%d ", f(5));
26+ printf("\n");
27+ }
1228 }
13-const int a = f(n-2), b = f(n-1);
14-const int c = a+b;
15-return c;
16-}
17-}
18-{
19-printf("%d ", f(1));
20-printf("\n");
21-printf("%d ", f(2));
22-printf("\n");
23-printf("%d ", f(3));
24-printf("\n");
25-printf("%d ", f(4));
26-printf("\n");
27-printf("%d ", f(5));
28-printf("\n");
29-}
30-}
Show on old repository browser