FSharp.Core


Operators Module

Basic F# Operators. This module is automatically opened in all F# code.

Nested modules

Modules Description

ArrayExtensions

Contains extension methods to allow the use of F# indexer notation with arrays. This module is automatically opened in all F# code.

Checked

This module contains the basic arithmetic operations with overflow checks.

NonStructuralComparison

A module of comparison and equality operators that are statically resolved, but which are not fully generic and do not make structural comparison. Opening this module may make code that relies on structural or generic comparison no longer compile.

OperatorIntrinsics

A module of compiler intrinsic functions for efficient implementations of F# integer ranges and dynamic invocations of other F# operators

Unchecked

This module contains basic operations which do not apply runtime and/or static checks

Functions and values

Function or value Description

!cell

Full Usage: !cell

Parameters:
    cell : 'T ref - The cell to dereference.

Returns: 'T The value contained in the cell.

Dereference a mutable reference cell

cell : 'T ref

The cell to dereference.

Returns: 'T

The value contained in the cell.

Example

 let count = ref 12  // Creates a reference cell object with a mutable Value property
 count.Value         // Evaluates to 12
 !count              // Also evaluates to 12 (with shorter syntax)

x % y

Full Usage: x % y

Parameters:
    x : ^T1 - The first parameter.
    y : ^T2 - The second parameter.

Returns: ^T3 The result of the operation.
Modifiers: inline
Type parameters: ^T1, ^T2, ^T3

Overloaded modulo operator

x : ^T1

The first parameter.

y : ^T2

The second parameter.

Returns: ^T3

The result of the operation.

Example

 29 % 5 //  Evaluates to 4

x &&& y

Full Usage: x &&& y

Parameters:
    x : ^T - The first parameter.
    y : ^T - The second parameter.

Returns: ^T The result of the operation.
Modifiers: inline
Type parameters: ^T

Overloaded bitwise-AND operator

x : ^T

The first parameter.

y : ^T

The second parameter.

Returns: ^T

The result of the operation.

Example

 let a = 13       // 00000000000000000000000000001101
 let b = 11       // 00000000000000000000000000001011
 let c = a &&& b  // 00000000000000000000000000001001
Evaluates to 9

x * y

Full Usage: x * y

Parameters:
    x : ^T1 - The first parameter.
    y : ^T2 - The second parameter.

Returns: ^T3 The result of the operation.
Modifiers: inline
Type parameters: ^T1, ^T2, ^T3

Overloaded multiplication operator

x : ^T1

The first parameter.

y : ^T2

The second parameter.

Returns: ^T3

The result of the operation.

Example

 8 * 6 //  Evaluates to 48

x ** y

Full Usage: x ** y

Parameters:
    x : ^T - The input base.
    y : ^U - The input exponent.

Returns: ^T The base raised to the exponent.
Modifiers: inline
Type parameters: ^T, ^U

Overloaded power operator.

x : ^T

The input base.

y : ^U

The input exponent.

Returns: ^T

The base raised to the exponent.

Example


            

x + y

Full Usage: x + y

Parameters:
    x : ^T1 - The first parameter.
    y : ^T2 - The second parameter.

Returns: ^T3 The result of the operation.
Modifiers: inline
Type parameters: ^T1, ^T2, ^T3

Overloaded addition operator

x : ^T1

The first parameter.

y : ^T2

The second parameter.

Returns: ^T3

The result of the operation.

Example

 2 + 2 //  Evaluates to 4
 "Hello " + "Word" // Evaluates to "Hello World"

x - y

Full Usage: x - y

Parameters:
    x : ^T1 - The first parameter.
    y : ^T2 - The second parameter.

Returns: ^T3 The result of the operation.
Modifiers: inline
Type parameters: ^T1, ^T2, ^T3

Overloaded subtraction operator

x : ^T1

The first parameter.

y : ^T2

The second parameter.

Returns: ^T3

The result of the operation.

Example

 10 - 2 //  Evaluates to 8

start .. finish

Full Usage: start .. finish

Parameters:
    start : ^T - The start value of the range.
    finish : ^T - The end value of the range.

Returns: seq<^T> The sequence spanning the range.
Modifiers: inline
Type parameters: ^T

The standard overloaded range operator, e.g. [n..m] for lists, seq {n..m} for sequences

start : ^T

The start value of the range.

finish : ^T

The end value of the range.

Returns: seq<^T>

The sequence spanning the range.

Example

 [1..4]      //  Evaluates to [1; 2; 3; 4]
 [1.5..4.4]  //  Evaluates to [1.5; 2.5; 3.5]
 ['a'..'d']  //  Evaluates to ['a'; 'b'; 'c'; 'd']
 
 [|1..4|]    //  Evaluates to an array [|1; 2; 3; 4|]
 { 1..4 }    //  Evaluates to a sequence [1; 2; 3; 4])

(....) start step finish

Full Usage: (....) start step finish

Parameters:
    start : ^T - The start value of the range.
    step : ^Step - The step value of the range.
    finish : ^T - The end value of the range.

Returns: seq<^T> The sequence spanning the range using the specified step size.
Modifiers: inline
Type parameters: ^T, ^Step

The standard overloaded skip range operator, e.g. [n..skip..m] for lists, seq {n..skip..m} for sequences

start : ^T

The start value of the range.

step : ^Step

The step value of the range.

finish : ^T

The end value of the range.

Returns: seq<^T>

The sequence spanning the range using the specified step size.

Example

 [1..2..6]           //  Evaluates to [1; 3; 5]
 [1.1..0.2..1.5]     //  Evaluates to [1.1; 1.3; 1.5]
 ['a'..'e'] //  Evaluates to ['a'; 'b'; 'c'; 'd'; 'e']

x / y

Full Usage: x / y

Parameters:
    x : ^T1 - The first parameter.
    y : ^T2 - The second parameter.

Returns: ^T3 The result of the operation.
Modifiers: inline
Type parameters: ^T1, ^T2, ^T3

Overloaded division operator

x : ^T1

The first parameter.

y : ^T2

The second parameter.

Returns: ^T3

The result of the operation.

Example

 16 / 2 //  Evaluates to 8

cell := value

Full Usage: cell := value

Parameters:
    cell : 'T ref - The cell to mutate.
    value : 'T - The value to set inside the cell.

Assign to a mutable reference cell

cell : 'T ref

The cell to mutate.

value : 'T

The value to set inside the cell.

Example

 let count = ref 0   // Creates a reference cell object with a mutable Value property
 count.Value <- 1    // Updates the value
 count := 2          // Also updates the value, but with shorter syntax     
 count.Value         // Evaluates to 2

x < y

Full Usage: x < y

Parameters:
    x : 'T - The first parameter.
    y : 'T - The second parameter.

Returns: bool The result of the comparison.
Modifiers: inline
Type parameters: 'T

Structural less-than comparison

x : 'T

The first parameter.

