let sub (m:double[],n:double[]) : double[]=
[| for i = 0 to Array.length m -1 do m.[i]-n.[i] |]
Error 1 This value is not a function and cannot be applied E:\MyDocuments\Visual Studio 2010\Projects\curve intersection\newton\Module1.fs 27 21 newton
But, this is ok:
let a = [| "a"; "b"; "c"; "d"; "e"; "f" |]
for i = 0 to Array.length a - 1 do
System.Console.WriteLine(a.[i])
Spaces around a minus sign matter:
calls the function
fwith an argument of-1(unary minus). Whereasand
are subtraction.
The compiler error reflects that
parses as
as though it is expecting the first expression to return a function, which will then be applied to the value
-1. Since length actually returns anint, you get the error message that says that an integer is not a function and cannot be applied to the argument-1.