We are now going to see how to write and read in F#. To read and write into the console, we can use the following commands:
- To write: System.Console.Write("Welcome!")
- To read: System.Console.Read()
- To print: printfn "Hello"
Let's compare F# with C#:
F# |
C# |
The F# user is free from the obligation of defining types; for example: let square x = x* x The compiler can identify (integer * integer) or (float * float) when we pass a value.
|
The C# user is bound to provide a type: Public int square(int x){ return x = x*x ; }
|
F# has immutable data, and the value never changes; for example: let number = [3;2;1] let moreNumber = 4:: number In the preceding example, to add one ... |