y : 'T

The second parameter.

Returns: bool

The result of the comparison.

Example

 1 < 5               // Evaluates to true
 5 < 5               // Evaluates to false
 (1, "a") < (1, "z") // Evaluates to true

func2 << func1

Full Usage: func2 << func1

Parameters:
    func2 : 'T2 -> 'T3 - The second function to apply.
    func1 : 'T1 -> 'T2 - The first function to apply.

Returns: 'T1 -> 'T3 The composition of the input functions.
Modifiers: inline
Type parameters: 'T2, 'T3, 'T1

Compose two functions, the function on the right being applied first

func2 : 'T2 -> 'T3

The second function to apply.

func1 : 'T1 -> 'T2

The first function to apply.

Returns: 'T1 -> 'T3

The composition of the input functions.

Example

 let addOne x = x + 1
 let doubleIt x = x * 2
 let doubleThenAdd = addOne << doubleIt
 doubleThenAdd 3

value <<< shift

Full Usage: value <<< shift

Parameters:
    value : ^T - The input value.
    shift : int32 - The amount to shift.

Returns: ^T The result of the operation.
Modifiers: inline
Type parameters: ^T

Overloaded byte-shift left operator by a specified number of bits

value : ^T

The input value.

shift : int32

The amount to shift.

Returns: ^T

The result of the operation.

Example

 let a = 13       // 00000000000000000000000000001101
 let c = a << 4   // 00000000000000000000000011010000
Evaluates to 206

x <= y

Full Usage: x <= y

Parameters:
    x : 'T - The first parameter.
    y : 'T - The second parameter.

Returns: bool The result of the comparison.
Modifiers: inline
Type parameters: 'T

Structural less-than-or-equal comparison

x : 'T

The first parameter.

y : 'T

The second parameter.

Returns: bool

The result of the comparison.

Example

  5 <= 1              // Evaluates to false
  5 <= 5              // Evaluates to true
  [1; 5] <= [1; 6]    // Evaluates to true

x <> y

Full Usage: x <> y

Parameters:
    x : 'T - The first parameter.
    y : 'T - The second parameter.

Returns: bool The result of the comparison.
Modifiers: inline
Type parameters: 'T

Structural inequality

x : 'T

The first parameter.

y : 'T

The second parameter.

Returns: bool

The result of the comparison.

Example

  5 <> 5              // Evaluates to false
  5 <> 6              // Evaluates to true
  [1; 2] <> [1; 2]    // Evaluates to false

func <| arg1

Full Usage: func <| arg1

Parameters:
    func : 'T -> 'U - The function.
    arg1 : 'T - The argument.

Returns: 'U The function result.
Modifiers: inline
Type parameters: 'T, 'U

Apply a function to a value, the value being on the right, the function on the left

func : 'T -> 'U

The function.

arg1 : 'T

The argument.

Returns: 'U

The function result.

Example

 let doubleIt x = x * 2
 doubleIt <| 3  //  Evaluates to 6

func <|| (arg1, arg2)

Full Usage: func <|| (arg1, arg2)

Parameters:
    func : 'T1 -> 'T2 -> 'U - The function.
    arg1 : 'T1 - The first argument.
    arg2 : 'T2 - The second argument.

Returns: 'U The function result.
Modifiers: inline
Type parameters: 'T1, 'T2, 'U

Apply a function to two values, the values being a pair on the right, the function on the left

func : 'T1 -> 'T2 -> 'U

The function.

arg1 : 'T1

The first argument.

arg2 : 'T2

The second argument.

Returns: 'U

The function result.

Example

 let sum x y = x + y
 sum <|| (3, 4)   // Evaluates to 7

func <||| (arg1, arg2, arg3)

Full Usage: func <||| (arg1, arg2, arg3)

Parameters:
    func : 'T1 -> 'T2 -> 'T3 -> 'U - The function.
    arg1 : 'T1 - The first argument.
    arg2 : 'T2 - The second argument.
    arg3 : 'T3 - The third argument.

Returns: 'U The function result.
Modifiers: inline
Type parameters: 'T1, 'T2, 'T3, 'U

Apply a function to three values, the values being a triple on the right, the function on the left

func : 'T1 -> 'T2 -> 'T3 -> 'U

The function.

arg1 : 'T1

The first argument.

arg2 : 'T2

The second argument.

arg3 : 'T3

The third argument.

Returns: 'U

The function result.

Example

 let sum3 x y z = x + y + z
 sum3 <||| (3, 4, 5)   // Evaluates to 12

x = y

Full Usage: x = y

Parameters:
    x : 'T - The first parameter.
    y : 'T - The second parameter.

Returns: bool The result of the comparison.
Modifiers: inline
Type parameters: 'T

Structural equality

x : 'T

The first parameter.

y : 'T

The second parameter.

Returns: bool

The result of the comparison.

Example

  5 = 5              // Evaluates to true
  5 = 6              // Evaluates to false
  [1; 2] = [1; 2]    // Evaluates to true
  (1, 5) = (1, 6)    // Evaluates to false

x > y

Full Usage: x > y

Parameters:
    x : 'T - The first parameter.
    y : 'T - The second parameter.

Returns: bool The result of the comparison.
Modifiers: inline
Type parameters: 'T

Structural greater-than

x : 'T

The first parameter.

y : 'T

The second parameter.

Returns: bool

The result of the comparison.

Example

  5 > 1               // Evaluates to true
  5 > 5               // Evaluates to false
  (1, "a") > (1, "z") // Evaluates to false

x >= y

Full Usage: x >= y

Parameters:
    x : 'T - The first parameter.
    y : 'T - The second parameter.

Returns: bool The result of the comparison.
Modifiers: inline
Type parameters: 'T

Structural greater-than-or-equal

x : 'T

The first parameter.

y : 'T

The second parameter.

Returns: bool

The result of the comparison.

Example

  5 >= 1              // Evaluates to true
  5 >= 5              // Evaluates to true
  [1; 5] >= [1; 6]    // Evaluates to false

func1 >> func2

Full Usage: func1 >> func2

Parameters:
    func1 : 'T1 -> 'T2 - The first function to apply.
    func2 : 'T2 -> 'T3 - The second function to apply.

Returns: 'T1 -> 'T3 The composition of the input functions.
Modifiers: inline
Type parameters: 'T1, 'T2, 'T3

Compose two functions, the function on the left being applied first

func1 : 'T1 -> 'T2

The first function to apply.

func2 : 'T2 -> 'T3

The second function to apply.

Returns: 'T1 -> 'T3

The composition of the input functions.

Example

 let addOne x = x + 1
 let doubleIt x = x * 2
 let addThenDouble = addOne >> doubleIt
 addThenDouble 3  // Evaluates to 8

value >>> shift

Full Usage: value >>> shift

Parameters:
    value : ^T - The input value.
    shift : int32 - The amount to shift.

