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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<title>Euclidean distance calculations</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script> | |
<script src="./suite.js"></script> | |
</head> | |
<body> | |
<h1>Open the console to view the results</h1> |
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
<link rel="import" href="../core-scaffold/core-scaffold.html"> | |
<link rel="import" href="../core-header-panel/core-header-panel.html"> | |
<link rel="import" href="../core-menu/core-menu.html"> | |
<link rel="import" href="../core-item/core-item.html"> | |
<link rel="import" href="../core-icon-button/core-icon-button.html"> | |
<link rel="import" href="../core-toolbar/core-toolbar.html"> | |
<link rel="import" href="../core-menu/core-submenu.html"> | |
<link rel="import" href="../paper-input/paper-input.html"> | |
<link rel="import" href="../paper-button/paper-button.html"> |
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
var make = (function() { | |
if (typeof Array.isArray !== 'function') { | |
Array.isArray = function(a) { | |
return Object.prototype.toString.call(a) === "[object Array]"; | |
}; | |
} | |
function make(desc) { | |
if (!Array.isArray(desc)) { | |
return make.call(this, Array.prototype.slice.call(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
var a = NaN; | |
isNaN(a); // true because a has the value NaN | |
isNaN = function(x) { return x < 5; }; | |
isNaN(a); // false |
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
function approximatelyEqual(a, b, tolerance) { | |
return Math.abs(a - b) < tolerance; | |
} | |
approximatelyEqual(0.1 + 0.2, 0.3, 1e-12); // true |
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
RegExp.escape = (function() { | |
var special = /([.*+?^${}()|[\]\/\\])/g; | |
return function escape(s) { | |
return s.replace(special, '\\$1'); | |
}; | |
})(); |
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
Number.toGrayCode = function(n) { | |
if (n < 0) { | |
throw new RangeError("cannot convert negative numbers to gray code"); | |
} | |
return n ^ (n >>> 1); | |
}; | |
Number.fromGrayCode = function(gn) { | |
if (gn < 0) { | |
throw new RangeError("gray code numbers cannot be negative"); |
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
/* | |
Get an array of parameter names for a function. | |
Example: | |
js> function f(a, b, c) { return a + b * c; } | |
js> JSON.stringify(Function.parameters(f)); | |
["a","b","c"] | |
*/ | |
Function.parameters = function(f) { |
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
var Name = (function() { | |
function Name(prefix, first, middle, last, suffix, called) { | |
this.prefix = prefix || ""; | |
this.first = first || ""; | |
this.middle = middle || ""; | |
this.last = last || ""; | |
this.suffix = suffix || ""; | |
this.called = called || ""; | |
} |
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
function createArray(length) { | |
var a = new Array(Number(length) || 0); | |
if (arguments.length > 1) { | |
var args = Array.prototype.slice.call(arguments, 1); | |
for (var i = 0; i < length; i++) { | |
a[i] = createArray.apply(this, args); | |
} | |
} |
NewerOlder