Pipeline supplier problem

I want to write the following function using the 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 # interprets (**) as a multi-line comment, but I want to use it as a function. Any suggestions?

+6
source share
1 answer

You just need to add a space before ** :

 let a_Adaptive x = x |> Array.map (fun x -> x ** 2.0) |> Array.sum |> ( ** ) -1.0 

From the F # specification:

To specify other operators starting with * , spaces must be followed by an opening bracket; otherwise (* interpreted as the beginning of the comment:

let (* + *) xy = (x + y)

+7
source

Source: https://habr.com/ru/post/954358/


All Articles