Sha256: d1a3c15725f349d8d774c8a838678bbf67521018e803b74e102f213463aa2eea
Contents?: true
Size: 1.03 KB
Versions: 8
Compression:
Stored size: 1.03 KB
Contents
.@ PackageName :: "Fib" .@ Editor :: "keita.yamaguchi@gmail.com" .@ "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
8 entries across 8 versions & 1 rubygems