1
Seq.toMap未在toMap2功能爲什麼以前定義的方法在fsharp的模塊中不可用?
open System
open Microsoft.FSharp.Collections
module Seq =
let toMap(seqinit:seq<'a*'T>) =
seqinit |> Map.ofSeq
let toMap2(seqinit:seq<'a*seq<'b*'T>>) =
seqinit |> Seq.map (fun (key1 ,seq1) -> (key1, seq1 |> Seq.toMap))
|> Map.ofSeq
UPDATE
一個更好的功能代碼將是的內調用識別(與初始PB作爲解決聖拉蒙SNIR建議)
let inline (||>) (seqinit:seq<'a*'T>) f =
seqinit |> Seq.map (fun (key1 ,seq1) -> (key1, seq1 |> f))
let toMap (seqinit:seq<'a*'T>) = seqinit |> Map.ofSeq
let toMap2 (seqinit:seq<'a*seq<'b*'T>>) = seqinit ||> toMap |> toMap
let toMap3 (seqinit:seq<'a*seq<'b*seq<'c*'T>>>) = seqinit ||> toMap2 |> toMap
是的,我明白了這一點。模塊和命名空間在這一點上對我來說是相當混亂的。 – nicolas 2012-03-01 08:42:32