2 people like it.

Fibonacci

fibonacci by Seq.Unfold

1: 
let fibonacci = Seq.unfold(fun (x,y) -> Some(x, (x + y, x))) (0,1)
val fibonacci : seq<int>

Full name: Script.fibonacci
module Seq

from Microsoft.FSharp.Collections
val unfold : generator:('State -> ('T * 'State) option) -> state:'State -> seq<'T>

Full name: Microsoft.FSharp.Collections.Seq.unfold
val x : int
val y : int
union case Option.Some: Value: 'T -> Option<'T>
Raw view Test code New version

More information

Link:http://fssnip.net/fl
Posted:11 years ago
Author:Laco
Tags: fibonacci , unfold