Logo Dicts

Dict Module

Static Functions on IDictionary Interface

Functions and values

Function or value Description

Dict.add key value dic

Full Usage: Dict.add key value dic

Parameters:
    key : 'Key - The key to add.
    value : 'Value - The value to add.
    dic : IDictionary<'Key, 'Value> - The dictionary to change.

Type parameters: 'Key, 'Value

Add a key and value to a IDictionary. Like Dictionary.Add, it throws an ArgumentException if the key already exists. Use Dict.set to add or replace a value.

key : 'Key

The key to add.

value : 'Value

The value to add.

dic : IDictionary<'Key, 'Value>

The dictionary to change.

Dict.addIfKeyAbsent key value dic

Full Usage: Dict.addIfKeyAbsent key value dic

Parameters:
    key : 'Key - The key to set.
    value : 'Value - The value to set if the key is missing.
    dic : IDictionary<'Key, 'Value> - The dictionary to change.

Returns: bool true if the value was set, false if the key already existed and nothing was changed.
Type parameters: 'Key, 'Value

Set value only if key does not exist yet. Same as Dict.setIfKeyAbsent key value dic

key : 'Key

The key to set.

value : 'Value

The value to set if the key is missing.

dic : IDictionary<'Key, 'Value>

The dictionary to change.

Returns: bool

true if the value was set, false if the key already existed and nothing was changed.

Dict.create xs

Full Usage: Dict.create xs

Parameters:
    xs : ('Key * 'Value) seq - The key and value pairs to fill the new Dict with.

Returns: Dict<'Key, 'Value>
Type parameters: 'Key, 'Value (requires equality)

Create a Dict from seq of key and value pairs. Like the Dictionary constructor, it throws an ArgumentException on duplicate keys.

xs : ('Key * 'Value) seq

The key and value pairs to fill the new Dict with.

Returns: Dict<'Key, 'Value>

Dict.get key dic

Full Usage: Dict.get key dic

Parameters:
    key : 'Key - The key to look up.
    dic : IDictionary<'Key, 'Value> - The dictionary to read from.

Returns: 'Value
Type parameters: 'Key, 'Value

Get value at key from IDictionary, with nicer Error messages. Throws a KeyNotFoundException if the key is not found.

key : 'Key

The key to look up.

dic : IDictionary<'Key, 'Value>

The dictionary to read from.

Returns: 'Value

Dict.getOrSetDefault getDefault key dic

Full Usage: Dict.getOrSetDefault getDefault key dic

Parameters:
    getDefault : 'Key -> 'Value - The function to create the value from the key, only called if the key is missing.
    key : 'Key - The key to look up.
    dic : IDictionary<'Key, 'Value> - The dictionary to read from and change.

Returns: 'Value The existing or the newly created value.
Type parameters: 'Key, 'Value

If the key is not present calls the default function, sets its result as value at the key and returns it. This function is an alternative to the DefaultDict type. Use it if you need to provide a custom implementation of the default function depending on the key.

getDefault : 'Key -> 'Value

The function to create the value from the key, only called if the key is missing.

key : 'Key

The key to look up.

dic : IDictionary<'Key, 'Value>

The dictionary to read from and change.

Returns: 'Value

The existing or the newly created value.

Dict.getOrSetDefaultValue defaultValue key dic

Full Usage: Dict.getOrSetDefaultValue defaultValue key dic

Parameters:
    defaultValue : 'Value - The value to set if the key is missing.
    key : 'Key - The key to look up.
    dic : IDictionary<'Key, 'Value> - The dictionary to read from and change.

Returns: 'Value The existing value or the default value.
Type parameters: 'Value, 'Key

If the key is not present sets the default value at the key and returns it.

defaultValue : 'Value

The value to set if the key is missing.

key : 'Key

The key to look up.

dic : IDictionary<'Key, 'Value>

The dictionary to read from and change.

Returns: 'Value

The existing value or the default value.

Dict.items dic

Full Usage: Dict.items dic

Parameters:
    dic : IDictionary<'Key, 'Value> - The dictionary to read from.

Returns: ('Key * 'Value) seq
Type parameters: 'Key, 'Value

Returns a (lazy) sequence of key and value tuples.

dic : IDictionary<'Key, 'Value>

The dictionary to read from.

Returns: ('Key * 'Value) seq

Dict.iter f dic

Full Usage: Dict.iter f dic

Parameters:
    f : 'Key -> 'Value -> unit - The function to call with each key and value.
    dic : IDictionary<'Key, 'Value> - The dictionary to iterate over.

Type parameters: 'Key, 'Value

Iterate over keys and values of a dictionary.

f : 'Key -> 'Value -> unit

The function to call with each key and value.

dic : IDictionary<'Key, 'Value>

The dictionary to iterate over.

Dict.keys dic