Returns: ^T The result of the operation.
Modifiers: inline
Type parameters: ^T

Overloaded byte-shift right operator by a specified number of bits

value : ^T

The input value.

shift : int32

The amount to shift.

Returns: ^T

The result of the operation.

Example

 let a = 206      // 00000000000000000000000011010000
 let c1 = a >> 2  // 00000000000000000000000000110100
 // Evaluates to 51
 let c2 = a >> 6  // 00000000000000000000000000000011
 Evaluates to 3

list1 @ list2

Full Usage: list1 @ list2

Parameters:
    list1 : 'T list - The first list.
    list2 : 'T list - The second list.

Returns: 'T list The concatenation of the lists.

Concatenate two lists.

list1 : 'T list

The first list.

list2 : 'T list

The second list.

Returns: 'T list

The concatenation of the lists.

Example

 let l1 = ['a'; 'b'; 'c']
 let l2 = ['d'; 'e'; 'f']
 l1 @ l2   //  Evalulates to ['a'; 'b'; 'c'; 'd'; 'e'; 'f']

s1 ^ s2

Full Usage: s1 ^ s2

Parameters:
Returns: string

Concatenate two strings. The operator '+' may also be used.

s1 : string
s2 : string
Returns: string

x ^^^ y

Full Usage: x ^^^ y

Parameters:
    x : ^T - The first parameter.
    y : ^T - The second parameter.

Returns: ^T The result of the operation.
Modifiers: inline
Type parameters: ^T

Overloaded bitwise-XOR operator

x : ^T

The first parameter.

y : ^T

The second parameter.

Returns: ^T

The result of the operation.

Example

 let a = 13       // 00000000000000000000000000001101
 let b = 11       // 00000000000000000000000000001011
 let c = a ^^^ b  // 00000000000000000000000000000110
Evaluates to 6

arg |> func

Full Usage: arg |> func

Parameters:
    arg : 'T1 - The argument.
    func : 'T1 -> 'U - The function.

Returns: 'U The function result.
Modifiers: inline
Type parameters: 'T1, 'U

Apply a function to a value, the value being on the left, the function on the right

arg : 'T1

The argument.

func : 'T1 -> 'U

The function.

Returns: 'U

The function result.

Example

 let doubleIt x = x * 2
 3 |> doubleIt  //  Evaluates to 6

(arg1, arg2) ||> func

Full Usage: (arg1, arg2) ||> func

Parameters:
    arg1 : 'T1 - The first argument.
    arg2 : 'T2 - The second argument.
    func : 'T1 -> 'T2 -> 'U - The function.

Returns: 'U The function result.
Modifiers: inline
Type parameters: 'T1, 'T2, 'U

Apply a function to two values, the values being a pair on the left, the function on the right

arg1 : 'T1

The first argument.

arg2 : 'T2

The second argument.

func : 'T1 -> 'T2 -> 'U

The function.

Returns: 'U

The function result.

Example

 let sum x y = x + y
 (3, 4) ||> sum   // Evaluates to 7

x ||| y

Full Usage: x ||| y

Parameters:
    x : ^T - The first parameter.
    y : ^T - The second parameter.

Returns: ^T The result of the operation.
Modifiers: inline
Type parameters: ^T

Overloaded bitwise-OR operator

x : ^T

The first parameter.

y : ^T

The second parameter.

Returns: ^T

The result of the operation.

Example

 let a = 13       // 00000000000000000000000000001101
 let b = 11       // 00000000000000000000000000001011
 let c = a ||| b  // 00000000000000000000000000001111
Evaluates to 15

(arg1, arg2, arg3) |||> func

Full Usage: (arg1, arg2, arg3) |||> func

Parameters:
    arg1 : 'T1 - The first argument.
    arg2 : 'T2 - The second argument.
    arg3 : 'T3 - The third argument.
    func : 'T1 -> 'T2 -> 'T3 -> 'U - The function.

Returns: 'U The function result.
Modifiers: inline
Type parameters: 'T1, 'T2, 'T3, 'U

Apply a function to three values, the values being a triple on the left, the function on the right

arg1 : 'T1

The first argument.

arg2 : 'T2

The second argument.

arg3 : 'T3

The third argument.

func : 'T1 -> 'T2 -> 'T3 -> 'U

The function.

Returns: 'U

The function result.

Example

 let sum3 x y z = x + y + z
 (3, 4, 5) |||> sum3   // Evaluates to 12

~+value

Full Usage: ~+value

Parameters:
    value : ^T - The input value.

Returns: ^T The result of the operation.
Modifiers: inline
Type parameters: ^T

Overloaded prefix-plus operator

value : ^T

The input value.

Returns: ^T

The result of the operation.

~-n

Full Usage: ~-n

Parameters:
    n : ^T - The value to negate.

Returns: ^T The result of the operation.
Modifiers: inline
Type parameters: ^T

Overloaded unary negation.

n : ^T

The value to negate.

Returns: ^T

The result of the operation.

~~~value

Full Usage: ~~~value

Parameters:
    value : ^T - The input value.

Returns: ^T The result of the operation.
Modifiers: inline
Type parameters: ^T

Overloaded bitwise-NOT operator

value : ^T

The input value.

Returns: ^T

The result of the operation.

Example

 let byte1 = 60uy  //  00111100
 let byte2 = ~~~b1 //  11000011
Evaluates to 195

Failure message

Full Usage: Failure message

Parameters:
    message : string - The message for the Exception.

Returns: exn A System.Exception.

Builds a Exception object.

message : string

The message for the Exception.

Returns: exn

A System.Exception.

Example

 let throwException() = 
     raise(Failure("Oh no!!!")) 
     true  // Never gets here
   
   throwException() //  Throws a generic Exception class

abs value

Full Usage: abs value

Parameters:
    value : ^T - The input value.

Returns: ^T The absolute value of the input.
Modifiers: inline
Type parameters: ^T

Absolute value of the given number.

value : ^T

The input value.

Returns: ^T

The absolute value of the input.

Example

 abs -12    // Evaluates to 12
 abs -15.0  // Evaluates to 15.0

acos value

Full Usage: acos value

Parameters:
    value : ^T - The input value.

Returns: ^T The inverse cosine of the input.
Modifiers: inline
Type parameters: ^T

Inverse cosine of the given number

value : ^T

The input value.

Returns: ^T

The inverse cosine of the input.

Example

 let angleFromAdjacent adjacent hypotenuse = acos(adjacent / hypotenuse)
 angleFromAdjacent 8.0 10.0  //  Evaluates to 0.6435011088

asin value

Full Usage: asin value

Parameters:
    value : ^T - The input value.

Returns: ^T The inverse sine of the input.
Modifiers: inline
Type parameters: ^T

Inverse sine of the given number

value : ^T

The input value.

Returns: ^T

The inverse sine of the input.

