kopia lustrzana https://github.com/backface/turtlestitch
revert APL-scalar caching
rodzic
9ae63f4d01
commit
ef5e02c86d
|
@ -0,0 +1,44 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Snap stable! Build Your Own Blocks 6.0.0 - beta -</title>
|
||||
<link rel="shortcut icon" href="src/favicon.ico">
|
||||
<script src="src/morphic.js?version=2020-06-13"></script>
|
||||
<script src="src/symbols.js?version=2020-06-17"></script>
|
||||
<script src="src/widgets.js?version=2020-05-06"></script>
|
||||
<script src="src/blocks.js?version=2020-06-20"></script>
|
||||
<script src="src/threads_stable.js?version=2020-06-22"></script>
|
||||
<script src="src/objects.js?version=2020-06-20"></script>
|
||||
<script src="src/gui.js?version=2020-06-08"></script>
|
||||
<script src="src/paint.js?version=2020-05-17"></script>
|
||||
<script src="src/lists.js?version=2020-05-18"></script>
|
||||
<script src="src/byob.js?version=2020-06-08"></script>
|
||||
<script src="src/tables.js?version=2020-05-18"></script>
|
||||
<script src="src/sketch.js?version=2020-04-15"></script>
|
||||
<script src="src/video.js?version=2019-06-27"></script>
|
||||
<script src="src/maps.js?version=2020-03-25"></script>
|
||||
<script src="src/xml.js?version=2020-04-27"></script>
|
||||
<script src="src/store.js?version=2020-05-18"></script>
|
||||
<script src="src/locale.js?version=2020-06-08"></script>
|
||||
<script src="src/cloud.js?version=2020-05-17"></script>
|
||||
<script src="src/api.js?version=2020-04-27"></script>
|
||||
<script src="src/sha512.js?version=2019-06-27"></script>
|
||||
<script src="src/FileSaver.min.js?version=2019-06-27"></script>
|
||||
<script>
|
||||
var world;
|
||||
window.onload = function () {
|
||||
world = new WorldMorph(document.getElementById('world'));
|
||||
new IDE_Morph().openIn(world);
|
||||
loop();
|
||||
};
|
||||
function loop() {
|
||||
requestAnimationFrame(loop);
|
||||
world.doOneCycle();
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body style="margin: 0;">
|
||||
<canvas id="world" tabindex="1" style="position: absolute;"></canvas>
|
||||
</body>
|
||||
</html>
|
102
src/threads.js
102
src/threads.js
|
@ -3540,21 +3540,19 @@ Process.prototype.reportTypeOf = function (thing) {
|
|||
|
||||
// Process math primtives - hyper-dyadic
|
||||
|
||||
Process.prototype.hyperDyadic = function (baseOp, a, b, a_info, b_info) {
|
||||
Process.prototype.hyperDyadic = function (baseOp, a, b) {
|
||||
// enable dyadic operations to be performed on lists and tables
|
||||
var len, i, result;
|
||||
var len, a_info, b_info, i, result;
|
||||
if (this.enableHyperOps) {
|
||||
a_info = a_info || this.examine(a);
|
||||
b_info = b_info || this.examine(b);
|
||||
a_info = this.examine(a);
|
||||
b_info = this.examine(b);
|
||||
if (a_info.isScalar && b_info.isScalar &&
|
||||
(a_info.rank !== b_info.rank)) {
|
||||
// keep the shape of the higher rank
|
||||
return this.hyperZip(
|
||||
baseOp,
|
||||
a_info.rank > b_info.rank ? a : a_info.scalar,
|
||||
b_info.rank > a_info.rank ? b : b_info.scalar,
|
||||
a_info.rank > b_info.rank ? a_info : null,
|
||||
b_info.rank > a_info.rank ? b_info : null
|
||||
b_info.rank > a_info.rank ? b : b_info.scalar
|
||||
);
|
||||
}
|
||||
if (a_info.rank > 1) {
|
||||
|
@ -3562,22 +3560,10 @@ Process.prototype.hyperDyadic = function (baseOp, a, b, a_info, b_info) {
|
|||
if (a.length() !== b.length()) {
|
||||
// test for special cased scalars in single-item lists
|
||||
if (a_info.isScalar) {
|
||||
return this.hyperDyadic(
|
||||
baseOp,
|
||||
a_info.scalar,
|
||||
b,
|
||||
null,
|
||||
b_info
|
||||
);
|
||||
return this.hyperDyadic(baseOp, a_info.scalar, b);
|
||||
}
|
||||
if (b_info.isScalar) {
|
||||
return this.hyperDyadic(
|
||||
baseOp,
|
||||
a,
|
||||
b_info.scalar,
|
||||
a_info,
|
||||
null
|
||||
);
|
||||
return this.hyperDyadic(baseOp, a, b_info.scalar);
|
||||
}
|
||||
}
|
||||
// zip both arguments ignoring out-of-bounds indices
|
||||
|
@ -3591,71 +3577,35 @@ Process.prototype.hyperDyadic = function (baseOp, a, b, a_info, b_info) {
|
|||
return new List(result);
|
||||
}
|
||||
if (a_info.isScalar) {
|
||||
return this.hyperZip(
|
||||
baseOp,
|
||||
a_info.scalar,
|
||||
b,
|
||||
null,
|
||||
b_info
|
||||
);
|
||||
return this.hyperZip(baseOp, a_info.scalar, b);
|
||||
}
|
||||
return a.map(each => this.hyperDyadic(
|
||||
baseOp,
|
||||
each,
|
||||
b,
|
||||
null,
|
||||
b_info
|
||||
));
|
||||
return a.map(each => this.hyperDyadic(baseOp, each, b));
|
||||
}
|
||||
if (b_info.rank > 1) {
|
||||
if (b_info.isScalar) {
|
||||
return this.hyperZip(
|
||||
baseOp,
|
||||
a,
|
||||
b_info.scalar,
|
||||
a_info,
|
||||
null
|
||||
);
|
||||
return this.hyperZip(baseOp, a, b_info.scalar);
|
||||
}
|
||||
return b.map(each => this.hyperDyadic(
|
||||
baseOp,
|
||||
a,
|
||||
each,
|
||||
a_info,
|
||||
null
|
||||
));
|
||||
return b.map(each => this.hyperDyadic(baseOp, a, each));
|
||||
}
|
||||
return this.hyperZip(baseOp, a, b, a_info, b_info);
|
||||
return this.hyperZip(baseOp, a, b);
|
||||
}
|
||||
return baseOp(a, b);
|
||||
};
|
||||
|
||||
Process.prototype.hyperZip = function (baseOp, a, b, a_info, b_info) {
|
||||
Process.prototype.hyperZip = function (baseOp, a, b) {
|
||||
// enable dyadic operations to be performed on lists and tables
|
||||
var len, i, result;
|
||||
a_info = a_info || this.examine(a);
|
||||
b_info = b_info || this.examine(b);
|
||||
var len, i, result,
|
||||
a_info = this.examine(a),
|
||||
b_info = this.examine(b);
|
||||
if (a instanceof List) {
|
||||
if (b instanceof List) {
|
||||
if (a.length() !== b.length()) {
|
||||
// test for special cased scalars in single-item lists
|
||||
if (a_info.isScalar) {
|
||||
return this.hyperZip(
|
||||
baseOp,
|
||||
a_info.scalar,
|
||||
b,
|
||||
null,
|
||||
b_info
|
||||
);
|
||||
return this.hyperZip(baseOp, a_info.scalar, b);
|
||||
}
|
||||
if (b_info.isScalar) {
|
||||
return this.hyperZip(
|
||||
baseOp,
|
||||
a,
|
||||
b_info.scalar,
|
||||
a_info,
|
||||
null
|
||||
);
|
||||
return this.hyperZip(baseOp, a, b_info.scalar);
|
||||
}
|
||||
}
|
||||
// zip both arguments ignoring out-of-bounds indices
|
||||
|
@ -3668,22 +3618,10 @@ Process.prototype.hyperZip = function (baseOp, a, b, a_info, b_info) {
|
|||
}
|
||||
return new List(result);
|
||||
}
|
||||
return a.map(each => this.hyperZip(
|
||||
baseOp,
|
||||
each,
|
||||
b,
|
||||
null,
|
||||
b_info
|
||||
));
|
||||
return a.map(each => this.hyperZip(baseOp, each, b));
|
||||
}
|
||||
if (b instanceof List) {
|
||||
return b.map(each => this.hyperZip(
|
||||
baseOp,
|
||||
a,
|
||||
each,
|
||||
a_info,
|
||||
null
|
||||
));
|
||||
return b.map(each => this.hyperZip(baseOp, a, each));
|
||||
}
|
||||
return baseOp(a, b);
|
||||
};
|
||||
|
|
Plik diff jest za duży
Load Diff
Ładowanie…
Reference in New Issue