Full Usage: Dict.keys dic

Parameters:
    dic : IDictionary<'Key, 'Value> - The dictionary to read from.

Returns: 'Key seq
Type parameters: 'Key, 'Value

Returns a (lazy) sequence of keys.

dic : IDictionary<'Key, 'Value>

The dictionary to read from.

Returns: 'Key seq

Dict.map f dic

Full Usage: Dict.map f dic

Parameters:
    f : 'Key -> 'Value -> 'T - The function to call with each key and value.
    dic : IDictionary<'Key, 'Value> - The dictionary to map over.

Returns: 'T seq A (lazy) sequence of the results of f.
Type parameters: 'Key, 'Value, 'T

Map over keys and values of a dictionary.

f : 'Key -> 'Value -> 'T

The function to call with each key and value.

dic : IDictionary<'Key, 'Value>

The dictionary to map over.

Returns: 'T seq

A (lazy) sequence of the results of f.

Dict.memoize f

Full Usage: Dict.memoize f

Parameters:
    f : 'T -> 'U - The function to cache the results of. It is called once per distinct argument.

Returns: 'T -> 'U A function that returns the cached result if it was called with the same argument before.
Type parameters: 'T, 'U (requires equality)

Caches the results of a function in a Dictionary. The argument 'T is packed in a wrapper so it can be unit or null(=None) too. (A Dictionary would fail on a null as key ) The cache is not thread-safe, don't call the returned function from several threads at the same time.

f : 'T -> 'U

The function to cache the results of. It is called once per distinct argument.

Returns: 'T -> 'U

A function that returns the cached result if it was called with the same argument before.

Dict.pop key dic

Full Usage: Dict.pop key dic

Parameters:
    key : 'Key - The key to remove.
    dic : IDictionary<'Key, 'Value> - The dictionary to change.

Returns: 'Value The value that was stored at the key.
Type parameters: 'Key, 'Value

Get a value and remove the key and value from the dictionary, like *.pop() in Python. Throws a KeyNotFoundException if the key does not exist.

key : 'Key

The key to remove.

dic : IDictionary<'Key, 'Value>

The dictionary to change.

Returns: 'Value

The value that was stored at the key.

Dict.set key value dic

Full Usage: Dict.set key value dic

Parameters:
    key : 'Key - The key to set.
    value : 'Value - The value to set.
    dic : IDictionary<'Key, 'Value> - The dictionary to change.

Type parameters: 'Key, 'Value

Set value at key in a IDictionary, adds the key if it is missing. Same as dic.[key] <- value

key : 'Key

The key to set.

value : 'Value

The value to set.

dic : IDictionary<'Key, 'Value>

The dictionary to change.

Dict.setIfKeyAbsent key value dic

Full Usage: Dict.setIfKeyAbsent key value dic

Parameters:
    key : 'Key - The key to set.
    value : 'Value - The value to set if the key is missing.
    dic : IDictionary<'Key, 'Value> - The dictionary to change.

Returns: bool true if the value was set, false if the key already existed and nothing was changed.
Type parameters: 'Key, 'Value

Set value only if key does not exist yet. Same as Dict.addIfKeyAbsent key value dic

key : 'Key

The key to set.

value : 'Value

The value to set if the key is missing.

dic : IDictionary<'Key, 'Value>

The dictionary to change.

Returns: bool

true if the value was set, false if the key already existed and nothing was changed.

Dict.tryGet k dic

Full Usage: Dict.tryGet k dic

Parameters:
    k : 'Key - The key to look up.
    dic : IDictionary<'Key, 'Value> - The dictionary to read from.

Returns: 'Value option Some value if the key was found, None if not.
Type parameters: 'Key, 'Value

Tries to get a value from a IDictionary.

k : 'Key

The key to look up.

dic : IDictionary<'Key, 'Value>

The dictionary to read from.

Returns: 'Value option

Some value if the key was found, None if not.

Dict.tryPop key dic

Full Usage: Dict.tryPop key dic

Parameters:
    key : 'Key - The key to remove.
    dic : IDictionary<'Key, 'Value> - The dictionary to change.

Returns: 'Value option Some value if the key was found, None if not.
Type parameters: 'Key, 'Value

Tries to get a value and remove the key and value from the dictionary, like *.pop() in Python.

key : 'Key

The key to remove.

dic : IDictionary<'Key, 'Value>

The dictionary to change.

Returns: 'Value option

Some value if the key was found, None if not.

Dict.values dic

Full Usage: Dict.values dic

Parameters:
    dic : IDictionary<'Key, 'Value> - The dictionary to read from.

Returns: 'Value seq
Type parameters: 'Key, 'Value

Returns a (lazy) sequence of values.

dic : IDictionary<'Key, 'Value>

The dictionary to read from.

Returns: 'Value seq

Type something to start searching.