Example

 let angleFromOpposite opposite hypotenuse = asin(opposite / hypotenuse)
 angleFromOpposite 6.0 10.0  //  Evaluates to 0.6435011088
 angleFromOpposite 5.0 3.0  //  Evaluates to nan

atan value

Full Usage: atan value

Parameters:
    value : ^T - The input value.

Returns: ^T The inverse tangent of the input.
Modifiers: inline
Type parameters: ^T

Inverse tangent of the given number

value : ^T

The input value.

Returns: ^T

The inverse tangent of the input.

Example

 let angleFrom opposite adjacent = atan(opposite / adjacent)
 angleFrom 5.0 5.0   //  Evaluates to 0.7853981634

atan2 y x

Full Usage: atan2 y x

Parameters:
    y : ^T1 - The y input value.
    x : ^T1 - The x input value.

Returns: 'T2 The inverse tangent of the input ratio.
Modifiers: inline
Type parameters: ^T1, 'T2

Inverse tangent of x/y where x and y are specified separately

y : ^T1

The y input value.

x : ^T1

The x input value.

Returns: 'T2

The inverse tangent of the input ratio.

Example

 let angleFromPlaneAtXY x y = atan2 y x * 180.0 / System.Math.PI
 angleFromPlaneAtXY 0.0 -1.0   //  Evaluates to -90.0
 angleFromPlaneAtXY 1.0 1.0    //  Evaluates to 45.0
 angleFromPlaneAtXY -1.0 1.0   //  Evaluates to 135.0

box value

Full Usage: box value

Parameters:
    value : 'T - The value to box.

Returns: obj The boxed object.
Modifiers: inline
Type parameters: 'T

Boxes a strongly typed value.

value : 'T

The value to box.

Returns: obj

The boxed object.

Example

 let x: int = 123
 let obj1 = box x    //  obj1 is a generic object type
 unbox obj1     //  Evaluates to 123 (int)
 unbox obj1  //  Throws System.InvalidCastException

byte value

Full Usage: byte value

Parameters:
    value : ^T - The input value.

Returns: byte The converted byte
Modifiers: inline
Type parameters: ^T

Converts the argument to byte. This is a direct conversion for all primitive numeric types. For strings, the input is converted using Byte.Parse() with InvariantCulture settings. Otherwise the operation requires an appropriate static conversion method on the input type.

value : ^T

The input value.

Returns: byte

The converted byte

Example


            

ceil value

Full Usage: ceil value

Parameters:
    value : ^T - The input value.

Returns: ^T The ceiling of the input.
Modifiers: inline
Type parameters: ^T

Ceiling of the given number

value : ^T

The input value.

Returns: ^T

The ceiling of the input.

Example

 ceil 12.1  //  Evaluates to 13.0
 ceil -1.9  //  Evaluates to -1.0

char value

Full Usage: char value

Parameters:
    value : ^T - The input value.

Returns: char The converted char.
Modifiers: inline
Type parameters: ^T

Converts the argument to character. Numeric inputs are converted according to the UTF-16 encoding for characters. String inputs must be exactly one character long. For other input types the operation requires an appropriate static conversion method on the input type.

value : ^T

The input value.

Returns: char

The converted char.

Example


            

compare e1 e2

Full Usage: compare e1 e2

Parameters:
    e1 : 'T - The first value.
    e2 : 'T - The second value.

Returns: int The result of the comparison.
Modifiers: inline
Type parameters: 'T

Generic comparison.

e1 : 'T

The first value.

e2 : 'T

The second value.

Returns: int

The result of the comparison.

Example

 compare 1 2             //  Evaluates to -1
 compare [1;2;3] [1;2;4] //  Evaluates to -1
 compare 2 2             //  Evaluates to 0
 compare [1;2;3] [1;2;3] //  Evaluates to 0
 compare 2 1             //  Evaluates to 1
 compare [1;2;4] [1;2;3] //  Evaluates to 1

cos value

Full Usage: cos value

Parameters:
    value : ^T - The input value.

Returns: ^T The cosine of the input.
Modifiers: inline
Type parameters: ^T

Cosine of the given number

value : ^T

The input value.

Returns: ^T

The cosine of the input.

Example


            

cosh value

Full Usage: cosh value

Parameters:
    value : ^T - The input value.

Returns: ^T The hyperbolic cosine of the input.
Modifiers: inline
Type parameters: ^T

Hyperbolic cosine of the given number

value : ^T

The input value.

Returns: ^T

The hyperbolic cosine of the input.

Example


            

decimal value

Full Usage: decimal value

Parameters:
    value : ^T - The input value.

Returns: decimal The converted decimal.
Modifiers: inline
Type parameters: ^T

Converts the argument to System.Decimal using a direct conversion for all primitive numeric types. For strings, the input is converted using UInt64.Parse() with InvariantCulture settings. Otherwise the operation requires an appropriate static conversion method on the input type.

value : ^T

The input value.

Returns: decimal

The converted decimal.

Example


            

decr cell

Full Usage: decr cell

Parameters:
    cell : int ref - The reference cell.

Decrement a mutable reference cell containing an integer

cell : int ref

The reference cell.

Example

 let count = ref 99  // Creates a reference cell object with a mutable Value property
 decr count          // Decrements our counter
 count.Value         // Evaluates to 98

defaultArg arg defaultValue

Full Usage: defaultArg arg defaultValue

Parameters:
    arg : 'T option - An option representing the argument.
    defaultValue : 'T - The default value of the argument.

Returns: 'T The argument value. If it is None, the defaultValue is returned.

Used to specify a default value for an optional argument in the implementation of a function

arg : 'T option

An option representing the argument.

defaultValue : 'T

The default value of the argument.

Returns: 'T

The argument value. If it is None, the defaultValue is returned.

Example

 type Vector(x: double, y: double, ?z: double) = 
     let z = defaultArg z 0.0
     member this.X = x
     member this.Y = y
     member this.Z = z
 
 let v1 = Vector(1.0, 2.0)
 v1.Z  // Evaluates to 0.
 let v2 = Vector(1.0, 2.0, 3.0)
 v2.Z  // Evaluates to 3.0

defaultValueArg arg defaultValue

Full Usage: defaultValueArg arg defaultValue

Parameters:
    arg : 'T voption - A value option representing the argument.
    defaultValue : 'T - The default value of the argument.

Returns: 'T The argument value. If it is None, the defaultValue is returned.

Used to specify a default value for an optional argument in the implementation of a function

arg : 'T voption

A value option representing the argument.

defaultValue : 'T

The default value of the argument.

Returns: 'T

The argument value. If it is None, the defaultValue is returned.

Example

 let arg1 = ValueSome(5)
 defaultValueArg arg1 6       //  Evaluates to 5
 defaultValueArg ValueNone 6  //  Evaluates to 6

enum value

Full Usage: enum value

Parameters:
    value : int32 - The input value.

Returns: ^U The converted enum type.
Modifiers: inline
Type parameters: ^U

