unison/unison-src/tests/fib4.u

20 lines
343 B
Plaintext

(+) = (UInt64.+)
(<) = (UInt64.<)
(-) = (UInt64.drop)
(*) = (UInt64.*)
fib4 n =
loop a b c d n = case n of
0 -> 0
1 -> d
n -> loop b c d (a + b + c + d) (n - 1)
loop 0 0 0 1 n
t = Stream.take 10 (Stream.map fib4 (Stream.from-uint64 0))
p = 9000
q = 900
r = 90
s = 9
sum = Stream.fold-left 0 (+) t
sum * 10000 + p + q + r + s