This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** pe | |
* @argument f: the multiple-argument function to turn into a partially-evaluatable | |
* @returns : A single-argument function that applies its argument as the first argument of f, and returns the partially-evaluated function | |
* @exemple: pe((a,b)=>a+b)(9)(1) === 10 | |
*/ | |
function pe(f, context, args) { | |
if(!args) args = []; | |
if (args.length === f.length) return f.apply(context, args); | |
return function partial (a) { | |
var args_copy = args.concat.apply(args, arguments); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* The bind() method creates a new function that, when called, | |
* has its this keyword set to the provided value, | |
* with a given sequence of arguments preceding any | |
* provided when the new function is called. | |
*/ | |
this.x = 9; // this refers to global "window" object here in the browser | |
var module = { | |
x: 81, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mode = (str) => { | |
return str | |
.split(' ') | |
.reduce((data, key) => { | |
let counter = data.map[key] + 1 || 1 | |
data.map[key] = counter | |
if (counter > data.counter) { | |
data.counter = counter | |
data.mode = key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const pascalTriangleRecursive = (n, arr) => { | |
if (!arr) arr = [[1]] // Create triangle | |
if (n < 2) return arr // Exit | |
const prevLine = arr[arr.length - 1] // Get previous line | |
const newLine = [1] // Create new line | |
// Populate new line | |
prevLine.forEach((item, index) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.run(function ($rootScope, $location, AuthenticationModel) { | |
// Register listener to watch route changes. | |
$rootScope.$on('$routeChangeStart', function (event, next, current) { | |
if (!AuthenticationModel.isSignedIn() && next.requireAuthentication === true) { | |
$location.path('/signin'); | |
} | |
}); | |
}); |