Converts the argument to a particular enum type.

value : int32

The input value.

Returns: ^U

The converted enum type.

Example


            

exit exitcode

Full Usage: exit exitcode

Parameters:
    exitcode : int - The exit code to use.

Returns: 'T The result value.

Exit the current hardware isolated process, if security settings permit, otherwise raise an exception. Calls Environment.Exit.

exitcode : int

The exit code to use.

Returns: 'T

The result value.

Example

 []
 let main argv = 
     if argv.Length = 0 then
         eprintfn "You must provide arguments"
         exit(-1)  // Causes program to quit with an error code
     printfn "Argument count: %i" argv.Length
     0

exp value

Full Usage: exp value

Parameters:
    value : ^T - The input value.

Returns: ^T The exponential of the input.
Modifiers: inline
Type parameters: ^T

Exponential of the given number

value : ^T

The input value.

Returns: ^T

The exponential of the input.

Example

 exp 0.0   //  Evaluates to 1.0
 exp 1.0   //  Evaluates to 2.718281828
 exp -1.0  //  Evaluates to 0.3678794412
 exp 2.0   //  Evaluates to 7.389056099

failwith message

Full Usage: failwith message

Parameters:
    message : string - The exception message.

Returns: 'T The result value.
Modifiers: inline
Type parameters: 'T

Throw a Exception exception.

message : string

The exception message.

Returns: 'T

The result value.

Example

 let failingFunction() = 
     failwith "Oh no" // Throws an exception
     true  // Never reaches this
   
 failingFunction()  // Throws a System.Exception

float value

Full Usage: float value

Parameters:
    value : ^T - The input value.

Returns: float The converted float
Modifiers: inline
Type parameters: ^T

Converts the argument to 64-bit float. This is a direct conversion for all primitive numeric types. For strings, the input is converted using Double.Parse() with InvariantCulture settings. Otherwise the operation requires an appropriate static conversion method on the input type.

value : ^T

The input value.

Returns: float

The converted float

Example


            

float32 value

Full Usage: float32 value

Parameters:
    value : ^T - The input value.

Returns: float32 The converted float32
Modifiers: inline
Type parameters: ^T

Converts the argument to 32-bit float. This is a direct conversion for all primitive numeric types. For strings, the input is converted using Single.Parse() with InvariantCulture settings. Otherwise the operation requires an appropriate static conversion method on the input type.

value : ^T

The input value.

Returns: float32

The converted float32

Example


            

floor value

Full Usage: floor value

Parameters:
    value : ^T - The input value.

Returns: ^T The floor of the input.
Modifiers: inline
Type parameters: ^T

Floor of the given number

value : ^T

The input value.

Returns: ^T

The floor of the input.

Example

 floor 12.1  //  Evaluates to 12.0
 floor -1.9  //  Evaluates to -2.0

fst tuple

Full Usage: fst tuple

Parameters:
    tuple : 'T1 * 'T2 - The input tuple.

Returns: 'T1 The first value.
Modifiers: inline
Type parameters: 'T1, 'T2

Return the first element of a tuple, fst (a,b) = a.

tuple : 'T1 * 'T2

The input tuple.

Returns: 'T1

The first value.

Example

 fst ("first", 2)  //  Evaluates to "first"

hash obj

Full Usage: hash obj

Parameters:
    obj : 'T - The input object.

Returns: int The computed hash.
Modifiers: inline
Type parameters: 'T

A generic hash function, designed to return equal hash values for items that are equal according to the "=" operator. By default it will use structural hashing for F# union, record and tuple types, hashing the complete contents of the type. The exact behaviour of the function can be adjusted on a type-by-type basis by implementing GetHashCode for each type.

obj : 'T

The input object.

Returns: int

The computed hash.

Example

 hash "Bob Jones"  // Evaluates to -325251320

id x

Full Usage: id x

Parameters:
    x : 'T - The input value.

Returns: 'T The same value.

The identity function

x : 'T

The input value.

Returns: 'T

The same value.

Example

 id 12     //  Evaulates to 12
 id "abc"  //  Evaulates to "abc"

ignore value

Full Usage: ignore value

Parameters:
    value : 'T - The value to ignore.

Modifiers: inline
Type parameters: 'T

Ignore the passed value. This is often used to throw away results of a computation.

value : 'T

The value to ignore.

Example

  ignore 55555   //  Evaluates to ()

incr cell

Full Usage: incr cell

Parameters:
    cell : int ref - The reference cell.

Increment a mutable reference cell containing an integer

cell : int ref

The reference cell.

Example

 let count = ref 99  // Creates a reference cell object with a mutable Value property
 incr count          // Increments our counter
 count.Value         // Evaluates to 100

infinity

Full Usage: infinity

Returns: float
Returns: float

infinityf

Full Usage: infinityf

Returns: float32
Returns: float32

int value

Full Usage: int value

Parameters:
    value : ^T - The input value.

Returns: int The converted int
Modifiers: inline
Type parameters: ^T

Converts the argument to signed 32-bit integer. This is a direct conversion for all primitive numeric types. For strings, the input is converted using Int32.Parse() with InvariantCulture settings. Otherwise the operation requires an appropriate static conversion method on the input type.

value : ^T

The input value.

Returns: int

The converted int

Example


            

int16 value

Full Usage: int16 value

Parameters:
    value : ^T - The input value.

Returns: int16 The converted int16
Modifiers: inline
Type parameters: ^T

Converts the argument to signed 16-bit integer. This is a direct conversion for all primitive numeric types. For strings, the input is converted using Int16.Parse() with InvariantCulture settings. Otherwise the operation requires an appropriate static conversion method on the input type.

value : ^T

The input value.

Returns: int16

The converted int16

Example


            

int32 value

Full Usage: int32 value

Parameters:
    value : ^T - The input value.

Returns: int32 The converted int32
Modifiers: inline
Type parameters: ^T

Converts the argument to signed 32-bit integer. This is a direct conversion for all primitive numeric types. For strings, the input is converted using Int32.Parse() with InvariantCulture settings. Otherwise the operation requires an appropriate static conversion method on the input type.

value : ^T

The input value.

Returns: int32

The converted int32

Example


            

int64 value

Full Usage: int64 value

Parameters:
    value : ^T - The input value.

Returns: int64 The converted int64
Modifiers: inline
Type parameters: ^T

Converts the argument to signed 64-bit integer. This is a direct conversion for all primitive numeric types. For strings, the input is converted using Int64.Parse() with InvariantCulture settings. Otherwise the operation requires an appropriate static conversion method on the input type.

value : ^T

The input value.

Returns: int64

The converted int64

Example


            

invalidArg argumentName message

Full Usage: invalidArg argumentName message

Parameters:
    argumentName : string - The argument name.
    message : string - The exception message.

Returns: 'T The result value.
Modifiers: inline
Type parameters: 'T

Throw a ArgumentException exception with the given argument name and message.

