1 people like it.

Composition Operator

Function Composition Operator

1: 
2: 
3: 
4: 
5: 
6: 
7: 
8: 
let inline (+.) f g x = g(f x)

let a = (*) 2
let b = (+) 1
let c = (/) 3
let d = (-) 4
let f = a +. b +. c +. d
f 1 |> printfn "%i"
val f : ('a -> 'b)
val g : ('b -> 'c)
val x : 'a
val a : (int -> int)

Full name: Script.a
val b : (int -> int)

Full name: Script.b
val c : (int -> int)

Full name: Script.c
val d : (int -> int)

Full name: Script.d
val f : (int -> int)

Full name: Script.f
val printfn : format:Printf.TextWriterFormat<'T> -> 'T

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn
Raw view Test code New version

More information

Link:http://fssnip.net/7T7
Posted:7 years ago
Author:Luiz Monad
Tags: composition , custom operator , function composition