annotate python/c3/examples/functions.c3 @ 271:cf7d5fb7d9c8

Reorganization
author Windel Bouwman
date Tue, 20 Aug 2013 18:56:02 +0200
parents 6ed3d3a82a63
children
rev   line source
251
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
1
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
2 /*
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
3 Demo of function usage
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
4 */
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
5
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
6 package functiondemo;
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
7
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
8 function void main()
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
9 {
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
10 var int a, b, c;
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
11 a = 3;
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
12 b = a;
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
13 a =3;
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
14 b = fib(a + 9);
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
15 sum(a, b);
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
16 }
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
17
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
18 function int fib(int x)
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
19 {
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
20 return fib(x - 1) * x;
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
21 }
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
22
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
23 function int sum(int a, int b)
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
24 {
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
25 return a + b;
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
26 }
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents:
diff changeset
27