/usr/share/picolisp/misc/fibo.l is in picolisp 15.11-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | # 25mar15abu
# (c) Software Lab. Alexander Burger
# Standard version
(de fibo (N)
(if (>= 2 N)
1
(+ (fibo (dec N)) (fibo (- N 2))) ) )
# Non-recursive
(de fib (N)
(let (A 0 B 1)
(do N
(prog1 B (setq B (+ A B) A @)) ) ) )
# Parallelized version
(de fibo+ (D N) # Uses 2**D processes
(cond
((>= 1 (dec 'N)) 1)
((ge0 (dec 'D))
(let (A NIL B NIL)
(later 'A (fibo+ D N))
(later 'B (fibo+ D (dec N)))
(wait NIL (and A B))
(+ A B) ) )
(T
(+
(fibo+ D N)
(fibo+ D (dec N)) ) ) ) )
# Using a cache (fastest)
(de cachedFibo (N)
(cache '(NIL) N
(if (>= 2 N)
1
(+ (cachedFibo (dec N)) (cachedFibo (- N 2))) ) ) )
# Coded in 'C'
`(== 64 64) # Only in the 64-bit version
(load "@lib/native.l")
(gcc "fibo" NIL
(cFibo (N) "Fibo" 'I N) )
int Fibo(int n) {
if (n <= 2)
return 1;
return Fibo(n-1) + Fibo(n-2);
}
/**/
# vi:et:ts=3:sw=3
|