Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Functional Programming for Fun and Profit

609 views

Published on

Rather than continually instructing a computer on how to get the job done, wouldn't it be so much easier if we simply had to explain what we wanted, and have the computer fill in the blanks for us?

Functional programming gives us this ability through its focus and priority on functions, rather than variables and classes, which allows us to reduce coupling and complexity, giving us a more repeatable program.

In this talk I'll explain my journey to understand, appreciate and leverage the power given to me by functional programming.

See more at https://github.com/jamesottaway/decks

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Functional Programming for Fun and Profit

  1. 1. FUNCTIONAL PROGRAMMING function() { return [‘fun’,‘profit’]; } Monday, 28 October 13
  2. 2. James Ottaway @jms_ Monday, 28 October 13
  3. 3. elevator pitch Monday, 28 October 13
  4. 4. teaser examples Monday, 28 October 13
  5. 5. (take 25 (squares-of (integers))) Monday, 28 October 13
  6. 6. [‘1’,’2’,’3’,’4’].map(&:to_i).reduce(&:+) Monday, 28 October 13
  7. 7. [1,2,3,4,5].filter(function(i) { return i % 2 == 0; }); Monday, 28 October 13
  8. 8. history Monday, 28 October 13
  9. 9. lambda calculus Monday, 28 October 13
  10. 10. declarative programming Monday, 28 October 13
  11. 11. > how Monday, 28 October 13
  12. 12. nested paradigms Monday, 28 October 13
  13. 13. regex Monday, 28 October 13
  14. 14. reactive programming Monday, 28 October 13
  15. 15. domain specific languages Monday, 28 October 13
  16. 16. functional programming Monday, 28 October 13
  17. 17. languages Monday, 28 October 13
  18. 18. concepts Monday, 28 October 13
  19. 19. function() { } Monday, 28 October 13
  20. 20. closures function counter() { var x = 0; function increment(y) { x += y; console.log(x); } return increment; } Monday, 28 October 13
  21. 21. closures first_counter = counter(); second_counter = counter(); first_counter(1) first_counter(2) first_counter(3) second_counter(5) second_counter(5) second_counter(5) Monday, 28 October 13 // returns 1 // returns 3 // returns 6 // returns 5 // returns 10 // returns 15
  22. 22. no side effects Monday, 28 October 13
  23. 23. insanity Monday, 28 October 13
  24. 24. ONE = 1; add = lambda { |x, y| x + y } addOne = lambda { |x| add[x, ONE] } referential transparency Monday, 28 October 13
  25. 25. require 'date' opaque_millis = lambda { DateTime.now.strftime('%Q').to_i } transparent_millis = lambda { |datetime| datetime.strftime('%Q').to_i } referential transparency Monday, 28 October 13
  26. 26. memoisation Monday, 28 October 13
  27. 27. deforestation Monday, 28 October 13
  28. 28. state is inevitable Monday, 28 October 13
  29. 29. recursion Monday, 28 October 13
  30. 30. structure and interpretation of computer programs Monday, 28 October 13
  31. 31. examples Monday, 28 October 13
  32. 32. list comprehension Monday, 28 October 13
  33. 33. source = [1,2,3,4,5] destination = [] for i in 0..source.length-1 do destination << source[i]*2 end return destination Monday, 28 October 13
  34. 34. [1,2,3,4,5].map { |i| i * 2 } Monday, 28 October 13
  35. 35. numbers = [1,2,3,4,5] x = 0 for i in 1..numbers.length-1 do x += numbers[i] end return x Monday, 28 October 13
  36. 36. [1,2,3,4,5].reduce { |acc, x| acc + x } Monday, 28 October 13
  37. 37. [1,2,3,4,5].reduce(&:+) Monday, 28 October 13
  38. 38. mobile app frameworks Monday, 28 October 13
  39. 39. Monday, 28 October 13
  40. 40. programming with nothing Monday, 28 October 13
  41. 41. reactive extensions Monday, 28 October 13
  42. 42. github desktop clients Monday, 28 October 13
  43. 43. go forth and prosper! Monday, 28 October 13
  44. 44. thanks Monday, 28 October 13

×