aboutsummaryrefslogtreecommitdiff
path: root/sample/recursive_functions/fib_9_abbr.in
blob: 57a8c628c990aed051ce417a6852675207ab7cd7 (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
| _ => cnt1 << fib(n-1), cnt2 << fib(n-2), ret << Add(cnt1,cnt2);


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

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