This is probably something simple, but I have a .fs file with a simple sample function.
let printHello = printfn "%A" "Hello"
I have set the search path to the .fs file using
>#I "PathToMyFSFile"
I have loaded my file using
>#load "Test.fs"
Which worked fine. Now I want to call the function which actually prints the hello to screen, but thats turning out to be too difficult
> Test.printHello;;
val it : unit = ()
Tried Test.printHello();; as well but doesn't work. How do I actually make it print "Hello" to screen?
your current
printHelloisn't actually a function. To make it a function you need to donoice the
(). Then everything should work.EDIT:
When the compiler sees your definition
it passes it as a simple data term. For example, consider this program:
This will print
"Hello"then"World".printHellojust has unit type, so does nothing. Compare it toHere
printHellois a function. In this case, the function is only executed when it is explicitly called, so this prints"World"then"Hello".