Functional Concepts

698 views

Published on

Published in: Education
  • Be the first to comment

  • Be the first to like this

Functional Concepts

  1. 1. Theoretical Underpinnings Michal P´se (CTU in Prague) ıˇ Object Prgrmmng L. 3: Functional Concepts October 12, 2010 2 / 10
  2. 2. Lambda Calculus e→x variable e1 e2 application λx.e abstraction Michal P´se (CTU in Prague) ıˇ Object Prgrmmng L. 3: Functional Concepts October 12, 2010 3 / 10
  3. 3. Semantics of Lambda Calculus λxi .e ⇒ λxj .[xj /xi ]e iff xj is not free in e (α-conversion, renaming) Michal P´se (CTU in Prague) ıˇ Object Prgrmmng L. 3: Functional Concepts October 12, 2010 4 / 10
  4. 4. Semantics of Lambda Calculus λxi .e ⇒ λxj .[xj /xi ]e iff xj is not free in e (α-conversion, renaming) (λx.e1 )e2 ⇒ [e2 /x]e1 (β-conversion, application) Michal P´se (CTU in Prague) ıˇ Object Prgrmmng L. 3: Functional Concepts October 12, 2010 4 / 10
  5. 5. Semantics of Lambda Calculus λxi .e ⇒ λxj .[xj /xi ]e iff xj is not free in e (α-conversion, renaming) (λx.e1 )e2 ⇒ [e2 /x]e1 (β-conversion, application) λx.(e x) ⇒ e iff x is not free in e (η-conversion) Michal P´se (CTU in Prague) ıˇ Object Prgrmmng L. 3: Functional Concepts October 12, 2010 4 / 10
  6. 6. Computational Strength of Lambda Calculus Lambda calculus has the same strength as Turing machine. In particular, you can define functions that represent numbers, Michal P´se (CTU in Prague) ıˇ Object Prgrmmng L. 3: Functional Concepts October 12, 2010 5 / 10
  7. 7. Computational Strength of Lambda Calculus Lambda calculus has the same strength as Turing machine. In particular, you can define functions that represent numbers, booleans and conditions and Michal P´se (CTU in Prague) ıˇ Object Prgrmmng L. 3: Functional Concepts October 12, 2010 5 / 10
  8. 8. Computational Strength of Lambda Calculus Lambda calculus has the same strength as Turing machine. In particular, you can define functions that represent numbers, booleans and conditions and recursive computations. Michal P´se (CTU in Prague) ıˇ Object Prgrmmng L. 3: Functional Concepts October 12, 2010 5 / 10
  9. 9. Functional Languages Michal P´se (CTU in Prague) ıˇ Object Prgrmmng L. 3: Functional Concepts October 12, 2010 6 / 10
  10. 10. Basic Characteristics No statements, just functions. Michal P´se (CTU in Prague) ıˇ Object Prgrmmng L. 3: Functional Concepts October 12, 2010 7 / 10
  11. 11. Basic Characteristics No statements, just functions. Immutable variables. Michal P´se (CTU in Prague) ıˇ Object Prgrmmng L. 3: Functional Concepts October 12, 2010 7 / 10
  12. 12. Basic Characteristics No statements, just functions. Immutable variables. No implicit state. Michal P´se (CTU in Prague) ıˇ Object Prgrmmng L. 3: Functional Concepts October 12, 2010 7 / 10
  13. 13. Composability No side effects. Michal P´se (CTU in Prague) ıˇ Object Prgrmmng L. 3: Functional Concepts October 12, 2010 8 / 10
  14. 14. Composability No side effects. Higher-order functions. Michal P´se (CTU in Prague) ıˇ Object Prgrmmng L. 3: Functional Concepts October 12, 2010 8 / 10
  15. 15. Composability No side effects. Higher-order functions. Currying. Michal P´se (CTU in Prague) ıˇ Object Prgrmmng L. 3: Functional Concepts October 12, 2010 8 / 10
  16. 16. Composability No side effects. Higher-order functions. Currying. Pattern matching. Michal P´se (CTU in Prague) ıˇ Object Prgrmmng L. 3: Functional Concepts October 12, 2010 8 / 10
  17. 17. Evaluation Order Non-strict (lazy) evaluation, possibly infinite data structures. Michal P´se (CTU in Prague) ıˇ Object Prgrmmng L. 3: Functional Concepts October 12, 2010 9 / 10
  18. 18. Evaluation Order Non-strict (lazy) evaluation, possibly infinite data structures. Parallel execution. Michal P´se (CTU in Prague) ıˇ Object Prgrmmng L. 3: Functional Concepts October 12, 2010 9 / 10
  19. 19. Evaluation Order Non-strict (lazy) evaluation, possibly infinite data structures. Parallel execution. Memoization. Michal P´se (CTU in Prague) ıˇ Object Prgrmmng L. 3: Functional Concepts October 12, 2010 9 / 10
  20. 20. See Hudak, P. Conception, evolution, and application of functional programming languages. ACM Computing Surveys 21, 3 (September 1989), 359–411. http://doi.acm.org/10.1145/72551.72554 Michal P´se (CTU in Prague) ıˇ Object Prgrmmng L. 3: Functional Concepts October 12, 2010 10 / 10

×