Introduction to FSharp

valdisiljuconoks 309 views 31 slides Jun 04, 2012
Slide 1
Slide 1 of 31
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31

About This Presentation

No description available for this slideshow.


Slide Content

www.dotnet.lv

Valdis Iljuconoks Technical Fellow, Software Architect Microsoft MVP Geta AS, Viiar Consulting [email protected] http://dotnet.lv/blogs/vi @ tech_fellow

F#

what is it?

x = x + 1

First official functional programming language on .Net

why?

do more with less see where C# and VB.NET are headed learn new language every year

functional object-oriented imperative

Theorem proving ISWIM (1966) ML CAML OCAML F#

‘let’ binding

let a = 2

let a = 2 int a = 2 ≠ // F# // C#

let a = 2 static int a() { return 2; } // F# // C#

Immutable by default let a = 2 let a = 3 error: FS0037 Duplicate definition of value ‘a’

Strong Static Weak Dynamic

functions

let sqr x = x * x > val sqr : int -> int sqr 5 > val it: int = 25 parameter signature result data type

demo sum of sqr of t

high order functions A higher-order function is a function that takes another function as a parameter, or a function that returns another function as a value, or a function which does both .

let sqr x : float = x * x let mply a b : float = a * b let mplyPI a = mply a 3.14159 let cylinderVolume radius length = mplyPI length * sqr radius

demo function pipelining (|>)

demo function composition (>>)

discriminated unions

type NullableInt = | Value of int | Nothing of unit match x with | Value -> ... | Nothing -> ...

interoperability

demo .Net interoperability

First official functional programming language on .Net

?

Valdis Iljuconoks Technical Fellow, Software Architect Microsoft MVP Geta AS, Viiar Consulting [email protected] http://dotnet.lv/blogs/vi @ tech_fellow

www.dotnet.lv
Tags