0
FunctionalProgramming  {   Introduction to F#
   Oleksiy Tereshchenko       Principal consultant at Neudesic       10 years experience in Custom Application        D...
 Introduction to F#    F# fundamentals    Demo   & QuestionsAgenda
   Functional programming is a style of        programming that emphasizes the evaluation        of expressions, rather t...
   LISP - by John McCarthy in 1958    (based on the lambda calculus theory)       ML - by Robin Milner in 1970s    (noti...
   LINQ        SQL        XAML        XSLTModern declarativetechnologies
   Business Logic Layer of Enterprise SystemsBest fit for functionalprogramming
   Makes you and your team productiveKey reason for coding infunctional Style
   Express Abstraction   (hide how code executed and specify what needs to be         achieved)        Reuse of patterns...
   Functional Programming             Function Values             Function Composition             Immutability       ...
F# Fundamentals
let number = 1    let Number : int = 1 (F# is case sensitive)    let number = 1 (will fail compilation, since = is binding...
let main (argument) =            printfn “Hello, World %s ” argument            0    let square x = x * x    let rec facto...
let isOdd x = (x % 2 = 1)    let describeNumber x =            match isOdd x with            | true -> printfn “x is odd” ...
let x = Lazy<int>.Create(fun () -> printfn    "Evaluating x…"; 10)    let y = lazy (printfn "Evaluating y…"; x.Value +    ...
let sequenceOfNumbers = seq {1 .. 5}    sequenceOfNumbers |> Seq.iter (printfn "%d")Sequences
while            let mutable i = 0                    while i < 5 do                      i <- i + 1                      ...
try      try                failwithf "Error!"      with                | :? NotSupportedException ->    reraise()        ...
Demo
Upcoming SlideShare
Loading in...5
×

Functional Programming Fundamentals

1,243

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,243
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
17
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Functional Programming Fundamentals"

  1. 1. FunctionalProgramming { Introduction to F#
  2. 2.  Oleksiy Tereshchenko  Principal consultant at Neudesic  10 years experience in Custom Application Development and Connected SystemsAbout Presenter
  3. 3.  Introduction to F#  F# fundamentals  Demo & QuestionsAgenda
  4. 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. 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
  6. 6.  LINQ  SQL  XAML  XSLTModern declarativetechnologies
  7. 7.  Business Logic Layer of Enterprise SystemsBest fit for functionalprogramming
  8. 8.  Makes you and your team productiveKey reason for coding infunctional Style
  9. 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 testingF# designed to solveproblems
  10. 10.  Functional Programming  Function Values  Function Composition  Immutability  Recursive Functions  Type Inference  Lazy Evaluation  Tail Recursion  Sequences  Imperative Programming  Object-Oriented Programming  Asynchronous Workflows  Parallel ProgramingF# offers
  11. 11. F# Fundamentals
  12. 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. 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. 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. 15. let x = Lazy<int>.Create(fun () -> printfn "Evaluating x…"; 10) let y = lazy (printfn "Evaluating y…"; x.Value + x.Value);; y.ValueLazy evaluation
  16. 16. let sequenceOfNumbers = seq {1 .. 5} sequenceOfNumbers |> Seq.iter (printfn "%d")Sequences
  17. 17. while let mutable i = 0 while i < 5 do i <- i + 1 printf “i = %d” i;; for i = 1 to 5 do printf “i = %d” i;;Looping constructs
  18. 18. try try failwithf "Error!" with | :? NotSupportedException -> reraise() | ex -> printfn "Exception caught: %s" ex.Message finally printfn "finally block"Exception management
  19. 19. Demo
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×