Operators.( << )<'T2,'T3,'T1> 函式 (F#)
會來撰寫兩個函式,先套用在右側的函式。
命名空間/模組路徑: Microsoft.FSharp.Core.Operators
組件:FSharp.Core (在 FSharp.Core.dll 中)
// Signature:
( << ) : ('T2 -> 'T3) -> ('T1 -> 'T2) -> 'T1 -> 'T3
// Usage:
func2 << func1
參數
func2
型別:'T2 -> 'T3要套用的第二個函式。
func1
型別:'T1 -> 'T2要套用的第一個函式。
傳回值
輸入函式的撰寫。
備註
此運算子被指為 回溯 或 反向的複合運算子 。
範例
下列範例示範使用反向的複合運算子 ( <<)
let append1 string1 = string1 + ".append1"
let append2 string1 = string1 + ".append2"
// Reverse composition of two functions.
let appendBothReverse = append1 << append2
printfn "%s" (appendBothReverse "abc")
// Reverse composition of three functions.
let append3 string1 = string1 + ".append3"
printfn "%s" ((append1 << append2 << append3) "abc")
// Reverse composition of functions with more than one parameter.
let appendString (string1:string) (string2:string) = string1 + string2
let appendFileExtension extension =
appendString extension << appendString "."
printfn "%s" (appendFileExtension "myfile" "txt")
平台
Windows 7、Windows Vista SP2、Windows XP SP3、Windows XP x64 SP2、Windows Server 2008 R2、Windows Server 2008 SP2、Windows Server 2003 SP2
版本資訊
F# 執行階段
支援版本:2.0、4.0
Silverlight
支援版本:3