36 people like it.

Dictionary extensions

Extensions to dictionaries.

1: 
2: 
3: 
4: 
5: 
module Dict =
  open System.Collections.Generic
  let toSeq d = d |> Seq.map (fun (KeyValue(k,v)) -> (k,v))
  let toArray (d:IDictionary<_,_>) = d |> toSeq |> Seq.toArray
  let toList (d:IDictionary<_,_>) = d |> toSeq |> Seq.toList
namespace System
namespace System.Collections
namespace System.Collections.Generic
val toSeq : d:seq<KeyValuePair<'a,'b>> -> seq<'a * 'b>

Full name: Script.Dict.toSeq
val d : seq<KeyValuePair<'a,'b>>
module Seq

from Microsoft.FSharp.Collections
val map : mapping:('T -> 'U) -> source:seq<'T> -> seq<'U>

Full name: Microsoft.FSharp.Collections.Seq.map
active recognizer KeyValue: KeyValuePair<'Key,'Value> -> 'Key * 'Value

Full name: Microsoft.FSharp.Core.Operators.( |KeyValue| )
val k : 'a
val v : 'b
val toArray : d:IDictionary<'a,'b> -> ('a * 'b) []

Full name: Script.Dict.toArray
val d : IDictionary<'a,'b>
type IDictionary<'TKey,'TValue> =
  member Add : key:'TKey * value:'TValue -> unit
  member ContainsKey : key:'TKey -> bool
  member Item : 'TKey -> 'TValue with get, set
  member Keys : ICollection<'TKey>
  member Remove : key:'TKey -> bool
  member TryGetValue : key:'TKey * value:'TValue -> bool
  member Values : ICollection<'TValue>

Full name: System.Collections.Generic.IDictionary<_,_>
val toArray : source:seq<'T> -> 'T []

Full name: Microsoft.FSharp.Collections.Seq.toArray
val toList : d:IDictionary<'a,'b> -> ('a * 'b) list

Full name: Script.Dict.toList
val toList : source:seq<'T> -> 'T list

Full name: Microsoft.FSharp.Collections.Seq.toList
Next Version Raw view Test code New version

More information

Link:http://fssnip.net/1t
Posted:13 years ago
Author:Ryan Riley
Tags: dictionary , extensions