How to make this F # code more compact
1 answer
let a = fun x -> x |> f |> g
equivalent to
let a x = x |> f |> g
It sounds like you want to create two functions f
and g
to create a new function a
. You can use operator >>
to create functions. You can write:
let a = f >> g
If f
they g
are generic functions, they will not compile due to the limitations of F # values . In this case, you need to add type annotations:
let a<'a> : ('a -> 'a) = f >> g
+7
source to share