Condividi tramite


Core.Option Module (F#)

Basic operations on options.

Namespace/Module Path: Microsoft.FSharp.Core

Assembly: FSharp.Core (in FSharp.Core.dll)

module Option

Remarks

For an overview of options in F#, see Options (F#).

Values

Value

Description

bind : ('T -> 'U option) -> 'T option -> 'U option

Invokes a function on an optional value that itself yields an option.

count : 'T option -> int

Evaluates the equivalent of Set.count for an option.

exists : ('T -> bool) -> 'T option -> bool

Evaluates the equivalent of List.exists for an option.

fold : ('State -> 'T -> 'State) -> 'State -> 'T option -> 'State

Evaluates the equivalent of List.fold for an option.

foldBack : ('T -> 'State -> 'State) -> 'T option -> 'State -> 'State

Performs the equivalent of the List.foldBack operation on an option.

forall : ('T -> bool) -> 'T option -> bool

Evaluates the equivalent of List.forall for an option type.

get : 'T option -> 'T

Gets the value associated with the option.

isNone : 'T option -> bool

Returns true if the option is None.

isSome : 'T option -> bool

Returns true if the option is not None.

iter : ('T -> unit) -> 'T option -> unit

Executes a function for an option value.

map : ('T -> 'U) -> 'T option -> 'U option

Transforms an option value by using a specified mapping function.

toArray : 'T option -> 'T []

Convert the option to an array of length 0 or 1.

toList : 'T option -> 'T list

Convert the option to a list of length 0 or 1.

Platforms

Windows 8, Windows 7, Windows Server 2012, Windows Server 2008 R2

Version Information

F# Core Library Versions

Supported in: 2.0, 4.0, Portable

See Also

Reference

Microsoft.FSharp.Core Namespace (F#)