In chapter 1.2.2 you can read about SICP view of tree recursion as a common
pattern of computation.As an example it proposes the computation of Fibonacci numbers.
Below you can check my F# version of the book's method for calculating them.
module FibonacciImplemtation
open System
let rec fib n =
if n = 0 then 0 else
if n = 1 then 1 else
fib (n - 1) + fib (n - 2)
// test
let testFib = fib 7
No hay comentarios:
Publicar un comentario