Is there an alternative/workaround for Seq.generate_using in Visual Studio 2010? The FSharp.PowerPack.dll is not available for 2010 AFAIK
+2
A:
(Sorry about the PowerPack still not being available for 2010 yet.)
I don't recall if this already is true of the CTP update, but in internal bits I get the warning:
This construct is deprecated. This function will be removed in a future release. If necessary, take a copy of its implementation from the F# PowerPack and copy it into your application
so here is the code from the PowerPack:
#nowarn "9"
namespace Microsoft.FSharp.Compatibility
open System.Collections.Generic
module Seq =
let combine ie1 ie2 = Seq.zip ie1 ie2
let nonempty (ie : seq<'T>) = use e = ie.GetEnumerator() in e.MoveNext() //'
let generate openf compute closef =
seq { let r = openf()
try
let x = ref None
while (x := compute r; (!x).IsSome) do
yield (!x).Value
finally
closef r }
let generate_using (openf : unit -> ('b :> System.IDisposable)) compute = //'
generate openf compute (fun (s:'b) -> s.Dispose()) //'
let cons (x:'T) (s: seq<'T>) =
seq { yield x
yield! s }
Brian
2009-05-29 21:42:31
thanks, Brian, works like a charm!
thinkhard
2009-05-30 02:08:32