argumentName : string

The argument name.

message : string

The exception message.

Returns: 'T

The result value.

Example

 let fullName firstName lastName = 
     if String.IsNullOrWhiteSpace(firstName) then
         invalidArg (nameof(firstName)) "First name can't be null or blank"
         if String.IsNullOrWhiteSpace(lastName) then
             invalidArg (nameof(lastName)) "Last name can't be null or blank"
     firstName + " " + lastName
   
 fullName null "Jones"
Throws System.ArgumentException: First name can't be null or blank (Parameter 'firstName')

invalidOp message

Full Usage: invalidOp message

Parameters:
    message : string - The exception message.

Returns: 'T The result value.
Modifiers: inline
Type parameters: 'T

Throw a InvalidOperationException exception

message : string

The exception message.

Returns: 'T

The result value.

Example

 type FileReader(filename: string) = 
     let mutable isOpen = false
     member this.Open() = 
       if isOpen then invalidOp "File is already open"
       //  ... Here we may open the file ...
       isOpen <- true
 
 let reader = FileReader("journal.txt")
 reader.Open()  //  Executes fine
 reader.Open()  //  Throws System.InvalidOperationException: File is already open

isNull value

Full Usage: isNull value

Parameters:
    value : 'T - The value to check.

Returns: bool True when value is null, false otherwise.
Modifiers: inline
Type parameters: 'T

Determines whether the given value is null.

value : 'T

The value to check.

Returns: bool

True when value is null, false otherwise.

Example

 isNull null        //  Evaluates to true
 isNull "Not null"  //  Evaluates to false

limitedHash limit obj

Full Usage: limitedHash limit obj

Parameters:
    limit : int - The limit of nodes.
    obj : 'T - The input object.

Returns: int The computed hash.
Modifiers: inline
Type parameters: 'T

A generic hash function. This function has the same behaviour as 'hash', however the default structural hashing for F# union, record and tuple types stops when the given limit of nodes is reached. The exact behaviour of the function can be adjusted on a type-by-type basis by implementing GetHashCode for each type.

limit : int

The limit of nodes.

obj : 'T

The input object.

Returns: int

The computed hash.

lock lockObject action

Full Usage: lock lockObject action

Parameters:
    lockObject : 'Lock - The object to be locked.
    action : unit -> 'T - The action to perform during the lock.

Returns: 'T The resulting value.
Modifiers: inline
Type parameters: 'Lock, 'T

Execute the function as a mutual-exclusion region using the input value as a lock.

lockObject : 'Lock

The object to be locked.

action : unit -> 'T

The action to perform during the lock.

Returns: 'T

The resulting value.

Example

 open System.Linq

 /// A counter object, supporting unlocked and locked increment
 type TestCounter () =
     let mutable count = 0
     
     /// Increment the counter, unlocked
     member this.IncrementWithoutLock() =
         count <- count + 1

     /// Increment the counter, locked
     member this.IncrementWithLock() = 
         lock this (fun () -> count <- count + 1)

     /// Get the count
     member this.Count = count
         
 let counter = TestCounter()

 // Create a parallel sequence to that uses all our CPUs
 (seq {1..100000}).AsParallel()
     .ForAll(fun _ -> counter.IncrementWithoutLock())
 
 // Evaluates to a number between 1-100000, non-deterministically because there is no locking
 counter.Count
 
 let counter2 = TestCounter()

 //  Create a parallel sequence to that uses all our CPUs
 (seq {1..100000}).AsParallel()
     .ForAll(fun _ -> counter2.IncrementWithLock())
 
 //  Evaluates to 100000 deterministically because the increment to the counter object is locked
 counter.Count

log value

Full Usage: log value

Parameters:
    value : ^T - The input value.

Returns: ^T The natural logarithm of the input.
Modifiers: inline
Type parameters: ^T

Natural logarithm of the given number

value : ^T

The input value.

Returns: ^T

The natural logarithm of the input.

Example

 let logBase baseNumber value = (log value) / (log baseNumber)
 logBase 2.0 32.0      //  Evaluates to 5.0
 logBase 10.0 1000.0   //  Evaluates to 3.0

log10 value

Full Usage: log10 value

Parameters:
    value : ^T - The input value.

Returns: ^T The logarithm to base 10 of the input.
Modifiers: inline
Type parameters: ^T

Logarithm to base 10 of the given number

value : ^T

The input value.

Returns: ^T

The logarithm to base 10 of the input.

Example

 log10 1000.0    //  Evaluates to 3.0
 log10 100000.0  //  Evaluates to 5.0
 log10 0.0001    //  Evaluates to -4.0
 log10 -20.0     //  Evaluates to nan

max e1 e2

Full Usage: max e1 e2

Parameters:
    e1 : 'T - The first value.
    e2 : 'T - The second value.

Returns: 'T The maximum value.
Modifiers: inline
Type parameters: 'T

Maximum based on generic comparison

e1 : 'T

The first value.

e2 : 'T

The second value.

Returns: 'T

The maximum value.

Example

  max 1 2             //  Evaluates to 2
  max [1;2;3] [1;2;4] //  Evaluates to [1;2;4]
  max "zoo" "alpha"   //  Evaluates to "zoo"

methodhandleof arg1

Full Usage: methodhandleof arg1

Parameters:
    arg0 : 'T -> 'TResult

Returns: RuntimeMethodHandle

An internal, library-only compiler intrinsic for compile-time generation of a RuntimeMethodHandle.

arg0 : 'T -> 'TResult
Returns: RuntimeMethodHandle

min e1 e2

Full Usage: min e1 e2

Parameters:
    e1 : 'T - The first value.
    e2 : 'T - The second value.

Returns: 'T The minimum value.
Modifiers: inline
Type parameters: 'T

Minimum based on generic comparison

e1 : 'T

The first value.

e2 : 'T

The second value.

Returns: 'T

The minimum value.

Example

  min 1 2             //  Evaluates to 1
  min [1;2;3] [1;2;4] //  Evaluates to [1;2;3]
  min "zoo" "alpha"   //  Evaluates to "alpha"

nameof arg1

Full Usage: nameof arg1

Parameters:
    arg0 : 'T

Returns: string
Modifiers: inline
Type parameters: 'T

Returns the name of the given symbol.

arg0 : 'T
Returns: string
Example

 let myVariableName = "This value doesn't matter"
 nameof(myVariableName)   //  Evaluates to "myVariableName"

nan

Full Usage: nan

Returns: float

Equivalent to Double.NaN

Returns: float

nanf

Full Usage: nanf

Returns: float32

Equivalent to Single.NaN

Returns: float32

nativeint value

Full Usage: nativeint value

Parameters:
    value : ^T - The input value.

Returns: nativeint The converted nativeint
Modifiers: inline
Type parameters: ^T

Converts the argument to signed native integer. This is a direct conversion for all primitive numeric types. Otherwise the operation requires an appropriate static conversion method on the input type.

