/* Fibonacci implementation using a round-robin splitter. * Since y[n]=y[n-1]+y[n-2], push the two values that get added around * the loop. The body filter inputs the two values, and outputs the * next result and the next two values to be added. * $Id: Fib2.str,v 1.2 2005/11/04 01:06:17 dimock Exp $ */ void->void pipeline Fib2 { add void->int feedbackloop { join roundrobin(0, 1); body int->int filter { work pop 2 push 3 { int a = pop(); int b = pop(); int result = a + b; push(result); push(b); push(result); } }; loop Identity; split roundrobin(1, 2); enqueue(0); enqueue(1); }; add int->void filter { work pop 1 { println(pop()); } }; }