I tried F# under command line, it doesn't recognize function definition
> let ref f n=
- if(n<=2)then 1
- else f(n-1)+f(n-2)
- ;;
val ref : f:(int -> int) -> n:int -> int
> printf "%i" (f 10)
- ;;
printf "%i" (f 10)
-------------^
stdin(9,14): error FS0039: The value or constructor 'f' is not defined
Question: any error in my program? I copied and pasted the definition and usage of f into visual studio's F# project, it runs OK.
But Why command line fails?
You defined a function named
ref, but you're trying to call a function namedf. No such function was defined (though yourreffunction takes a parameter namedf), so you can't call it.You probably intended to define a recursive function
fusing thereckeyword (with a 'c'), rather than defining a function namedref.That's only possible if your VS project already contains a definition of a function named
f.