By on 2/10/2009 12:09 PM ()

Yes, Brian's blog covers this well.

Also, some docs are here

[link:research.microsoft.com]

By on 2/11/2009 7:31 PM ()

It simply tells unfold to continue with the generative sequence. To stop use "None".

On a broader scale you'll find the Option type (Some x or None) used where you in C# would find null's scattered around.

For example consider the not to uncommon case of reading each line from a TextReader (file or Console.In for example) with unfold you could accomplish that like so

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#light

open System
open System.IO

let input = new StringReader("Hello\r\nWorld\r\nBye.\r\n") :> TextReader

let ReadLine (stream:TextReader) = 
    let line = stream.ReadLine()
    if line <> null then
        Some(line, stream)
    else
        None    

Seq.unfold ReadLine input
|> print_any
By on 2/10/2009 11:50 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper