Skip to content

{ Tag Archives } F#

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 […]

Also tagged

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, […]

Also tagged

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 = […]

Also tagged

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 […]

Also tagged

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 […]

Also tagged

Things to know about F# before getting started and mutable variables

F# is a .NET enabled functional programming language that has features that you would expect such a language to have (lists, tuples, pattern matching and so on), as well as the features you would expect from a .NET language such as preemptive multitasking, dynamic linking and Unicode strings. The program starts from the top of […]

Also tagged

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 […]

Also tagged