Seq.delay creates a sequence from a function-that-returns-a-sequence; this is one way to delay side-effects from creation of the sequence until (each) use of the sequence. That said, I can't think of a scenario for this function right now that couldn't easily be handled using a "seq { ... }" block of code.

[link:research.microsoft.com]

By on 5/24/2009 8:52 AM ()

Seq.compare compare two sequences elementwise, returning 0 if both are equal, -1 or 1 if one is greater than/smaller than the other. It takes a function as argument that does the actual comparison of one pair, so it returns 0 if both are the same, -1 or 1 if the first is greater than/smaller than the other. Seq.compare then just feeds a pair of elements, one from each sequence in order, to this function and accumulates the result:

1
2
3
let compare seq1 seq2 = Seq.compare (fun a b -> a-b) seq1 seq2

printf "%A" (compare [2..5] [2..5])

will print 0.

By on 5/24/2009 5:16 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