Upload
jamesottaway
View
365
Download
1
Tags:
Embed Size (px)
DESCRIPTION
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
Citation preview
FUNCTIONALPROGRAMMING
function() { return [‘fun’,‘profit’];}
Monday, 28 October 13
James Ottaway
@jms_
Monday, 28 October 13
elevator pitch
Monday, 28 October 13
teaser examples
Monday, 28 October 13
(take 25 (squares-of (integers)))
Monday, 28 October 13
[‘1’,’2’,’3’,’4’].map(&:to_i).reduce(&:+)
Monday, 28 October 13
[1,2,3,4,5].filter(function(i) { return i % 2 == 0;});
Monday, 28 October 13
history
Monday, 28 October 13
lambda calculus
Monday, 28 October 13
declarative programming
Monday, 28 October 13
> how
Monday, 28 October 13
nested paradigmsMonday, 28 October 13
regex
Monday, 28 October 13
reactive programming
Monday, 28 October 13
domain specific languages
Monday, 28 October 13
functional programming
Monday, 28 October 13
languages
Monday, 28 October 13
concepts
Monday, 28 October 13
function() { }
Monday, 28 October 13
function counter() { var x = 0;
function increment(y) { x += y; console.log(x); }
return increment;}
closures
Monday, 28 October 13
first_counter = counter();second_counter = counter();
first_counter(1) // returns 1first_counter(2) // returns 3first_counter(3) // returns 6
second_counter(5) // returns 5second_counter(5) // returns 10second_counter(5) // returns 15
closures
Monday, 28 October 13
no side effects
Monday, 28 October 13
insanity
Monday, 28 October 13
ONE = 1;
add = lambda { |x, y| x + y}
addOne = lambda { |x| add[x, ONE]}
referential transparency
Monday, 28 October 13
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
memoisation
Monday, 28 October 13
deforestationMonday, 28 October 13
state is inevitable
Monday, 28 October 13
recursion
Monday, 28 October 13
structure and interpretation of computer programs
Monday, 28 October 13
examples
Monday, 28 October 13
list comprehension
Monday, 28 October 13
source = [1,2,3,4,5]destination = []
for i in 0..source.length-1 do destination << source[i]*2end
return destination
Monday, 28 October 13
[1,2,3,4,5].map { |i| i * 2 }
Monday, 28 October 13
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
[1,2,3,4,5].reduce { |acc, x| acc + x }
Monday, 28 October 13
[1,2,3,4,5].reduce(&:+)
Monday, 28 October 13
mobile app frameworks
Monday, 28 October 13
Monday, 28 October 13
programming with nothing
Monday, 28 October 13
reactive extensions
Monday, 28 October 13
github desktop clients
Monday, 28 October 13
go forth and prosper!
Monday, 28 October 13
thanks
Monday, 28 October 13