2

在 Visual Studio 2010 中是否有 Seq.generate_using 的替代/解决方法?FSharp.PowerPack.dll 不适用于 2010 AFAIK

4

2 回答 2

5

(抱歉,PowerPack 仍然无法在 2010 年推出。)

我不记得 CTP 更新是否已经如此,但在内部位中我收到警告:

此构造已弃用。此功能将在未来的版本中删除。如有必要,从 F# PowerPack 获取其实现的副本并将其复制到您的应用程序中

所以这里是来自 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 }
于 2009-05-29T21:42:31.390 回答
3

仅供参考,.Net 4.0 Beta1 的 PowerPack 二进制文件今天上线:

http://www.microsoft.com/downloads/details.aspx?FamilyID=e475a670-9596-4958-bfa2-dc0ac29b4631&displaylang=en

于 2009-06-04T01:59:56.077 回答