projects:fsharp_workshop
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
projects:fsharp_workshop [2015/03/13 23:35] – mkucia | projects:fsharp_workshop [2015/04/18 17:32] – mkucia | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== F# workshop ====== | ====== F# workshop ====== | ||
+ | {{: | ||
+ | ===== Prerequisites ===== | ||
+ | * https:// | ||
+ | <hidden ↘ alternatives> | ||
+ | * Try F# in browser: http:// | ||
+ | * Use Visual Studio https:// | ||
+ | * Get a full distribution: | ||
+ | </ | ||
+ | ===== Agenda ===== | ||
- | * f(x) = Hello_Word | + | * hello(x) |
- | * On Testing and | + | * Type providers (strongly typed) |
+ | * Matching | ||
+ | * Options | ||
- | <wrap hi>highlighted</wrap> | + | ===== hello(x) ===== |
+ | <code fsharp> | ||
+ | let hello = printf "Hello World" | ||
+ | hello | ||
+ | </code> | ||
+ | |||
+ | F# (pronounced “F Sharp”) is | ||
<WRAP group> | <WRAP group> | ||
<WRAP half column box> | <WRAP half column box> | ||
- | Pros: | ||
* Open Source | * Open Source | ||
- | * Multi platform | + | * Multi platform |
- | * Modern, rising | + | * Modern, rising |
- | * Lazy evaluation | + | * Lazy evaluated |
* Reusable | * Reusable | ||
- | * Reduced code | + | * Concise (See [[http:// |
* Strongly typed | * Strongly typed | ||
+ | * Functional first | ||
+ | * Use functional to write easy to test and understand code | ||
+ | * Use imperative for performance and compatibility | ||
+ | * Use objective for organization and encapsulation | ||
+ | * Compiled | ||
</ | </ | ||
<WRAP half column box> | <WRAP half column box> | ||
- | Cons: | + | |
- | | + | * Hard to optimize (Functional languages fundamentally don't model how your computer works) |
- | * requires | + | * Functional first (different thinking |
</ | </ | ||
</ | </ | ||
+ | programming language for writing simple code to solve complex problems. | ||
+ | |||
+ | <code fsharp> | ||
+ | let hello x = printfn "Hello %s" x | ||
+ | hello " | ||
+ | </ | ||
+ | |||
+ | Introducing pipeline operator: | ||
+ | <code fsharp> | ||
+ | let hello x = printfn "Hello %s" x | ||
+ | " | ||
+ | </ | ||
+ | |||
+ | <hidden pipeline operator definition> | ||
+ | How to define the operator? | ||
+ | <code fsharp> | ||
+ | let inline (|>) x f = f x | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | <code fsharp> | ||
+ | let square x = x * x | ||
+ | let subtract x y = x - y | ||
+ | </ | ||
+ | |||
+ | <code fsharp> | ||
+ | let ``complicated stuff`` x = | ||
+ | printfn " | ||
+ | </ | ||
+ | |||
+ | <code fsharp> | ||
+ | let ``another complicated stuff`` x = | ||
+ | x |> square |> subtract 5 |> printfn " | ||
+ | </ | ||
+ | |||
+ | <code fsharp> | ||
+ | let equation x = | ||
+ | x | ||
+ | |> (fun y -> y * y ) | ||
+ | |> (fun y z -> y - z ) 5 | ||
+ | |> printfn " | ||
+ | </ | ||
+ | |||
+ | Note that F# uses indentation to indicate block structure. Find out more [[http:// | ||
- | <hidden ↘ C# equivalent> | ||
+ | ===== References ===== | ||
+ | * http:// | ||
+ | * http:// | ||
+ | * http:// | ||
+ | * http:// | ||
+ | * http:// | ||
+ | * [[https:// | ||
+ | * https:// | ||
+ | * http:// | ||
+ | * http:// | ||
+ | * http:// | ||
+ | * [[https:// |
projects/fsharp_workshop.txt · Last modified: 2015/05/02 12:45 by mkucia