Udostępnij za pośrednictwem


Operators.( |> )<'T1,'U> Function (F#)

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

Namespace/Module Path: Microsoft.FSharp.Core.Operators

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

// Signature:
( |> ) : 'T1 -> ('T1 -> 'U) -> 'U

// Usage:
arg |> func

Parameters

  • arg
    Type: 'T1

    The argument.

  • func
    Type: 'T1 -> 'U

    The function.

Return Value

The function result.

Example

The following example demonstrates the use of the forward pipe operator.

let append1 string1 = string1 + ".append1"
let append2 string1 = string1 + ".append2"

let result1 = "abc" |> append1
printfn "\"abc\" |> append1 gives %A" result1

let result2 = "abc" 
              |> append1
              |> append2
printfn "result2: %A" result2

[1; 2; 3]
|> List.map (fun elem -> elem * 100)
|> List.rev
|> List.iter (fun elem -> printf "%d " elem)
printfn ""
"abc" |> append1 gives "abc.append1"
result2: "abc.append1.append2"
300 200 100

Platforms

Windows 7, Windows Vista SP2, Windows XP SP3, Windows XP x64 SP2, Windows Server 2008 R2, Windows Server 2008 SP2, Windows Server 2003 SP2

Version Information

F# Runtime

Supported in: 2.0, 4.0

Silverlight

Supported in: 3

See Also

Reference

Core.Operators Module (F#)

Microsoft.FSharp.Core Namespace (F#)