Skip to content

Commit fa10810

Browse files
committed
Merge pull request #18 from chrisseaton/dataflow
Dataflow: add missing example in derivation.
2 parents 725314f + 8646742 commit fa10810

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

md/dataflow.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,16 @@ def dataflow(*inputs, &block)
193193
result
194194
end
195195

196+
def fib(n)
197+
if n < 2
198+
dataflow { n }
199+
else
200+
n1 = fib(n - 1)
201+
n2 = fib(n - 2)
202+
dataflow(n1, n2) { |v1, v2| v1 + v2 }
203+
end
204+
end
205+
196206
f = fib(14) #=> #<Concurrent::Future:0x000001019a26d8 ...
197207
sleep(0.5)
198208

0 commit comments

Comments
 (0)