_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q44300 | drawChart | train | function drawChart(chart) {
var streaming = chart.streaming;
var frameRate = chart.options.plugins.streaming.frameRate;
var frameDuration = 1000 / (Math.max(frameRate, 0) || 30);
var next = streaming.lastDrawn + frameDuration || 0;
var now = Date.now();
var lastMouseEvent = streaming.lastMouseEvent;
if (next <=... | javascript | {
"resource": ""
} |
q44301 | train | function (minimumInterval, callback) {
var timeout = null;
return function () {
var that = this, args = arguments;
if(timeout === null) {
timeout = setTimeout(function () {
timeout = null;
}, minimumInterval);
callback.apply(that, args);
... | javascript | {
"resource": ""
} | |
q44302 | blank | train | function blank(v) {
if (typeof v === 'undefined') return true;
if (v instanceof Array && v.length === 0) return true;
if (v === null) return true;
if (typeof v === 'string' && v === '') return true;
return false;
} | javascript | {
"resource": ""
} |
q44303 | Schema | train | function Schema(name, settings) {
var schema = this;
name = name ? name.toLowerCase() : '';
switch (name) {
case 'sqlite':
name = 'sqlite3';
break;
case 'mysqldb':
case 'mariadb':
name = 'mysql';
break;
case 'mongo':
... | javascript | {
"resource": ""
} |
q44304 | train | function(time) {
grunt.log.writeln(String(
'Completed in ' +
time.toFixed(3) +
's at ' +
(new Date()).toString()
).cyan + ' - ' + waiting);
} | javascript | {
"resource": ""
} | |
q44305 | TaskRun | train | function TaskRun(target) {
this.name = target.name || 0;
this.files = target.files || [];
this._getConfig = target._getConfig;
this.options = target.options;
this.startedAt = false;
this.spawned = null;
this.changedFiles = Object.create(null);
this.spawnTaskFailure = false;
this.live... | javascript | {
"resource": ""
} |
q44306 | AmazonMwsResource | train | function AmazonMwsResource(AmazonMws, urlData) {
this._AmazonMws = AmazonMws;
this._urlData = urlData || {};
this.basePath = utils.makeURLInterpolator(AmazonMws.getApiField('basePath'));
this.path = utils.makeURLInterpolator(this.path);
if (this.includeBasic) {
this.includeBasic.forEach(fu... | javascript | {
"resource": ""
} |
q44307 | amazonMwsMethod | train | function amazonMwsMethod(spec) {
var commandPath = typeof spec.path === 'function' ? spec.path
: utils.makeURLInterpolator(spec.path || '');
var requestMethod = (spec.method || 'GET').toUpperCase();
var urlParams = spec.urlParams || [];
var encode = spec.encode || function (data) {
return ... | javascript | {
"resource": ""
} |
q44308 | _Error | train | function _Error() {
this.populate.apply(this, arguments);
var stack = (new Error(this.message)).stack;
debug('stack ', stack);
} | javascript | {
"resource": ""
} |
q44309 | train | function (cb) {
if (AmazonMws.USER_AGENT_SERIALIZED) {
return cb(AmazonMws.USER_AGENT_SERIALIZED);
}
this.getClientUserAgentSeeded(AmazonMws.USER_AGENT, function (cua) {
AmazonMws.USER_AGENT_SERIALIZED = cua;
cb(AmazonMws.USER_AGENT_SERIALIZED);
});
... | javascript | {
"resource": ""
} | |
q44310 | train | function (seed, cb) {
exec('uname -a', function (err, uname) {
var userAgent = {};
for (var field in seed) {
userAgent[field] = encodeURIComponent(seed[field]);
}
// URI-encode in case there are unusual characters in the system's uname.
... | javascript | {
"resource": ""
} | |
q44311 | collectMessage | train | function collectMessage(message, processingQueue, cb) {
const threshold = message.getRetryThreshold();
const messageRetryThreshold = typeof threshold === 'number' ? threshold : dispatcher.getMessageRetryThreshold();
const delay = message.getRetryDelay();
const messageRetryDelay = typeof... | javascript | {
"resource": ""
} |
q44312 | isPaddedArgument | train | function isPaddedArgument (node) {
var parentArray = node.parent().arguments ? node.parent().arguments : node.parent().elements
var idx = parentArray.indexOf(node)
if (idx === 0) { // first arg
if (prePreChar === '(' && preChar === '(' && postChar === ')') { // already padded
... | javascript | {
"resource": ""
} |
q44313 | isArgumentToFunctionCall | train | function isArgumentToFunctionCall (node) {
return isCallExpression(node.parent()) &&
node.parent().arguments.length &&
node.parent().arguments.indexOf(node) !== -1
} | javascript | {
"resource": ""
} |
q44314 | isIIFECall | train | function isIIFECall (node) {
return node &&
isCallExpression(node) &&
node.callee &&
node.callee.type === 'FunctionExpression'
} | javascript | {
"resource": ""
} |
q44315 | isProbablyWebpackModule | train | function isProbablyWebpackModule (node) {
return isElementOfArray(node) &&
isArgumentToFunctionCall(node.parent()) &&
isIIFECall(node.parent().parent())
} | javascript | {
"resource": ""
} |
q44316 | arrayToMatrix | train | function arrayToMatrix (a) {
return { a: a[0], b: a[1], c: a[2], d: a[3], e: a[4], f: a[5] }
} | javascript | {
"resource": ""
} |
q44317 | tempRedirect | train | function tempRedirect(req, res) {
var params = {
Bucket: S3_BUCKET,
Key: checkTrailingSlash(getFileKeyDir(req)) + req.params[0]
};
var s3 = getS3();
s3.getSignedUrl('getObject', params, function(err, url) {
res.redirect(url);
});
} | javascript | {
"resource": ""
} |
q44318 | createQueryMetadata | train | function createQueryMetadata (pageSize, bookmark) {
const metadata = new _serviceProto.QueryMetadata();
metadata.setPageSize(pageSize);
metadata.setBookmark(bookmark);
return metadata.toBuffer();
} | javascript | {
"resource": ""
} |
q44319 | train | function (cwd = process.cwd()) {
const promise = new Promise((resolve, reject) => {
const _name = this.toString();
// eslint-disable-next-line no-console
console.log(`spawning:: ${_name}`);
const call = spawn(this.cmd, this.args, {env: process.env, shell: true, st... | javascript | {
"resource": ""
} | |
q44320 | parseCoordinates | train | function parseCoordinates(coord) {
if (Array.isArray(coord) && coord.length === 2) {
return {
lng: coord[0],
lat: coord[1],
};
}
if (coord instanceof Object && coord !== null) {
return {
lng: coord.lng || coord.lon,
lat: coord.lat,
... | javascript | {
"resource": ""
} |
q44321 | train | function (object) {
var listeners = this.listeners;
for (var i = 0, iMax = this.listeners.length; i < iMax; i++) {
var listener = listeners[i];
if (listener && listener.object == object) {
return i;
}
}
return -1;
} | javascript | {
"resource": ""
} | |
q44322 | train | function (object, event, properties) {
var index = this.indexOf(object);
var listener = this.listeners[index];
if (listener) {
var callbacks = listener.events[event];
if (callbacks) {
for (var i = 0, iMax = callbacks.length; i < iMax; i++) {
... | javascript | {
"resource": ""
} | |
q44323 | isLoaded | train | function isLoaded (url) {
if (urls[url] == true) {
return true;
}
var image = new Image();
image.src = url;
if (image.complete) {
return true;
}
return false;
} | javascript | {
"resource": ""
} |
q44324 | load | train | function load (url, callback, sendCallbackWhenAlreadyLoaded) {
if (sendCallbackWhenAlreadyLoaded == undefined) {
sendCallbackWhenAlreadyLoaded = true;
}
if (isLoaded(url)) {
if (sendCallbackWhenAlreadyLoaded) {
callback(url);
}
ret... | javascript | {
"resource": ""
} |
q44325 | loadAll | train | function loadAll (urls, callback, sendCallbackWhenAlreadyLoaded) {
// list all urls which are not yet loaded
var urlsLeft = [];
urls.forEach(function (url) {
if (!isLoaded(url)) {
urlsLeft.push(url);
}
});
if (urlsLeft.length) {
... | javascript | {
"resource": ""
} |
q44326 | filterImageUrls | train | function filterImageUrls (elem, urls) {
var child = elem.firstChild;
while (child) {
if (child.tagName == 'IMG') {
var url = child.src;
if (urls.indexOf(url) == -1) {
urls.push(url);
}
}
filterImageU... | javascript | {
"resource": ""
} |
q44327 | cloudCollide | train | function cloudCollide(tag, board, sw) {
sw >>= 5;
var sprite = tag.sprite,
w = tag.width >> 5,
lx = tag.x - (w << 4),
sx = lx & 0x7f,
msx = 32 - sx,
h = tag.y1 - tag.y0,
x = (tag.y + tag.y0) * sw + (lx >> 5),
last;
for (var j = 0; j < h; j++) {
l... | javascript | {
"resource": ""
} |
q44328 | train | function (properties, featureCollection, mergeKey) {
var features = featureCollection.features;
var featureIndex = L.GeometryUtils.indexFeatureCollection(features, mergeKey);
var property;
var mergeValue;
var newFeatureCollection = {
type: 'FeatureCollection',
features: []
};
for (var key in proper... | javascript | {
"resource": ""
} | |
q44329 | train | function (featureCollection, indexKey) {
var features = featureCollection.features;
var feature;
var properties;
var featureIndex = {};
var value;
for (var index = 0; index < features.length; ++index) {
feature = features[index];
properties = feature.properties;
value = properties[indexKey];
... | javascript | {
"resource": ""
} | |
q44330 | train | function (element, style) {
var styleString = '';
for (var key in style) {
styleString += key + ': ' + style[key] + ';';
}
element.setAttribute('style', styleString);
return element;
} | javascript | {
"resource": ""
} | |
q44331 | train | function (element, attr) {
for (var key in attr) {
element.setAttribute(key, attr[key]);
}
return element;
} | javascript | {
"resource": ""
} | |
q44332 | train | function (location, options, record) {
var marker;
if (location) {
if (options.numberOfSides >= 30 && !(options.innerRadius || (options.innerRadiusX && options.innerRadiusY))) {
marker = new L.CircleMarker(location, options);
}
else {
marker = new L.RegularPolygonMarker(location, options);
}
... | javascript | {
"resource": ""
} | |
q44333 | train | function (data) {
// Initialize framework linear functions for mapping earthquake data properties to Leaflet style properties
// Color scale - green to red using the basic HSLHueFunction
var magnitudeColorFunction = new L.HSLHueFunction(new L.Point(0,90), new L.Point(10,0), {outputSaturation: '100%', outputLuminosi... | javascript | {
"resource": ""
} | |
q44334 | train | function () {
if (lastLayer) {
map.removeLayer(lastLayer);
}
$.ajax({
//url: 'http://earthquake.usgs.gov/earthquakes/feed/geojsonp/all/day',
url: 'http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojsonp',
type: 'GET',
... | javascript | {
"resource": ""
} | |
q44335 | train | function () {
var selected = timeline.getSelection();
if (selected.length > 0) {
var row = selected[0].row;
var item = timeline.getItem(row);
var id = $(item.content).attr('data-id');
var layer = layers[id];
if (lastLayer && lastLayer.viewedImage) {
lastLayer.viewedImage.fire('click');
... | javascript | {
"resource": ""
} | |
q44336 | parseUrlsOption | train | async function parseUrlsOption (state, urls) {
if (!urls || urls.length === 0) {
// get URLs for all sections across all pages
const pages = await getDocPages(state)
return (await pages.reduce(toSectionUrls.bind(null, state), [])).map(normalizeUrl)
}
const normalizedUrls = urls.map(normalizeUrl)
co... | javascript | {
"resource": ""
} |
q44337 | replaceTimeNowDefault | train | function replaceTimeNowDefault (state) {
state.results.forEach(output => {
output.params.forEach(result => {
if (result.default === 'Time.now') {
result.default = '<current date/time>'
}
})
})
} | javascript | {
"resource": ""
} |
q44338 | _parseScenarios | train | function _parseScenarios(feature) {
feature.elements.forEach(scenario => {
scenario.passed = 0;
scenario.failed = 0;
scenario.notDefined = 0;
scenario.skipped = 0;
scenario.pending = 0;
scenario.ambiguous = 0;
scenario.duration = 0;
scenario.time = '00:00:00.000';
... | javascript | {
"resource": ""
} |
q44339 | _readTemplateFile | train | function _readTemplateFile(fileName) {
if (fileName) {
try {
fs.accessSync(fileName, fs.constants.R_OK);
return fs.readFileSync(fileName, 'utf-8');
} catch (err) {
return fs.readFileSync(path.join(__dirname, '..', 'templates', fileName), 'utf-8');
}
} else {
retur... | javascript | {
"resource": ""
} |
q44340 | _isBase64 | train | function _isBase64(string) {
const notBase64 = /[^A-Z0-9+\/=]/i;
const stringLength = string.length;
if (!stringLength || stringLength % 4 !== 0 || notBase64.test(string)) {
return false;
}
const firstPaddingChar = string.indexOf('=');
return firstPaddingChar === -1 ||
firstPaddin... | javascript | {
"resource": ""
} |
q44341 | _createFeaturesOverviewIndexPage | train | function _createFeaturesOverviewIndexPage(suite) {
const featuresOverviewIndex = path.resolve(reportPath, INDEX_HTML);
FEATURES_OVERVIEW_TEMPLATE = suite.customMetadata ?
FEATURES_OVERVIEW_CUSTOM_METADATA_TEMPLATE : FEATURES_OVERVIEW_TEMPLATE;
fs.writeFileSync(
featuresOverviewIndex,
_.t... | javascript | {
"resource": ""
} |
q44342 | _createFeatureIndexPages | train | function _createFeatureIndexPages(suite) {
// Set custom metadata overview for the feature
FEATURE_METADATA_OVERVIEW_TEMPLATE = suite.customMetadata ?
FEATURE_CUSTOM_METADATA_OVERVIEW_TEMPLATE : FEATURE_METADATA_OVERVIEW_TEMPLATE;
suite.features.forEach(feature => {
const featurePage = path.re... | javascript | {
"resource": ""
} |
q44343 | parseAndValidateArgs | train | function parseAndValidateArgs (options) {
// parse and validate args
var args = nopt({
'archs': [String],
'appx': String,
'phone': Boolean,
'win': Boolean,
'bundle': Boolean,
'packageCertificateKeyFile': String,
'packageThumbprint': String,
'publis... | javascript | {
"resource": ""
} |
q44344 | enterFullScreen | train | function enterFullScreen() {
if (Windows.UI.ViewManagement.ApplicationViewBoundsMode) { // else crash on 8.1
var view = Windows.UI.ViewManagement.ApplicationView.getForCurrentView();
view.setDesiredBoundsMode(Windows.UI.ViewManagement.ApplicationViewBoundsMode.useCoreWindow);
view.suppressSy... | javascript | {
"resource": ""
} |
q44345 | exitFullScreen | train | function exitFullScreen() {
if (Windows.UI.ViewManagement.ApplicationViewBoundsMode) { // else crash on 8.1
var view = Windows.UI.ViewManagement.ApplicationView.getForCurrentView();
view.setDesiredBoundsMode(Windows.UI.ViewManagement.ApplicationViewBoundsMode.useVisible);
view.suppressSystem... | javascript | {
"resource": ""
} |
q44346 | colorizeTitleBar | train | function colorizeTitleBar() {
var appView = Windows.UI.ViewManagement.ApplicationView.getForCurrentView();
if (isWin10UWP && !isBgColorTransparent) {
titleInitialBgColor = appView.titleBar.backgroundColor;
appView.titleBar.backgroundColor = titleBgColor;
appView.titleBar.buttonBackgroun... | javascript | {
"resource": ""
} |
q44347 | revertTitleBarColor | train | function revertTitleBarColor() {
var appView = Windows.UI.ViewManagement.ApplicationView.getForCurrentView();
if (isWin10UWP && !isBgColorTransparent) {
appView.titleBar.backgroundColor = titleInitialBgColor;
appView.titleBar.buttonBackgroundColor = titleInitialBgColor;
}
} | javascript | {
"resource": ""
} |
q44348 | hide | train | function hide() {
if (isVisible()) {
var hideFinishCb = function () {
WinJS.Utilities.addClass(splashElement, 'hidden');
splashElement.style.opacity = 1;
enableUserInteraction();
exitFullScreen();
}
// Color reversion before fading is over loo... | javascript | {
"resource": ""
} |
q44349 | activated | train | function activated(eventObject) {
// Retrieve splash screen object
splash = eventObject.detail.splashScreen;
// Retrieve the window coordinates of the splash screen image.
coordinates = splash.imageLocation;
// Register an event handler to be executed when the splash screen has been dismissed.
... | javascript | {
"resource": ""
} |
q44350 | addBOMSignature | train | function addBOMSignature (directory) {
shell.ls('-R', directory)
.map(function (file) {
return path.join(directory, file);
})
.forEach(addBOMToFile);
} | javascript | {
"resource": ""
} |
q44351 | addBOMToFile | train | function addBOMToFile (file) {
if (!file.match(/\.(js|htm|html|css|json)$/i)) {
return;
}
// skip if this is a folder
if (!fs.lstatSync(file).isFile()) {
return;
}
var content = fs.readFileSync(file);
if (content[0] !== 0xEF && content[1] !== 0xBE && content[2] !== 0xBB) {
... | javascript | {
"resource": ""
} |
q44352 | updateProjectAccordingTo | train | function updateProjectAccordingTo (projectConfig, locations) {
// Apply appxmanifest changes
[MANIFEST_WINDOWS, MANIFEST_WINDOWS10, MANIFEST_PHONE]
.forEach(function (manifestFile) {
updateManifestFile(projectConfig, path.join(locations.root, manifestFile));
});
if (process.plat... | javascript | {
"resource": ""
} |
q44353 | train | function (tag, elementToInstall, xml) {
var frameworkCustomPathElement = xml.find(xpath);
expect(frameworkCustomPathElement).not.toBe(null);
var frameworkCustomPath = frameworkCustomPathElement.text;
expect(frameworkCustomPath).not.toBe(null);
... | javascript | {
"resource": ""
} | |
q44354 | train | function (framework) {
var targetDir = framework.targetDir || '';
var dest = path.join(cordovaProjectWindowsPlatformDir, 'plugins', dummyPluginInfo.id, targetDir, path.basename(framework.src));
var copiedSuccessfully = fs.existsSync(path.resolve(dest));
ex... | javascript | {
"resource": ""
} | |
q44355 | sortCapabilities | train | function sortCapabilities (manifest) {
// removes namespace prefix (m3:Capability -> Capability)
// this is required since elementtree returns qualified name with namespace
function extractLocalName (tag) {
return tag.split(':').pop(); // takes last part of string after ':'
}
var capabilit... | javascript | {
"resource": ""
} |
q44356 | train | function (callbackId, isSuccess, status, args, keepCallback) {
try {
var callback = cordova.callbacks[callbackId];
if (callback) {
if (isSuccess && status === cordova.callbackStatus.OK) {
callback.success && callback.success.apply(null, args);
... | javascript | {
"resource": ""
} | |
q44357 | getPackageName | train | function getPackageName (platformPath) {
// Can reliably read from package.windows.appxmanifest even if targeting Windows 10
// because the function is only used for desktop deployment, which always has the same
// package name when uninstalling / reinstalling
try {
return Q.when(AppxManifest.ge... | javascript | {
"resource": ""
} |
q44358 | getInstalledVSVersions | train | function getInstalledVSVersions () {
// Query all keys with Install value equal to 1, then filter out
// those, which are not related to VS itself
return spawn('reg', ['query', 'HKLM\\SOFTWARE\\Microsoft\\DevDiv\\vs\\Servicing', '/s', '/v', 'Install', '/f', '1', '/d', '/e', '/reg:32'])
.fail(functio... | javascript | {
"resource": ""
} |
q44359 | getInstalledWindowsSdks | train | function getInstalledWindowsSdks () {
var installedSdks = [];
return spawn('reg', ['query', 'HKLM\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows', '/s', '/v', 'InstallationFolder', '/reg:32'])
.fail(function () { return ''; })
.then(function (output) {
var re = /\\Microsoft SDKs\\Wind... | javascript | {
"resource": ""
} |
q44360 | getInstalledPhoneSdks | train | function getInstalledPhoneSdks () {
var installedSdks = [];
return spawn('reg', ['query', 'HKLM\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows Phone\\v8.1', '/v', 'InstallationFolder', '/reg:32'])
.fail(function () { return ''; })
.then(function (output) {
var match = /\\Microsoft SDK... | javascript | {
"resource": ""
} |
q44361 | train | function (windowsTargetVersion, windowsPhoneTargetVersion) {
if (process.platform !== 'win32') {
// Build Universal windows apps available for windows platform only, so we reject on others platforms
return Q.reject('Cordova tooling for Windows requires Windows OS to build project');
}
retur... | javascript | {
"resource": ""
} | |
q44362 | getWillowProgDataPaths | train | function getWillowProgDataPaths () {
if (!process.env.systemdrive) {
// running on linux/osx?
return [];
}
var instancesRoot = path.join(process.env.systemdrive, 'ProgramData/Microsoft/VisualStudio/Packages/_Instances');
if (!shell.test('-d', instancesRoot)) {
// can't seem to fi... | javascript | {
"resource": ""
} |
q44363 | train | function(symbol, c) {
this.variable = variables(symbol)[0];
if(!symbol.isPoly()) throw core.exceptions.NerdamerTypeError('Polynomial Expected! Received '+core.Utils.text(symbol));
c = c || [];
if(!symbol.power.absEquals(1)) symbol = _.expand(symbol);
... | javascript | {
"resource": ""
} | |
q44364 | train | function(x) {
x = Number(x) || 0;
var l = this.coeffs.length;
for(var i=0; i<l; i++) {
if(this.coeffs[i] === undefined) { this.coeffs[i] = new Frac(x); }
}
return this;
} | javascript | {
"resource": ""
} | |
q44365 | train | function() {
var l = this.coeffs.length;
while(l--) {
var c = this.coeffs[l];
var equalsZero = c.equals(0);
if(c && equalsZero) {
if(l === 0) break;
this.coeffs.pop();
}
... | javascript | {
"resource": ""
} | |
q44366 | train | function(poly) {
var l = Math.max(this.coeffs.length, poly.coeffs.length);
for(var i=0; i<l; i++) {
var a = (this.coeffs[i] || new Frac(0)),
b = (poly.coeffs[i] || new Frac(0));
this.coeffs[i] = a.add(b);
}
return... | javascript | {
"resource": ""
} | |
q44367 | train | function() {
var l = this.coeffs.length;
for(var i=0; i<l; i++) {
var e = this.coeffs[i];
if(!e.equals(0)) return false;
}
return true;
} | javascript | {
"resource": ""
} | |
q44368 | train | function() {
var lc = this.lc(), l = this.coeffs.length;
for(var i=0; i<l; i++) this.coeffs[i] = this.coeffs[i].divide(lc);
return this;
} | javascript | {
"resource": ""
} | |
q44369 | train | function(poly) {
//get the maximum power of each
var mp1 = this.coeffs.length-1,
mp2 = poly.coeffs.length-1,
T;
//swap so we always have the greater power first
if(mp1 < mp2) {
return poly.gcd(this);
}
... | javascript | {
"resource": ""
} | |
q44370 | train | function() {
var new_array = [], l = this.coeffs.length;
for(var i=1; i<l; i++) new_array.push(this.coeffs[i].multiply(new Frac(i)));
this.coeffs = new_array;
return this;
} | javascript | {
"resource": ""
} | |
q44371 | train | function() {
var new_array = [0], l = this.coeffs.length;
for(var i=0; i<l; i++) {
var c = new Frac(i+1);
new_array[c] = this.coeffs[i].divide(c);
}
this.coeffs = new_array;
return this;
} | javascript | {
"resource": ""
} | |
q44372 | train | function(toPolynomial) {
//get the first nozero coefficient and returns its power
var fnz = function(a) {
for(var i=0; i<a.length; i++)
if(!a[i].equals(0)) return i;
},
ca = [];
for(var i=0; i<this.coe... | javascript | {
"resource": ""
} | |
q44373 | train | function(a) {
for(var i=0; i<a.length; i++)
if(!a[i].equals(0)) return i;
} | javascript | {
"resource": ""
} | |
q44374 | train | function() {
var a = this.clone(),
i = 1,
b = a.clone().diff(),
c = a.clone().gcd(b),
w = a.divide(c)[0];
var output = Polynomial.fromArray([new Frac(1)], a.variable);
while(!c.equalsNumber(1)) {
... | javascript | {
"resource": ""
} | |
q44375 | train | function() {
var l = this.coeffs.length,
variable = this.variable;
if(l === 0) return new core.Symbol(0);
var end = l -1, str = '';
for(var i=0; i<l; i++) {
//place the plus sign for all but the last one
var plus = ... | javascript | {
"resource": ""
} | |
q44376 | MVTerm | train | function MVTerm(coeff, terms, map) {
this.terms = terms || [];
this.coeff = coeff;
this.map = map; //careful! all maps are the same object
this.sum = new core.Frac(0);
this.image = undefined;
} | javascript | {
"resource": ""
} |
q44377 | train | function(symbol, factors) {
if(symbol.isConstant() || symbol.group === S) return symbol;
var poly = new Polynomial(symbol);
var sqfr = poly.squareFree();
var p = sqfr[2];
//if we found a square then the p entry in the array will be non... | javascript | {
"resource": ""
} | |
q44378 | train | function(symbol, factors) {
if(symbol.group !== PL) return symbol; //only PL need apply
var d = core.Utils.arrayMin(keys(symbol.symbols));
var retval = new Symbol(0);
var q = _.parse(symbol.value+'^'+d);
symbol.each(function(x) {
... | javascript | {
"resource": ""
} | |
q44379 | train | function(symbol, factors) {
if(symbol.isComposite()) {
var gcd = core.Math2.QGCD.apply(null, symbol.coeffs());
if(!gcd.equals(1)) {
symbol.each(function(x) {
if(x.isComposite()) {
... | javascript | {
"resource": ""
} | |
q44380 | train | function(c1, c2, n, p) {
var candidate = Polynomial.fit(c1, c2, n, base, p, v);
if(candidate && candidate.coeffs.length > 1) {
var t = poly.divide(candidate);
if(t[1].equalsNumber(0)) {
factors.add(c... | javascript | {
"resource": ""
} | |
q44381 | train | function(symbol, factors) {
if(symbol.group !== FN) {
var vars = variables(symbol).reverse();
for(var i=0; i<vars.length; i++) {
do {
if(vars[i] === symbol.value){
... | javascript | {
"resource": ""
} | |
q44382 | train | function(symbol, factors) {
try {
var remove_square = function(x) {
return core.Utils.block('POSITIVE_MULTIPLIERS', function() {
return Symbol.unwrapPARENS(math.sqrt(math.abs(x)));
}, true);
... | javascript | {
"resource": ""
} | |
q44383 | train | function(set) {
var l = set.length;
for(var i=0; i<l; i++) if(!__.isLinear(set[i])) return false;
return true;
} | javascript | {
"resource": ""
} | |
q44384 | train | function(symbol1, symbol2) {
var result, remainder, factored, den;
factored = core.Algebra.Factor.factor(symbol1.clone());
den = factored.getDenom();
if(!den.isConstant('all')) {
symbol1 = _.expand(Symbol.unwrapPARENS(_.multiply(factored, den.clone())... | javascript | {
"resource": ""
} | |
q44385 | train | function(arr) {
var symbol = new Symbol(0);
for(var i=0; i<arr.length; i++) {
var x = arr[i].toSymbol();
symbol = _.add(symbol, x);
}
return symbol;
} | javascript | {
"resource": ""
} | |
q44386 | train | function(term, any) {
var max = Math.max.apply(null, term.terms),
count = 0, idx;
if(!any) {
for(var i=0; i<term.terms.length; i++) {
if(term.terms[i].equals(max)) {
... | javascript | {
"resource": ""
} | |
q44387 | train | function(s, lookat) {
lookat = lookat || 0;
var det = s[lookat], l = s.length;
if(!det) return;
//eliminate the first term if it doesn't apply
var umax = get_unique_max(det);
for(var i=lookat... | javascript | {
"resource": ""
} | |
q44388 | train | function(symbol, v, raw) {
if(!core.Utils.isSymbol(v))
v = _.parse(v);
var stop = function(msg) {
msg = msg || 'Stopping';
throw new core.exceptions.ValueLimitExceededError(msg);
};
//if not CP then nothing to do
... | javascript | {
"resource": ""
} | |
q44389 | train | function(eqn) {
//If it's an equation then call its toLHS function instead
if(eqn instanceof Equation)
return eqn.toLHS();
var es = eqn.split('=');
if(es[1] === undefined) es[1] = '0';
var e1 = _.parse(es[0]), e2 = _.parse(es[1]);
return removeDenom(e1... | javascript | {
"resource": ""
} | |
q44390 | train | function(c, b, a, plus_or_min) {
var plus_or_minus = plus_or_min === '-' ? 'subtract': 'add';
var bsqmin4ac = _.subtract(_.pow(b.clone(), Symbol(2)), _.multiply(_.multiply(a.clone(), c.clone()),Symbol(4)))/*b^2 - 4ac*/;
var det = _.pow(bsqmin4ac, Symbol(0.5));
var retval = _.divid... | javascript | {
"resource": ""
} | |
q44391 | train | function(symbol, solve_for) {
var sols = [];
//see if we can solve the factors
var factors = core.Algebra.Factor.factor(symbol);
if(factors.group === CB) {
factors.each(function(x) {
x = Symbol.unwrapPARENS(x);
sols = sols.concat(solve(x... | javascript | {
"resource": ""
} | |
q44392 | train | function(point, f, fp) {
var maxiter = 200,
iter = 0;
//first try the point itself. If it's zero viola. We're done
var x0 = point, x;
do {
var fx0 = f(x0); //store the result of the function
//if the value is zero then we're done because 0 - (0... | javascript | {
"resource": ""
} | |
q44393 | train | function(symbol) {
var has_trig = symbol.hasTrig();
// we get all the points where a possible zero might exist
var points1 = get_points(symbol, 0.1);
var points2 = get_points(symbol, 0.05);
var points3 = get_points(symbol, 0.01);
var points ... | javascript | {
"resource": ""
} | |
q44394 | train | function(eq) {
var lhs = new Symbol(0),
rhs = new Symbol(0);
eq.each(function(x) {
if(x.contains(solve_for, true))
lhs = _.add(lhs, x.clone());
else
rhs = _.subtract(rhs, x.clone());
});
... | javascript | {
"resource": ""
} | |
q44395 | polydiff | train | function polydiff(symbol) {
if(symbol.value === d || symbol.contains(d, true)) {
symbol.multiplier = symbol.multiplier.multiply(symbol.power);
symbol.power = symbol.power.subtract(new Frac(1));
if(symbol.power.equals(0)) {
... | javascript | {
"resource": ""
} |
q44396 | train | function(x) {
var g = x.group;
if(g === FN) {
var fname = x.fname;
if(core.Utils.in_trig(fname) || core.Utils.in_htrig(fname))
parts[3].push(x);
else if(core.Utils.in_inver... | javascript | {
"resource": ""
} | |
q44397 | train | function(symbol) {
var p = symbol.power,
k = p/2, e;
if(symbol.fname === COS)
... | javascript | {
"resource": ""
} | |
q44398 | train | function(integral, vars, point) {
try {
return _.parse(integral, vars);
}
catch(e) {
//it failed for some reason so return the limit
return __.Limit.limit(integral, dx, point);
}
... | javascript | {
"resource": ""
} | |
q44399 | interpolate | train | function interpolate(contours, accuracy) {
return _.map(contours, function (contour) {
var resContour = [];
_.forEach(contour, function (point, idx) {
// Never skip first and last points
if (idx === 0 || idx === (contour.length - 1)) {
resContour.push(point);
return;
}
... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.