Skip to content

Instantly share code, notes, and snippets.

View wdiasvargas's full-sized avatar

William Dias wdiasvargas

View GitHub Profile
npm i --save-dev babel-cli babel-preset-env nodemon && echo { "presets": ["env"] } > .babelrc
var str = "isso é uma string";
typeof(str);//'string'
var num = 1.74;
typeof(num);//'number'
var bol = true;
typeof(bol);//'boolean'
var und; //undefined
var str = "isso é uma string";
typeof(str);//'string'
var num = 1.74;
typeof(num);//'number'
var bol = true;
typeof(bol);//'boolean'
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
const soma = (x, y) => x + y;
const calcular = (fn, x, y) => fn(x, y);
calcular(sum, 1, 2);
npm install --save-dev babel-cli babel-preset-es2017 && echo '{ "presets": ["es2017"] }' > .babelrc && echo 'function a(b,) { console.log("hi"); }; a()' > index.js
//run ./node_modules/.bin/babel-node index.js
//params $babel$ $script.js$ --presets es2017
/**
* Created in 21/06/2017.
* Author: William Dias Vargas
* Github: @wdiasvargas
*/
'use strict';
import yCombFact from './y-combinator-factorial'
export default (number) => ((fn) => fn(fn, number))((f, n) => (n <= 1)? 1: n * f(f, (n - 1)))
console.info(yCombFact(5))
/**
* Created in 21/06/2017.
* Author: William Dias Vargas
* Github: @wdiasvargas
*/
'use strict';
//http://kestas.kuliukas.com/YCombinatorExplained/
() => (f) => f(f)((f) =>((x) => (f(f))(x))))
/**
* Created in 20/06/2017.
* Author: William Dias Vargas
* Github: @wdiasvargas
*/
"use strict";
export default (fn, cache = {}) => (x) => (x in cache) ? cache[x] : cache[x] = fn(x);
/**
* Created in 20/06/2017.
* Author: William Dias Vargas
* Github: @wdiasvargas
*/
"use strict";
export default (fn, cache = {}) => (x) => (x in cache) ? cache[x] : cache[x] = fn(x);