Skip to content

Instantly share code, notes, and snippets.

View wdiasvargas's full-sized avatar

William Dias wdiasvargas

View GitHub Profile
var feira = "Fui no mercado comprar: caqui, limao, pera, morango, abacaxi.";
var comeco = feira.indexOf(':');
var final = feira.indexOf('.', comeco+1);
var lista = feira.substring(comeco+1, final);
console.log(lista)
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'
function fatorial(n){
if(n == 0 )
return 1;
else{
return n * fatorial(n-1)
}
}
<!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);
/**
* 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))
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
@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';