Anonymous user
Fibonacci n-step number sequences: Difference between revisions
→{{header|Racket}}: Much improved & shortened code; note that the two functions are nearly identical, which means that one is redundant.
m (→{{header|Racket}}: Minor improvements, mostly remove the no-longer-needed `local`) |
(→{{header|Racket}}: Much improved & shortened code; note that the two functions are nearly identical, which means that one is redundant.) |
||
Line 2,089:
{{incomplete|Racket|Lucas?}}
<lang Racket>#lang racket
;; fib-n : Nat x Nat -> [
;; Outputs the first
(define (fib-n n
(define lon
(if
(if (<= len n) lon
(
(
;; fib-list : [
;; Given a list of natural numbers, the length of the list becomes the
;; size of the step, and outputs the first
;; (
(define (fib-list lon
(define
(
(reverse (for/fold
(
(
▲ (reverse (acc (reverse lon) step))]))
;; Now compute the series:
|