Operators.( >> )<'T1,'T2,'T3> 函数 (F#)

组合两个函数,首先应用左边的函数

命名空间/模块路径: Microsoft.FSharp.Core.Operators

程序集:FSharp.Core(在 FSharp.Core.dll 中)

// Signature:
( >> ) : ('T1 -> 'T2) -> ('T2 -> 'T3) -> 'T1 -> 'T3

// Usage:
func1 >> func2

参数

  • func1
    类型:'T1 -> 'T2

    要应用的第一个函数。

  • func2
    类型:'T2 -> 'T3

    要应用的第二个函数。

返回值

输入函数的组合。

示例

下面的示例说明组合运算符 (>>) 的用法。

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

// Composition of two functions.
let appendBoth = append1 >> append2
printfn "%s" (appendBoth "abc")

// Composition of three functions.
let append3 string1 = string1 + ".append3"
printfn "%s" ((append1 >> append2 >> append3) "abc")

// Composition of functions with more than one parameter.
let appendString (string1:string) (string2:string) = string1 + string2

let appendFileExtension extension =
    appendString "." >> appendString extension
printfn "%s" (appendFileExtension "myfile" "txt")
  

平台

Windows 8,Windows 7,Windows server 2012中,Windows server 2008 R2

版本信息

F#核心库版本

支持:2.0,4.0,可移植

请参见

参考

Core.Operators 模块 (F#)

Microsoft.FSharp.Core 命名空间 (F#)