value : ^T

The input value.

Returns: nativeint

The converted nativeint

Example


            

not value

Full Usage: not value

Parameters:
    value : bool - The value to negate.

Returns: bool The result of the negation.
Modifiers: inline

Negate a logical value. Not True equals False and not False equals True

value : bool

The value to negate.

Returns: bool

The result of the negation.

Example

 not (2 + 2 = 5)     // Evaluates to true 
 
 //  not is a function that can be compose with other functions
 let fileDoesNotExist = System.IO.File.Exists >> not

nullArg argumentName

Full Usage: nullArg argumentName

Parameters:
    argumentName : string - The argument name.

Returns: 'T The result value.
Modifiers: inline
Type parameters: 'T

Throw a ArgumentNullException exception

argumentName : string

The argument name.

Returns: 'T

The result value.

Example

 let fullName firstName lastName = 
     nullArg (nameof(firstName))
     nullArg (nameof(lastName))
     firstName + " " + lastName
   
   fullName null "Jones"  // Throws System.ArgumentNullException: Value cannot be null. (Parameter 'firstName')

pown x n

Full Usage: pown x n

Parameters:
    x : ^T - The input base.
    n : int - The input exponent.

Returns: ^T The base raised to the exponent.
Modifiers: inline
Type parameters: ^T

Overloaded power operator. If n > 0 then equivalent to x*...*x for n occurrences of x.

x : ^T

The input base.

n : int

The input exponent.

Returns: ^T

The base raised to the exponent.

Example


            

raise exn

Full Usage: raise exn

Parameters:
Returns: 'T The result value.
Modifiers: inline
Type parameters: 'T

Raises an exception

exn : Exception

The exception to raise.

Returns: 'T

The result value.

Example

 open System.IO
 exception FileNotFoundException of string
 
 let readFile (filename: string) = 
     if not (File.Exists(filename)) then
         raise(FileNotFoundException(filename))
     File.ReadAllText(filename)
 
 readFile "/this-file-doest-exist"
When executed, raises a FileNotFoundException.

ref value

Full Usage: ref value

Parameters:
    value : 'T - The value to contain in the cell.

Returns: 'T ref The created reference cell.

Create a mutable reference cell

value : 'T

The value to contain in the cell.

Returns: 'T ref

The created reference cell.

Example

 let count = ref 0   // Creates a reference cell object with a mutable Value property
 count.Value         // Evaluates to 0
 count.Value <- 1    // Updates the value
 count.Value         // Evaluates to 1

reraise ()

Full Usage: reraise ()

Parameters:
Returns: 'T The result value.
Modifiers: inline
Type parameters: 'T

Rethrows an exception. This should only be used when handling an exception

() : unit
Returns: 'T

The result value.

Example

 let readFile (filename: string) = 
   try
     File.ReadAllText(filename)
   with ex ->
     eprintfn "Couldn't read %s" filename
     reraise()
   
 readFile "/this-file-doest-exist"  
 //  Prints the message to stderr
 //  Throws a System.IO.FileNotFoundException

round value

Full Usage: round value

Parameters:
    value : ^T - The input value.

Returns: ^T The nearest integer to the input value.
Modifiers: inline
Type parameters: ^T

Round the given number

value : ^T

The input value.

Returns: ^T

The nearest integer to the input value.

Example

 round 3.49    //  Evaluates to 3.0
 round -3.49   //  Evaluates to -3.0
 round 3.5     //  Evaluates to 4.0
 round -3.5    //  Evaluates to -4.0

sbyte value

Full Usage: sbyte value

Parameters:
    value : ^T - The input value.

Returns: sbyte The converted sbyte
Modifiers: inline
Type parameters: ^T

Converts the argument to signed byte. This is a direct conversion for all primitive numeric types. For strings, the input is converted using SByte.Parse() with InvariantCulture settings. Otherwise the operation requires an appropriate static conversion method on the input type.

value : ^T

The input value.

Returns: sbyte

The converted sbyte

Example


            

seq sequence

Full Usage: seq sequence

Parameters:
    sequence : seq<'T> - The input sequence.

Returns: seq<'T> The result sequence.

Builds a sequence using sequence expression syntax

sequence : seq<'T>

The input sequence.

Returns: seq<'T>

The result sequence.

Example

 seq { for i in 0..10 do yield (i, i*i) }

sign value

Full Usage: sign value

Parameters:
    value : ^T - The input value.

Returns: int -1, 0, or 1 depending on the sign of the input.
Modifiers: inline
Type parameters: ^T

Sign of the given number

value : ^T

The input value.

Returns: int

-1, 0, or 1 depending on the sign of the input.

Example

 sign -12.0    //  Evaluates to -1
 sign 43       //  Evaluates to 1

sin value

Full Usage: sin value

Parameters:
    value : ^T - The input value.

Returns: ^T The sine of the input.
Modifiers: inline
Type parameters: ^T

Sine of the given number

value : ^T

The input value.

Returns: ^T

The sine of the input.

Example


            

sinh value

Full Usage: sinh value

Parameters:
    value : ^T - The input value.

Returns: ^T The hyperbolic sine of the input.
Modifiers: inline
Type parameters: ^T

Hyperbolic sine of the given number

value : ^T

The input value.

Returns: ^T

The hyperbolic sine of the input.

Example


            

sizeof

Full Usage: sizeof

Returns: int
Modifiers: inline
Type parameters: 'T

Returns the internal size of a type in bytes. For example, sizeof returns 4.

Returns: int
Example

 sizeof                   //  Evaluates to 1
 sizeof                   //  Evaluates to 1
 sizeof                    //  Evaluates to 4
 sizeof                 //  Evaluates to 8
 sizeof    //  Evaluates to 2
 sizeof              //  Evaluates to 4 or 8 (32-bit or 64-bit) depending on your platform

snd tuple

Full Usage: snd tuple

Parameters:
    tuple : 'T1 * 'T2 - The input tuple.

Returns: 'T2 The second value.
Modifiers: inline
Type parameters: 'T1, 'T2

Return the second element of a tuple, snd (a,b) = b.

tuple : 'T1 * 'T2

The input tuple.

Returns: 'T2

The second value.

Example

 snd ("first", 2)  //  Evaluates to 2

sqrt value

Full Usage: sqrt value

Parameters:
    value : ^T - The input value.

Returns: ^U The square root of the input.
Modifiers: inline
Type parameters: ^T, ^U

Square root of the given number

value : ^T

The input value.

Returns: ^U

The square root of the input.

Example

 sqrt 2.0  //  Evaluates to 1.414213562
 sqrt 100.0  //  Evaluates to 10.0

stderr

Full Usage: stderr

Returns: TextWriter

Reads the value of the property Console.Error.

Returns: TextWriter

stdin

Full Usage: stdin

Returns: TextReader

Reads the value of the property Console.In.

