Map (FSharp.Core)
Returns a new map with the binding added to the given map.
If a binding with the given key already exists in the input map, the existing binding is replaced by the new binding in the result map.
Returns a new map with the binding added to the given map. If a binding with the given key already exists in the input map, the existing binding is replaced by the new binding in the result map.
-
key
:
'Key -
The input key.
-
value
:
'T -
The input value.
-
table
:
Map<'Key, 'T> -
The input map.
-
Returns:
Map<'Key, 'T> -
The resulting map.
let input = Map [ (1, "a"); (2, "b") ]
input |> Map.add 3 "c" // evaluates to map [(1, "a"); (2, "b"); (3, "c")]
input |> Map.add 2 "aa" // evaluates to map [(1, "a"); (2, "aa")]
val input: Map<int,string>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val add: key: 'Key -> value: 'T -> table: Map<'Key,'T> -> Map<'Key,'T> (requires comparison)
Returns a new map with the value stored under key changed according to f.
Returns a new map with the value stored under key changed according to f.
-
key
:
'Key -
The input key.
-
f
:
'T option -> 'T option -
The change function.
-
table
:
Map<'Key, 'T> -
The input map.
-
Returns:
Map<'Key, 'T> -
The resulting map.
let input = Map [ (1, "a"); (2, "b") ]
input |> Map.change 1 (fun x ->
match x with
| Some s -> Some (s + "z")
| None -> None
) // evaluates to map [(1, "az"); (2, "b")]
val input: Map<int,string>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val change: key: 'Key -> f: ('T option -> 'T option) -> table: Map<'Key,'T> -> Map<'Key,'T> (requires comparison)
val x: string option
union case Option.Some: Value: 'T -> Option<'T>
val s: string
union case Option.None: Option<'T>
Tests if an element is in the domain of the map.
Tests if an element is in the domain of the map.
-
key
:
'Key -
The input key.
-
table
:
Map<'Key, 'T> -
The input map.
-
Returns:
bool -
True if the map contains the key.
let sample = Map [ (1, "a"); (2, "b") ]
sample |> Map.containsKey 1 // evaluates to true
sample |> Map.containsKey 3 // evaluates to false
val sample: Map<int,string>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val containsKey: key: 'Key -> table: Map<'Key,'T> -> bool (requires comparison)
The number of bindings in the map.
The number of bindings in the map.
-
table
:
Map<'Key, 'T>
-
Returns:
int
let sample = Map [ (1, "a"); (2, "b") ]
sample |> Map.count // evaluates to 2
val sample: Map<int,string>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val count: table: Map<'Key,'T> -> int (requires comparison)
-
Returns:
Map<'Key, 'T>
let emptyMap = Map.empty<int, string>
val emptyMap: Map<int,string>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val empty<'Key,'T (requires comparison)> : Map<'Key,'T> (requires comparison)
Multiple items
val int: value: 'T -> int (requires member op_Explicit)
--------------------
type int = int32
--------------------
type int<'Measure> =
int
Multiple items
val string: value: 'T -> string
--------------------
type string = System.String
Returns true if the given predicate returns true for one of the
bindings in the map.
Returns true if the given predicate returns true for one of the bindings in the map.
-
predicate
:
'Key -> 'T -> bool -
The function to test the input elements.
-
table
:
Map<'Key, 'T> -
The input map.
-
Returns:
bool -
True if the predicate returns true for one of the key/value pairs.
let sample = Map [ (1, "a"); (2, "b") ]
sample |> Map.exists (fun n s -> n = s.Length) // evaluates to true
sample |> Map.exists (fun n s -> n < s.Length) // evaluates to false
val sample: Map<int,string>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val exists: predicate: ('Key -> 'T -> bool) -> table: Map<'Key,'T> -> bool (requires comparison)
val n: int
val s: string
property System.String.Length: int with get
Builds a new map containing only the bindings for which the given predicate returns 'true'.
Builds a new map containing only the bindings for which the given predicate returns 'true'.
-
predicate
:
'Key -> 'T -> bool -
The function to test the key/value pairs.
-
table
:
Map<'Key, 'T> -
The input map.
-
Returns:
Map<'Key, 'T> -
The filtered map.
let sample = Map [ (1, "a"); (2, "b") ]
sample |> Map.filter (fun n s -> n = s.Length) // evaluates to map [(1, "a")]
val sample: Map<int,string>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val filter: predicate: ('Key -> 'T -> bool) -> table: Map<'Key,'T> -> Map<'Key,'T> (requires comparison)
val n: int
val s: string
property System.String.Length: int with get
Lookup an element in the map, raising KeyNotFoundException if no binding
exists in the map.
Lookup an element in the map, raising KeyNotFoundException if no binding
exists in the map.
-
key
:
'Key -
The input key.
-
table
:
Map<'Key, 'T> -
The input map.
-
Returns:
'T -
The value mapped to the given key.
let sample = Map [ (1, "a"); (2, "b") ]
sample |> Map.find 1 // evaluates to "a"
sample |> Map.find 3 // throws KeyNotFoundException
val sample: Map<int,string>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val find: key: 'Key -> table: Map<'Key,'T> -> 'T (requires comparison)
Evaluates the function on each mapping in the collection. Returns the key for the first mapping
where the function returns 'true'. Raise KeyNotFoundException if no such element exists.
Evaluates the function on each mapping in the collection. Returns the key for the first mapping
where the function returns 'true'. Raise KeyNotFoundException if no such element exists.
-
predicate
:
'Key -> 'T -> bool -
The function to test the input elements.
-
table
:
Map<'Key, 'T> -
The input map.
-
Returns:
'Key -
The first key for which the predicate evaluates true.
let sample = Map [ (1, "a"); (2, "b") ]
sample |> Map.findKey (fun n s -> n = s.Length) // evaluates to 1
sample |> Map.findKey (fun n s -> n < s.Length) // throws KeyNotFoundException
val sample: Map<int,string>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val findKey: predicate: ('Key -> 'T -> bool) -> table: Map<'Key,'T> -> 'Key (requires comparison)
val n: int
val s: string
property System.String.Length: int with get
Folds over the bindings in the map
Folds over the bindings in the map
-
folder
:
'State -> 'Key -> 'T -> 'State -
The function to update the state given the input key/value pairs.
-
state
:
'State -
The initial state.
-
table
:
Map<'Key, 'T> -
The input map.
-
Returns:
'State -
The final state value.
let sample = Map [ (1, "a"); (2, "b") ]
("initial", sample) ||> Map.fold (fun state n s -> sprintf "%s %i %s" state n s)
val sample: Map<int,string>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val fold<'Key,'T,'State (requires comparison)> : folder: ('State -> 'Key -> 'T -> 'State) -> state: 'State -> table: Map<'Key,'T> -> 'State (requires comparison)
val state: string
val n: int
val s: string
val sprintf: format: Printf.StringFormat<'T> -> 'T
Evaluates to"initial 1 a 2 b".
Folds over the bindings in the map.
Folds over the bindings in the map.
-
folder
:
'Key -> 'T -> 'State -> 'State -
The function to update the state given the input key/value pairs.
-
table
:
Map<'Key, 'T> -
The input map.
-
state
:
'State -
The initial state.
-
Returns:
'State -
The final state value.
let sample = Map [ (1, "a"); (2, "b") ]
(sample, "initial") ||> Map.foldBack (fun n s state -> sprintf "%i %s %s" n s state)
val sample: Map<int,string>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val foldBack: folder: ('Key -> 'T -> 'State -> 'State) -> table: Map<'Key,'T> -> state: 'State -> 'State (requires comparison)
val n: int
val s: string
val state: string
val sprintf: format: Printf.StringFormat<'T> -> 'T
Evaluates to"1 a 2 b initial"
Returns true if the given predicate returns true for all of the
bindings in the map.
Returns true if the given predicate returns true for all of the bindings in the map.
-
predicate
:
'Key -> 'T -> bool -
The function to test the input elements.
-
table
:
Map<'Key, 'T> -
The input map.
-
Returns:
bool -
True if the predicate evaluates to true for all of the bindings in the map.
let sample = Map [ (1, "a"); (2, "b") ]
sample |> Map.forall (fun n s -> n >= s.Length) // evaluates to true
sample |> Map.forall (fun n s -> n = s.Length) // evaluates to false
val sample: Map<int,string>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val forall: predicate: ('Key -> 'T -> bool) -> table: Map<'Key,'T> -> bool (requires comparison)
val n: int
val s: string
property System.String.Length: int with get
-
table
:
Map<'Key, 'T> -
The input map.
-
Returns:
bool -
True if the map is empty.
let emptyMap = Map.empty<int, string>
emptyMap |> Map.isEmpty // evaluates to true
let notEmptyMap = Map [ (1, "a"); (2, "b") ]
emptyMap |> Map.isEmpty // evaluates to false
val emptyMap: Map<int,string>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val empty<'Key,'T (requires comparison)> : Map<'Key,'T> (requires comparison)
Multiple items
val int: value: 'T -> int (requires member op_Explicit)
--------------------
type int = int32
--------------------
type int<'Measure> =
int
Multiple items
val string: value: 'T -> string
--------------------
type string = System.String
val isEmpty: table: Map<'Key,'T> -> bool (requires comparison)
val notEmptyMap: Map<int,string>
Applies the given function to each binding in the dictionary
Applies the given function to each binding in the dictionary
-
action
:
'Key -> 'T -> unit -
The function to apply to each key/value pair.
-
table
:
Map<'Key, 'T> -
The input map.
let sample = Map [ (1, "a"); (2, "b") ]
sample |> Map.iter (fun n s -> printf "%i %s " n s)
val sample: Map<int,string>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val iter: action: ('Key -> 'T -> unit) -> table: Map<'Key,'T> -> unit (requires comparison)
val n: int
val s: string
val printf: format: Printf.TextWriterFormat<'T> -> 'T
Prints"1 a 2 b ".
The keys in the map.
The sequence will be ordered by the keys of the map.
The keys in the map. The sequence will be ordered by the keys of the map.
-
table
:
Map<'Key, 'T>
-
Returns:
ICollection<'Key>
let sample = Map [ (1, "a"); (2, "b") ]
sample |> Map.keys // evaluates to seq [1; 2]
val sample: Map<int,string>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val keys: table: Map<'Key,'T> -> System.Collections.Generic.ICollection<'Key> (requires comparison)
Builds a new collection whose elements are the results of applying the given function
to each of the elements of the collection. The key passed to the
function indicates the key of element being transformed.
Builds a new collection whose elements are the results of applying the given function to each of the elements of the collection. The key passed to the function indicates the key of element being transformed.
-
mapping
:
'Key -> 'T -> 'U -
The function to transform the key/value pairs.
-
table
:
Map<'Key, 'T> -
The input map.
-
Returns:
Map<'Key, 'U> -
The resulting map of keys and transformed values.
let sample = Map [ (1, "a"); (2, "b") ]
sample |> Map.map (fun n s -> sprintf "%i %s" n s) // evaluates to map [(1, "1 a"); (2, "2 b")]
val sample: Map<int,string>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val map: mapping: ('Key -> 'T -> 'U) -> table: Map<'Key,'T> -> Map<'Key,'U> (requires comparison)
val n: int
val s: string
val sprintf: format: Printf.StringFormat<'T> -> 'T
Returns binding for the largest key in the map.
Raise KeyNotFoundException when map is empty.
Returns binding for the largest key in the map.
Raise KeyNotFoundException when map is empty.
-
table
:
Map<'Key, 'T> -
The input map.
-
Returns:
'Key * 'T
let sample = Map [ (1, "a"); (2, "b") ]
sample |> Map.maxKeyValue // evaluates to (2, "b")
val sample: Map<int,string>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val maxKeyValue: table: Map<'Key,'T> -> 'Key * 'T (requires comparison)
Returns binding for the smallest key in the map.
Raise KeyNotFoundException when map is empty.
Returns binding for the smallest key in the map.
Raise KeyNotFoundException when map is empty.
-
table
:
Map<'Key, 'T> -
The input map.
-
Returns:
'Key * 'T
let sample = Map [ (1, "a"); (2, "b") ]
sample |> Map.minKeyValue // evaluates to (1, "a")
val sample: Map<int,string>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val minKeyValue: table: Map<'Key,'T> -> 'Key * 'T (requires comparison)
Returns a new map made from the given bindings.
Returns a new map made from the given bindings.
-
elements
:
('Key * 'T) array -
The input array of key/value pairs.
-
Returns:
Map<'Key, 'T> -
The resulting map.
let input = [| (1, "a"); (2, "b") |]
input |> Map.ofArray // evaluates to map [(1, "a"); (2, "b")]
val input: (int * string) array
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val ofArray: elements: ('Key * 'T) array -> Map<'Key,'T> (requires comparison)
Returns a new map made from the given bindings.
Returns a new map made from the given bindings.
-
elements
:
('Key * 'T) list -
The input list of key/value pairs.
-
Returns:
Map<'Key, 'T> -
The resulting map.
let input = [ (1, "a"); (2, "b") ]
input |> Map.ofList // evaluates to map [(1, "a"); (2, "b")]
val input: (int * string) list
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val ofList: elements: ('Key * 'T) list -> Map<'Key,'T> (requires comparison)
Returns a new map made from the given bindings.
Returns a new map made from the given bindings.
-
elements
:
('Key * 'T) seq -
The input sequence of key/value pairs.
-
Returns:
Map<'Key, 'T> -
The resulting map.
let input = seq { (1, "a"); (2, "b") }
input |> Map.ofSeq // evaluates to map [(1, "a"); (2, "b")]
val input: (int * string) seq
Multiple items
val seq: sequence: 'T seq -> 'T seq
--------------------
type 'T seq = System.Collections.Generic.IEnumerable<'T>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val ofSeq: elements: ('Key * 'T) seq -> Map<'Key,'T> (requires comparison)
Builds two new maps, one containing the bindings for which the given predicate returns 'true',
and the other the remaining bindings.
Builds two new maps, one containing the bindings for which the given predicate returns 'true', and the other the remaining bindings.
-
predicate
:
'Key -> 'T -> bool -
The function to test the input elements.
-
table
:
Map<'Key, 'T> -
The input map.
-
Returns:
Map<'Key, 'T> * Map<'Key, 'T> -
A pair of maps in which the first contains the elements for which the predicate returned true and the second containing the elements for which the predicated returned false.
let sample = Map [ (1, "a"); (2, "b") ]
sample |> Map.partition (fun n s -> n = s.Length) // evaluates to (map [(1, "a")], map [(2, "b")])
val sample: Map<int,string>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val partition: predicate: ('Key -> 'T -> bool) -> table: Map<'Key,'T> -> Map<'Key,'T> * Map<'Key,'T> (requires comparison)
val n: int
val s: string
property System.String.Length: int with get
Searches the map looking for the first element where the given function returns a Some value.
Raise KeyNotFoundException if no such element exists.
Searches the map looking for the first element where the given function returns a Some value.
Raise KeyNotFoundException if no such element exists.
-
chooser
:
'Key -> 'T -> 'U option -
The function to generate options from the key/value pairs.
-
table
:
Map<'Key, 'T> -
The input map.
-
Returns:
'U -
The first result.
| KeyNotFoundException |
Thrown if no element returns a Some
value when evaluated by the chooser function
|
let sample = Map [ (1, "a"); (2, "b"); (10, "ccc"); (20, "ddd") ]
sample |> Map.pick (fun n s -> if n > 5 && s.Length > 2 then Some s else None)
val sample: Map<int,string>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val pick: chooser: ('Key -> 'T -> 'U option) -> table: Map<'Key,'T> -> 'U (requires comparison)
val n: int
val s: string
property System.String.Length: int with get
union case Option.Some: Value: 'T -> Option<'T>
union case Option.None: Option<'T>
Evaluates to"ccc"
let sample = Map [ (1, "a"); (2, "b"); (10, "ccc"); (20, "ddd") ]
sample |> Map.pick (fun n s -> if n > 5 && s.Length > 4 then Some s else None)
val sample: Map<int,string>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val pick: chooser: ('Key -> 'T -> 'U option) -> table: Map<'Key,'T> -> 'U (requires comparison)
val n: int
val s: string
property System.String.Length: int with get
union case Option.Some: Value: 'T -> Option<'T>
union case Option.None: Option<'T>
RaisesKeyNotFoundException
Removes an element from the domain of the map. No exception is raised if the element is not present.
Removes an element from the domain of the map. No exception is raised if the element is not present.
-
key
:
'Key -
The input key.
-
table
:
Map<'Key, 'T> -
The input map.
-
Returns:
Map<'Key, 'T> -
The resulting map.
let sample = Map [ (1, "a"); (2, "b") ]
sample |> Map.remove 1 // evaluates to map [(2, "b")]
sample |> Map.remove 3 // equal to sample
val sample: Map<int,string>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val remove: key: 'Key -> table: Map<'Key,'T> -> Map<'Key,'T> (requires comparison)
Returns an array of all key-value pairs in the mapping.
The array will be ordered by the keys of the map.
Returns an array of all key-value pairs in the mapping. The array will be ordered by the keys of the map.
-
table
:
Map<'Key, 'T> -
The input map.
-
Returns:
('Key * 'T) array -
The array of key/value pairs.
let input = Map [ (1, "a"); (2, "b") ]
input |> Map.toArray // evaluates to [|(1, "a"); (2, "b")|]
val input: Map<int,string>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val toArray: table: Map<'Key,'T> -> ('Key * 'T) array (requires comparison)
Returns a list of all key-value pairs in the mapping.
The list will be ordered by the keys of the map.
Returns a list of all key-value pairs in the mapping. The list will be ordered by the keys of the map.
-
table
:
Map<'Key, 'T> -
The input map.
-
Returns:
('Key * 'T) list -
The list of key/value pairs.
let input = Map [ (1, "a"); (2, "b") ]
input |> Map.toList // evaluates to [(1, "a"); (2, "b")]
val input: Map<int,string>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val toList: table: Map<'Key,'T> -> ('Key * 'T) list (requires comparison)
Views the collection as an enumerable sequence of pairs.
The sequence will be ordered by the keys of the map.
Views the collection as an enumerable sequence of pairs. The sequence will be ordered by the keys of the map.
-
table
:
Map<'Key, 'T> -
The input map.
-
Returns:
('Key * 'T) seq -
The sequence of key/value pairs.
let input = Map [ (1, "a"); (2, "b") ]
input |> Map.toSeq // evaluates to seq [(1, "a"); (2, "b")]
val input: Map<int,string>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val toSeq: table: Map<'Key,'T> -> ('Key * 'T) seq (requires comparison)
Lookup an element in the map, returning a Some value if the element is in the domain
of the map and None if not.
Lookup an element in the map, returning a Some value if the element is in the domain
of the map and None if not.
-
key
:
'Key -
The input key.
-
table
:
Map<'Key, 'T> -
The input map.
-
Returns:
'T option -
The found
Somevalue orNone.
let sample = Map [ (1, "a"); (2, "b") ]
sample |> Map.tryFind 1 // evaluates to Some "a"
sample |> Map.tryFind 3 // evaluates to None
val sample: Map<int,string>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val tryFind: key: 'Key -> table: Map<'Key,'T> -> 'T option (requires comparison)
Returns the key of the first mapping in the collection that satisfies the given predicate.
Returns 'None' if no such element exists.
Returns the key of the first mapping in the collection that satisfies the given predicate. Returns 'None' if no such element exists.
-
predicate
:
'Key -> 'T -> bool -
The function to test the input elements.
-
table
:
Map<'Key, 'T> -
The input map.
-
Returns:
'Key option -
The first key for which the predicate returns true or None if the predicate evaluates to false for each key/value pair.
let sample = Map [ (1, "a"); (2, "b") ]
sample |> Map.tryFindKey (fun n s -> n = s.Length) // evaluates to Some 1
sample |> Map.tryFindKey (fun n s -> n < s.Length) // evaluates to None
val sample: Map<int,string>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val tryFindKey: predicate: ('Key -> 'T -> bool) -> table: Map<'Key,'T> -> 'Key option (requires comparison)
val n: int
val s: string
property System.String.Length: int with get
Searches the map looking for the first element where the given function returns a Some value.
Searches the map looking for the first element where the given function returns a Some value.
-
chooser
:
'Key -> 'T -> 'U option -
The function to generate options from the key/value pairs.
-
table
:
Map<'Key, 'T> -
The input map.
-
Returns:
'U option -
The first result.
let sample = Map [ (1, "a"); (2, "b"); (10, "ccc"); (20, "ddd") ]
sample |> Map.tryPick (fun n s -> if n > 5 && s.Length > 2 then Some s else None)
val sample: Map<int,string>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val tryPick: chooser: ('Key -> 'T -> 'U option) -> table: Map<'Key,'T> -> 'U option (requires comparison)
val n: int
val s: string
property System.String.Length: int with get
union case Option.Some: Value: 'T -> Option<'T>
union case Option.None: Option<'T>
Evaluates toSome "ccc".
let sample = Map [ (1, "a"); (2, "b"); (10, "ccc"); (20, "ddd") ]
sample |> Map.tryPick (fun n s -> if n > 5 && s.Length > 4 then Some s else None)
val sample: Map<int,string>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val tryPick: chooser: ('Key -> 'T -> 'U option) -> table: Map<'Key,'T> -> 'U option (requires comparison)
val n: int
val s: string
property System.String.Length: int with get
union case Option.Some: Value: 'T -> Option<'T>
union case Option.None: Option<'T>
Evaluates toNone.
The values in the map, including the duplicates.
The sequence will be ordered by the keys of the map.
The values in the map, including the duplicates. The sequence will be ordered by the keys of the map.
-
table
:
Map<'Key, 'T>
-
Returns:
ICollection<'T>
let sample = Map [ (1, "a"); (2, "b") ]
sample |> Map.values // evaluates to seq ["a"; "b"]
val sample: Map<int,string>
Multiple items
module Map
from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> =
interface IReadOnlyDictionary<'Key,'Value>
interface IReadOnlyCollection<KeyValuePair<'Key,'Value>>
interface IEnumerable
interface IStructuralEquatable
interface IComparable
interface IEnumerable<KeyValuePair<'Key,'Value>>
interface ICollection<KeyValuePair<'Key,'Value>>
interface IDictionary<'Key,'Value>
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
member Add: key: 'Key * value: 'Value -> Map<'Key,'Value>
...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
val values: table: Map<'Key,'T> -> System.Collections.Generic.ICollection<'T> (requires comparison)