projects:fsharp_workshop
This is an old revision of the document!
Table of Contents
F# workshop
Prerequisites
- https://www.linqpad.net/ or anything that can execute a REPL1)
Agenda
- hello(x)
- Type providers (strongly typed)
- Matching
- Options
hello(x)
let hello = printf "Hello World" hello
let hello x = printfn "Hello %s" x hello "world"
let hello x = printfn "Hello %s" x "World" |> hello
|>
is the pipeline operator
let square x = x * x let subtract x y = x - y
let ``complicated stuff`` x = printfn "%d" (add 5 (square x))
let ``another complicated stuff`` x = x |> square |> subtract 5 |> printfn "%d"
let equation x = x |> (fun y -> y * y ) |> (fun y z -> y - z ) 5 |> printfn "%d"
Why?
Pros:
- Open Source
- Multi platform (Mono, .NET core)
- Modern, rising popularity
- Lazy evaluation
- Reusable
- Reduced code (See signal-to-noise ratio)
- Strongly typed
Cons:
- Not suitable for real time (unpredictable performance)
- Functional languages fundamentally don't model how your computer works ⇒ harder to optimize.
- Different thinking process (you need to re-learn)
References
1)
Read, Evaluate, Print Loop
projects/fsharp_workshop.1429304614.txt.gz · Last modified: 2015/04/17 23:03 by mkucia