parent
3ef69920c7
commit
ec443899c3
@ -1,24 +1,24 @@ |
|||||||
* A function which accepts a number N and returns the Nth fibonacci number |
* A function which accepts a number N and returns the Nth fibonacci number |
||||||
{ |
{ |
||||||
* We are passing a tuple of inputs into a graph here, such that the graph is |
* We are passing a tuple of inputs into a graph here, such that the graph is |
||||||
* evaluated as an anonymous function. That anonymous function uses recur |
* evaluated as an anonymous function. That anonymous function uses !recur |
||||||
* internally to compute the result. |
* internally to compute the result. |
||||||
out = { |
!out = { |
||||||
|
|
||||||
* A little helper function. |
* A little helper function. |
||||||
decr = { out = add < (in, -1) }; |
decr = { !out = !add < (!in, -1) }; |
||||||
|
|
||||||
* Deconstruct the input tuple into its individual elements, for clarity. |
* Deconstruct the input tuple into its individual elements, for clarity. |
||||||
* There will be a more ergonomic way of doing this one day. |
* There will be a more ergonomic way of doing this one day. |
||||||
n = tupEl < (in, 0); |
n = !tupEl < (!in, 0); |
||||||
a = tupEl < (in, 1); |
a = !tupEl < (!in, 1); |
||||||
b = tupEl < (in, 2); |
b = !tupEl < (!in, 2); |
||||||
|
|
||||||
out = if < ( |
!out = !if < ( |
||||||
isZero < n, |
!isZero < n, |
||||||
a, |
a, |
||||||
recur < ( decr<n, b, add<(a,b) ), |
!recur < ( decr<n, b, !add<(a,b) ), |
||||||
); |
); |
||||||
|
|
||||||
} < (in, 0, 1); |
} < (!in, 0, 1); |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue