Sha256: a2be3eab4db9e3dcd9dc3a4fb7487865a6e845e3b06241be0d67e5fd2a2fe303
Contents?: true
Size: 1012 Bytes
Versions: 4
Compression:
Stored size: 1012 Bytes
Contents
@ author :: "Keita Yamaguchi" @ "Fib.pione calculates the value of Fibonacci number." param ($NUM := 3) Rule Main output 'result.txt' Flow rule Fib {N: $NUM} rule Result End Rule Fib0 @ "the value of fib(0) is 0" output 'fib0.txt' Action echo -n '0' > fib0.txt End Rule Fib1 @ "the value of fib(1) is 1" output 'fib1.txt' Action echo -n '1' > fib1.txt End Rule Fib @ "fib(n) is fib(0), fib(1), or fib(n-1) + fib(n-2)" output 'fib{$N}.txt' param $N Flow case $N when 0 rule Fib0 when 1 rule Fib1 else $P1 := $N - 2 $P2 := $N - 1 rule Fib {N: $P1} rule Fib {N: $P2} rule Calc {N: $N, P1: $P1, P2: $P2} end End Rule Calc @ "calculate the value of fib(n-1) + fib(n-2)" input 'fib{$P1}.txt' input 'fib{$P2}.txt' output 'fib{$N}.txt' param $N param $P1 param $P2 Action echo "`cat {$I[1]}` + `cat {$I[2]}`" | bc > {$O[1]} End Rule Result @ "make the result" input 'fib*.txt' output 'result.txt' Action cp {$I[1]} {$O[1]} End
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
pione-0.2.2 | example/Fib/Fib.pione |
pione-0.2.1 | example/Fib/Fib.pione |
pione-0.2.0 | example/Fib/Fib.pione |
pione-0.1.4 | example/Fib/Fib.pione |