2. Oleksiy Tereshchenko
Principal consultant at Neudesic
10 years experience in Custom Application
Development and Connected Systems
About Presenter
4. Functional programming is a style of
programming that emphasizes the evaluation
of expressions, rather than execution of
commands. The expressions in these languages
are formed using functions to combine basic
values. [Hutton ed. 2002]
Definition
5. LISP - by John McCarthy in 1958
(based on the lambda calculus theory)
ML - by Robin Milner in 1970s
(notion of types and types inference)
OCaml – in 1996
(pragmatic extension of ML, combination of object-oriented and functional
programming)
Haskell – in 1990s
(mathematical purity and elegance)
Erlang – in 1986
(simplified concurrent programming)
History
7. Business Logic Layer of Enterprise Systems
Best fit for functional
programming
8. Makes you and your team productive
Key reason for coding in
functional Style
9. Express Abstraction (hide how code executed and specify what needs to be
achieved)
Reuse of patterns
Reduce impact of requirements change
Deterministic flow
Asynchronies flow
Run concurrently on multiprocessor core
Simple testing
F# designed to solve
problems
12. let number = 1
let Number : int = 1 (F# is case sensitive)
let number = 1 (will fail compilation, since = is binding operation and not assignment )
Variables
13. let main (argument) =
printfn “Hello, World %s ” argument
0
let square x = x * x
let rec factorial x =
if x <= 1 then
1
else
x * factorial (x-1)
Functions
14. let isOdd x = (x % 2 = 1)
let describeNumber x =
match isOdd x with
| true -> printfn “x is odd”
| false -> printfn “x is event”;;
Pattern Matching
15. let x = Lazy<int>.Create(fun () -> printfn
"Evaluating x…"; 10)
let y = lazy (printfn "Evaluating y…"; x.Value +
x.Value);;
y.Value
Lazy evaluation