aboutsummaryrefslogtreecommitdiff
path: root/sample/recursive_functions/fib_9.in
blob: 7c4af1fe575db068d74f8cb64af6d326470e8d4d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Fibonacci number

// Rules
fib(ret) >< (int n)
| n == 0 => ret~0
| n == 1 => ret~1
| _ => fib(cnt1)~(n-1), fib(cnt2)~(n-2), Add(ret, cnt2)~cnt1;


// Note: Add is implemented as a built-in agent such that:
//   Add(ret, int m) ~ (int n) --> ret~(m+n);

// Nets
fib(ret)~9;
ret;