[Home] Module Microsoft.FSharp.MLLib.Option


Basic operations on options.

Values

ValueDescription
val bind : ('a -> 'b option) -> 'a option -> 'b option
"bind f inp" evaluates to "match inp with None -> None | Some x -> f x"
val exists : ('a -> bool) -> 'a option -> bool
"exists p inp" evaluates to "match inp with None -> false | Some x -> p x"
val filter : ('a -> bool) -> 'a option -> 'a option
"filter p inp" evaluates to "match inp with None -> None | Some x -> if p x then inp else None"
val fold_left : ('b -> 'a -> 'b) -> 'b -> 'a option -> 'b
"nonempty inp" evaluates to "match inp with None -> false | Some _ -> true" "fold_left f s inp " evaluates to "match inp with None -> s | Some x -> f s x"
val fold_right : ('a -> 'b -> 'b) -> 'a option -> 'b -> 'b
"fold_right f inp s" evaluates to "match inp with None -> s | Some x -> f x s"
val for_all : ('a -> bool) -> 'a option -> bool
"forall p inp" evaluates to "match inp with None -> true | Some x -> p x"
val get : 'a option -> 'a
Gets the value associated with the option. If the option is None then raises Invalid_argument "Option.get"
val is_none : 'a option -> bool
Returns true if the option is None
val is_some : 'a option -> bool
Returns true if the option is not None
val iter : ('a -> unit) -> 'a option -> unit
"iter f inp" executes "match inp with None -> () | Some x -> f x"
val length : 'a option -> int
"length inp" evaluates to "match inp with None -> 0 | Some _ -> 1"
val map : ('a -> 'b) -> 'a option -> 'b option
"map f inp" evaluates to "match inp with None -> None | Some x -> Some (f x)"
val partition : ('a -> bool) -> 'a option -> 'a option * 'a option
"partition p inp" evaluates to "match inp with None -> None,None | Some x -> if p x then inp,None else None,inp"
val to_array : 'a option -> 'a array
Convert the option to an array of length 0 or 1
val to_list : 'a option -> 'a list
Convert the option to a list of length 0 or 1
val to_stream : 'a option -> 'a t
Convert the option to a stream of length 0 or 1

Deprecated Values

ValueDescription
val foreach : 'a option -> ('a -> unit) -> unit

Deprecated: This member is deprecated. Use "x |> CollectionType.iter" instead.

Apply the given function to each element of the collection. Options have at most one item when viewed as a collection
val transform : 'a option -> ('a -> 'b) -> 'b option

Deprecated: This member is deprecated. Use "x |> CollectionType.map" instead.

Build a new collection whose elements are the results of applying the given function to each of the elements of the collection. Options have at most one item when viewed as a collection.

See Also

Microsoft.FSharp.MLLib


Documentation for assembly mllib, version 1.1.10.1, generated using F# version 1.1.10.1