Skip to content

Instantly share code, notes, and snippets.

View wdiasvargas's full-sized avatar

William Dias wdiasvargas

View GitHub Profile
/**
* 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);
@wdiasvargas
wdiasvargas / derivative.es6
Created June 21, 2017 05:03
derivative_memoizade
/**
* Created in 20/06/2017.
* Author: William Dias Vargas
* Github: @wdiasvargas
*/
"use strict";
import memoization from './memoization';
import derivative from './derivative';
import f from './fn';
import x from './x';
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))
const soma = (x, y) => x + y;
const calcular = (fn, x, y) => fn(x, y);
calcular(sum, 1, 2);
<!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>
function fatorial(n){
if(n == 0 )
return 1;
else{
return n * fatorial(n-1)
}
}
var str = "isso é uma string";
typeof(str);//'string'
var num = 1.74;
typeof(num);//'number'
var bol = true;
typeof(bol);//'boolean'
var str = "isso é uma string";
typeof(str);//'string'
var num = 1.74;
typeof(num);//'number'
var bol = true;
typeof(bol);//'boolean'
var und; //undefined