F# Program Structure is a Functional Programming language. In F#, functions work like data types. You can declare and use a function in the same way as any other variable.
In general, an F# application does not have any specific entry point. The compiler executes all top-level statements in the file from top to bottom.
However, to follow the procedural programming style, many applications keep a single top-level statement that calls the main loop.
The following code shows a simple F# program −
open System (* This is a multi-line comment *) // This is a single-line comment let sign num = if num > 0 then "positive" elif num < 0 then "negative" else "zero" let main() = Console.WriteLine("sign 5: {0}", (sign 5)) main()
When you compile and execute the program, it yields the following output −
sign 5: positive
Please note that −
- An F# code file might begin with a number of open statements that is used to import namespaces.
- The body of the files includes other functions that implement the business logic of the application.
- The main loop contains the top executable statements.
Next Topic – Click Here
Pingback: F# - Environment Setup - Adglob Infosystem Pvt Ltd
Looking forward to reading more. Great post. Really Cool.