There and Back Again
-
Upload
mike-harris -
Category
Technology
-
view
516 -
download
0
Transcript of There and Back Again
Travel Log• Equipment
• Higher Order Functions
• Variadic Functions with Splat / Apply
• Destructuring
• Map Structure
— J.R.R. Tolkien, The Lord of the Rings
“It's a dangerous business, Frodo, going out your door. You step onto the road, and if you
don't keep your feet, there's no knowing where you might be swept off to.”
Travel Log• Equipment
• Higher Order Functions
• Variadic Functions with Splat / Apply
• Destructuring
• Map Structure
var should = require('should'); var companySize = function() {return 15;}; companySize().should.equal(15);
JS
Travel Log• Equipment
• Higher Order Functions
• Variadic Functions with Splat / Apply
• Destructuring
• Map Structure
— Alan J. Perlis, Epigrams on Programming, #5
“If a program manipulates a large amount of data, it does so in a small number of ways.”
let dwarves = [{name: "Ori", gender: "Male"}, {name: "Dori", gender: "Male"}, {name: "Nori", gender: “Male”}];_.pluck(dwarves, 'name') .should.eql(['Ori', 'Dori', 'Nori'])
ES 6
(def dwarves [{:name "Ori" :gender “Male"} {:name "Dori" :gender "Male"} {:name "Nori" :gender “Male"}])
(is (= ["Ori" "Dori" "Nori"] (map :name dwarves)))
Travel Log• Equipment
• Higher Order Functions
• Variadic Functions with Splat / Apply
• Destructuring
• Map Structure
— J.R.R. Tolkien, The Hobbit
“‘Go back?’ he thought. ‘No good at all! Go sideways? Impossible! Go forward? Only thing
to do! On we go!’”
function summer() { return _.reduce( Array.prototype.slice.call( arguments, summer.length), function(m, x) { return m + x; }, 0);};summer( 1, 2, 3, 4, 5, 6).should.equal(21);
let summer = (...values) => _.reduce( values, (m, x) => m + x, 0); summer( 1, 2, 3, 4, 5, 6).should.equal(21);
ES 6
Travel Log• Equipment
• Higher Order Functions
• Variadic Functions with Splat / Apply
• Destructuring
• Map Structure
let [a=0, ,c, ,e=99] = [1, 2]; a.should.equal(1);should(c).be.equal(undefined);e.should.equal(99);
ES 6
let bilbo = { name: ‘Bilbo', age: 50, family: ['Baggins', 'Took'], pastTime: ['writing']}; let {name, family:parents} = bilbo;
ES 6
hobbies(bilbo).should .equal('Bilbo enjoys writing’); hobbies( {name: ‘Gollum', something: ‘else’ pastTime:[‘precious!']}) .should.equal( 'Gollum enjoys precious!');
ES 6
(defn hobbies [{ name :name hobbies :past-time}] (str name " enjoys " (clojure.string/join ", " hobbies)))
(is (= "Bilbo enjoys writing" (hobbies bilbo)))(is (= "Gollum enjoys precious!" (hobbies {:name “Gollum" :something “else” :past-time ["precious!"]})))
Travel Log• Equipment
• Higher Order Functions
• Variadic Functions with Splat / Apply
• Destructuring
• Map Structure
— Alan J. Perlis, Epigrams on Programming, #9
“It is better to have 100 functions operate on one data structure than 10 functions on 10 data
structures.”
_.pick(bilbo, 'name') .should.eql({name: ‘Bilbo'});_.pick(bilbo, ['name', 'family']) .should.eql( {name: 'Bilbo', family: ['Baggins', ‘Took']}); _.pick(bilbo, ‘none').should.eql({});
_.get(bilbo, 'name') .should.equal(‘Bilbo');_.get(bilbo, 'none', 'not found') .should.equal('not found’);should(_.get(bilbo, 'none')) .equal(undefined);
(is (= nil (get bilbo :none))) (is (= :not-found (get bilbo :none :not-found))) (is (= nil (bilbo :none))) (is (= nil (:none bilbo)))
Travel Log• Equipment
• Higher Order Functions
• Variadic Functions with Splat / Apply
• Destructuring
• Map Structure
— J.R.R. Tolkien, The Hobbit
“May the wind under your wings bear you where the sun sails and the moon walks.”
Bibliography(conference session)
• “Simple Made Easy” by Rich Hickey at Strange Loop 2011 http://www.infoq.com/presentations/Simple-Made-Easy
• “Coder Decoder: Functional Programming Lingo Explained, with Pictures” by Katie Miller at Strange Loop 2014 https://www.youtube.com/watch?v=uwrCQmpZ8Ts
• “Pattern Matching in Clojure” by Sean Johnson at Clojure/West 2015 https://www.youtube.com/watch?v=n7aE6k8o_BU
Bibliography(egghead.io videos)
• “Asynchronous Programming: The End of Loop” by Jafar Husain https://egghead.io/series/mastering-asynchronous-programming-the-end-of-the-loop
• “Introduction to Lodash” by John Lindquist https://egghead.io/lessons/core-javascript-introduction-to-lodash
• “Lodash: Refactoring Simple For Loops” by John Lindquist https://egghead.io/lessons/javascript-lodash-refactoring-simple-for-loops
• “ECMAscript6” by John Lindquist https://egghead.io/technologies/es6
Bibliography(Clojure books)
• “The Joy of Clojure” by Michael Fogus and Chris Houser
• “Programming Clojure” by Stuart Halloway and Aaron Bedra
• “Clojure Programming” by Chas Emerick, Brian Carper, and Christophe Grand
Bibliography(Functional JavaScript books)
• “Functional JavaScript: Introducing Functional Programming with Underscore.js” by Michael Fogus
• “JavaScript Allongé” by Reginald Braithwaite https://leanpub.com/javascript-allonge
Image Sources• The Hobbit book covers from http://commons.wikimedia.org/wiki/File:HMCoSecondEdHobbits.jpg
• Socrates take by Eric Gaba from http://en.wikipedia.org/wiki/File:Socrates_Louvre.jpg
• The Divided Line created by Neal Burton from http://outre-monde.com/2010/09/25/platonic-myths-the-sun-line-and-cave/
• The Hobbit images* are by Mikhail Belomlinsky from http://viola.bz/the-first-illustrator-of-the-hobbit/
• Babel from https://github.com/babel/babel
• Lodash from https://github.com/lodash/lodash
• Clojure from http://clojure.org/
• The Hobbit image (wolves)* by Tove Jansson from http://www.tolkien.com.pl/hobbit/collection/hobbit-swedish-1962.php
• Me taken by Kelsey Harris at Strange Loop 2014