Type inference in F# Read more

Type inference in F#

I have recently been to a short F# presentation at HiQ in Arboga. One of the things that got mentioned was type inference. Both Visual Basic and C# have type inference in their current version, but F# takes this one step further. This approach will produce two integers in VB when Option Infer is set […]

Tuples Read more

Tuples

Tuples in F# is a list of objects with different types, and the tuple itself is strongly typed. You can imagine a simple class or a structure without having to declare the type. This code creates a tuple called myTuple that contains a string, and integer, another string and finally a boolean. let myTuple=(“A”, 10, […]

F# functions Read more

F# functions

Functions are declared using the let keyword, followed by a name, a parameter list and a definition. This creates a function that adds to values and returns the result (first line). The two middle lines calls the function. let myFunction x y = x + y let result1 = myFunction 10 20 let result2 = […]

Conditions and iterations in F# Read more

Conditions and iterations in F#

Conditions This code will first assign a value to a and b, and print the values out. Thereafter, it will assign a value to c, that depends on the value of a. The value will be 20. Finally, it will print out both a, b and c. let a=1 let b=2 printfn “%d %d” a […]

Using the framework from F# Read more

Using the framework from F#

Just by typing the open statement, you can use the .NET Framework, or any other referenced libraries. To access the Console type, just add the following line to your source code: open System This program uses the built-in library function printfn, and then the WriteLine function to write “Hello world” to the screen. printfn “Hello […]

F# and PhotoName Read more

F# and PhotoName

I have just decided to look in to F#, the new functional .NET language by Microsoft. It installs with Visual Studio 2010, and it can be installed for Visual Studio 9. I use Visual Studio 9 for my everyday work, so I installed it from here (click on the word MSI in the first paragraph […]