ginger/README.md

29 lines
346 B
Markdown
Raw Normal View History

# Ginger
2017-07-12 00:52:07 +00:00
Fibonacci function in ginger:
2017-07-12 00:52:07 +00:00
```
fib {
decr { out add(in, -1) }
2017-07-12 00:52:07 +00:00
out {
n 0(in),
a 1(in),
b 2(in),
2017-07-12 00:52:07 +00:00
out if(
zero?(n),
a,
recur(decr(n), b, add(a,b))
)
2017-07-12 00:52:07 +00:00
}(in, 0, 1)
}
```
2017-07-12 00:52:07 +00:00
Usage of the function to generate the 6th fibonnaci number:
2017-07-12 00:52:07 +00:00
```
fib(5)
```