-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfib.mapal
More file actions
38 lines (36 loc) · 1.1 KB
/
Copy pathfib.mapal
File metadata and controls
38 lines (36 loc) · 1.1 KB
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
37
38
// fib — the iteration idiom (S24b, Sapir's ask).
//
// Cycles live in the DATAFLOW graph (`loop`), never the call graph:
// a recursive `fib` is rejected by design with the teaching diagnostic
// L1008: recursive call cycle: fib -> fib (recursion is out of Core)
// — the rejection-over-analysis rule that keeps "the code IS the graph" true.
//
// Bonus the graph gives for free (S24 parallel orchestrator): the three
// calls below are three independent paths — path_plan emits three tasks
// with ZERO dependency edges, so they compute CONCURRENTLY on the pool
// while the prints checkpoint in program order.
//
// Oracle-verified: 55 / 832040 / 1134903170 (fib(45), exact in i32).
fn fib(n: i32) -> i32 {
mut a: i32 <- 0;
mut b: i32 <- 1;
mut i: i32 <- 0;
loop {
(i < n) -> {
-true-> {
a + b -> t;
b -> a;
t -> b;
i + 1 -> i;
-> loop;
}
-false-> a -> out;
}
}
out -> ret;
}
fn main() {
10 -> fib -> println;
30 -> fib -> println;
45 -> fib -> println;
}