Returns: TextReader

stdout

Full Usage: stdout

Returns: TextWriter

Reads the value of the property Console.Out.

Returns: TextWriter

string value

Full Usage: string value

Parameters:
    value : 'T - The input value.

Returns: string The converted string.
Modifiers: inline
Type parameters: 'T

Converts the argument to a string using ToString.

For standard integer and floating point values the and any type that implements IFormattableToString conversion uses CultureInfo.InvariantCulture.

value : 'T

The input value.

Returns: string

The converted string.

Example


            

tan value

Full Usage: tan value

Parameters:
    value : ^T - The input value.

Returns: ^T The tangent of the input.
Modifiers: inline
Type parameters: ^T

Tangent of the given number

value : ^T

The input value.

Returns: ^T

The tangent of the input.

Example


            

tanh value

Full Usage: tanh value

Parameters:
    value : ^T - The input value.

Returns: ^T The hyperbolic tangent of the input.
Modifiers: inline
Type parameters: ^T

Hyperbolic tangent of the given number

value : ^T

The input value.

Returns: ^T

The hyperbolic tangent of the input.

Example


            

truncate value

Full Usage: truncate value

Parameters:
    value : ^T - The input value.

Returns: ^T The truncated value.
Modifiers: inline
Type parameters: ^T

Overloaded truncate operator.

value : ^T

The input value.

Returns: ^T

The truncated value.

Example


            

tryUnbox value

Full Usage: tryUnbox value

Parameters:
    value : obj - The boxed value.

Returns: 'T option The unboxed result as an option.
Modifiers: inline
Type parameters: 'T

Try to unbox a strongly typed value.

value : obj

The boxed value.

Returns: 'T option

The unboxed result as an option.

Example

 let x: int = 123
 let obj1 = box x    //  obj1 is a generic object type
 tryUnbox obj1     //  Evaluates to Some(123)
 tryUnbox obj1  //  Evaluates to None

typedefof

Full Usage: typedefof

Returns: Type
Modifiers: inline
Type parameters: 'T

Generate a System.Type representation for a type definition. If the input type is a generic type instantiation then return the generic type definition associated with all such instantiations.

Returns: Type
Example

 typeof     // Evaluates to Microsoft.FSharp.Collections.FSharpList`1[System.Int32]
 typedefof  // Evaluates to Microsoft.FSharp.Collections.FSharpList`1[T]        ///

typeof

Full Usage: typeof

Returns: Type
Modifiers: inline
Type parameters: 'T

Generate a System.Type runtime representation of a static type.

Returns: Type
Example

 let t = typeof  // Gets the System.Type
 t.FullName                 // Evaluates to "System.Int32"

uint value

Full Usage: uint value

Parameters:
    value : ^T - The input value.

Returns: uint The converted int
Modifiers: inline
Type parameters: ^T

Converts the argument to an unsigned 32-bit integer. This is a direct conversion for all primitive numeric types. For strings, the input is converted using UInt32.Parse() with InvariantCulture settings. Otherwise the operation requires an appropriate static conversion method on the input type.

value : ^T

The input value.

Returns: uint

The converted int

Example


            

uint16 value

Full Usage: uint16 value

Parameters:
    value : ^T - The input value.

Returns: uint16 The converted uint16
Modifiers: inline
Type parameters: ^T

Converts the argument to unsigned 16-bit integer. This is a direct conversion for all primitive numeric types. For strings, the input is converted using UInt16.Parse() with InvariantCulture settings. Otherwise the operation requires an appropriate static conversion method on the input type.

value : ^T

The input value.

Returns: uint16

The converted uint16

Example


            

uint32 value

Full Usage: uint32 value

Parameters:
    value : ^T - The input value.

Returns: uint32 The converted uint32
Modifiers: inline
Type parameters: ^T

Converts the argument to unsigned 32-bit integer. This is a direct conversion for all primitive numeric types. For strings, the input is converted using UInt32.Parse() with InvariantCulture settings. Otherwise the operation requires an appropriate static conversion method on the input type.

value : ^T

The input value.

Returns: uint32

The converted uint32

Example


            

uint64 value

Full Usage: uint64 value

Parameters:
    value : ^T - The input value.

Returns: uint64 The converted uint64
Modifiers: inline
Type parameters: ^T

Converts the argument to unsigned 64-bit integer. This is a direct conversion for all primitive numeric types. For strings, the input is converted using UInt64.Parse() with InvariantCulture settings. Otherwise the operation requires an appropriate static conversion method on the input type.

value : ^T

The input value.

Returns: uint64

The converted uint64

Example


            

unativeint value

Full Usage: unativeint value

Parameters:
    value : ^T - The input value.

Returns: unativeint The converted unativeint
Modifiers: inline
Type parameters: ^T

Converts the argument to unsigned native integer using a direct conversion for all primitive numeric types. Otherwise the operation requires an appropriate static conversion method on the input type.

value : ^T

The input value.

Returns: unativeint

The converted unativeint

Example


            

unbox value

Full Usage: unbox value

Parameters:
    value : obj - The boxed value.

Returns: 'T The unboxed result.
Modifiers: inline
Type parameters: 'T

Unbox a strongly typed value.

value : obj

The boxed value.

Returns: 'T

The unboxed result.

Example

 let x: int = 123
 let obj1 = box x    //  obj1 is a generic object type
 unbox obj1     //  Evaluates to 123 (int)
 unbox obj1  //  Throws System.InvalidCastException

using resource action

Full Usage: using resource action

Parameters:
    resource : 'T - The resource to be disposed after action is called.
    action : 'T -> 'U - The action that accepts the resource.

Returns: 'U The resulting value.

Clean up resources associated with the input object after the completion of the given function. Cleanup occurs even when an exception is raised by the protected code.

resource : 'T

The resource to be disposed after action is called.

action : 'T -> 'U

The action that accepts the resource.

Returns: 'U

The resulting value.

Example

The following code appends 10 lines to test.txt, then closes the StreamWriter when finished.

 open System.IO
 
 using (File.AppendText "test.txt") (fun writer ->
     for i in 1 .. 10 do
         writer.WriteLine("Hello World {0}", i))

Active patterns

Active pattern Description

(|Failure|_|) error

Full Usage: (|Failure|_|) error

Parameters:
    error : exn - The input exception.

Returns: string option A string option.

Matches Exception objects whose runtime type is precisely Exception

error : exn

The input exception.

Returns: string option

A string option.

(|KeyValue|) keyValuePair

Full Usage: (|KeyValue|) keyValuePair

Parameters:
    keyValuePair : KeyValuePair<'Key, 'Value> - The input key/value pair.

Returns: 'Key * 'Value A tuple containing the key and value.

An active pattern to match values of type KeyValuePair

keyValuePair : KeyValuePair<'Key, 'Value>

The input key/value pair.

Returns: 'Key * 'Value

A tuple containing the key and value.

Example