Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to Functional Programming

Introduction to Functional Programming

First part of the first Fun(Lx) meetup, with a very brief overview of FP concepts, to provide a motivation for the Erlang and Scala talks.

João Duarte

March 07, 2014
Tweet

More Decks by João Duarte

Other Decks in Programming

Transcript

  1. Functional Programming 1936: λ-calculus - Alonzo Church 1960: LISP -

    John McCarthy 197*: ML - Robin Milner 1975: Scheme - Guy Steele 1985: Miranda - David Turner 1986: Erlang - Joe Armstrong 1990: Haskell - Simon Peyton Jones 2003: Scala - Martin Odersky 2005: F# - Microsoft 2007: Clojure - Rich Hickey 2012: Elixir - José Valim
  2. What is Functional Programming? Length = String INT zero? =

    Int Bool zero? . Length = Bool String
  3. What is Functional Programming? Length = String INT zero? =

    Int Bool empty? = zero? . Length = Bool String
  4. What is Functional Programming? Size = [ … ] INT

    zero? = Int Bool empty? = zero? . SIZE = Bool [ … ]
  5. What is Functional Programming? F = * INT zero? =

    Int Bool empty? (F) = zero? . F = Bool * F
  6. What is Functional Programming? def do_something(x, y) z = y.map

    {|i| i + x } expensive_computation(z) z end
  7. Functional Programming composition of functions as the building block of

    computation higher order functions focus on expressions vs statements referential transparency avoid mutable state lazy evaluation
  8. FP outside FP: Blending OO and FP No side effects

    Functional Stateful Imperative