Search

1/22/2015

Functional Programming in Javascript === Garbage « Thomas Reynolds

Functional Programming in Javascript === Garbage « Thomas Reynolds

These can both be written as a reducer.
function map(f, list) {
  return reduce(function(val, sum) {
    sum.push(f(val));
    return sum;
  }, list, []);
}
The reducer takes a function which can update a value sum which starts at [] and is updated once for each item in the list. Okay, that was a long lead in. Here's how you could naively implement a reducer:
function reduce(f, list, sum) {
  if (list.length < 1) {
    return sum;
  } else {
    var val = list.shift();
    return reduce(f, list, f(val, list));
  }
}

Javascript in 2015 - YouTube

1. npm install -g jspm 2. cd ~/dev/jspm; jspm init 3. npm install -g live-server 4. live-server . 5. vim index.htm, add 6. vim ./lib/main.js, add import RedditApi from './Reddit-api' export default {} 7. vim ./lib/Reddit-api.js, add class RedditApi { load() { console.log('todo') } } export default new RedditApi() 8. jspm install npm:jsonp 9. jspm bundle --minify lib/main
tag: systemJS

1/21/2015

live-server

live-server

This is a little development server with live reload capability. Use it for hacking your HTML/JavaScript/CSS files, but not for deploying the final site. ex: PORT=12345 live-server .