Reputation: 7092
i want to write the next function using pipeline:
A = 1/Sum[1-k](x^2)
so when i write:
//Adaptive step
let a_Adaptive x =
x
|> Array.map (fun x -> x ** 2.0)
|> Array.sum
|> (**) -1.0
f# interpretes (**)
as a multiline comment, but i want use it as a function.
Any suggestions?
Upvotes: 6
Views: 114
Reputation: 144166
You just need to add a space before the **
:
let a_Adaptive x =
x
|> Array.map (fun x -> x ** 2.0)
|> Array.sum
|> ( ** ) -1.0
From the F# specification:
To define other operators that begin with
*
, whitespace must follow the opening parenthesis; otherwise(*
is interpreted as the start of a comment:let ( *+* ) x y = (x + y)
Upvotes: 7