hyperdyadic less / great than or equals prims reachable via "relabel"

pull/95/head
jmoenig 2020-12-01 09:33:33 +01:00
rodzic ffd09d21e8
commit 1c6cafe9d2
3 zmienionych plików z 49 dodań i 18 usunięć

Wyświetl plik

@ -4,6 +4,7 @@
* **New Features:**
* hyperdyadic MIN and MAX primitives reachable via "relabel"
* hyperdyadic less / great than or equals primitives reachable via "relabel"
* **Notable Changes:**
* searching for blocks and keyboard entry now includes the contents of dropdown menus
* **Notable Fixes:**
@ -11,6 +12,7 @@
### 2020-12-01
* threads, objects: added hyperdyadic MIN and MAX primitives reachable via "relabel"
* threads, objects: added hyperdyadic less/greaterThanOrEquals prims
### 2020-11-30
* threads: keep internal linked-list organization intact for hyperblocks

Wyświetl plik

@ -1122,21 +1122,31 @@ SpriteMorph.prototype.initBlocks = function () {
spec: 'pick random %n to %n',
defaults: [1, 10]
},
reportLessThan: {
type: 'predicate',
category: 'operators',
spec: '%s < %s'
},
reportEquals: {
type: 'predicate',
category: 'operators',
spec: '%s = %s'
},
reportLessThan: {
type: 'predicate',
category: 'operators',
spec: '%s < %s'
},
reportLessThanOrEquals: {
type: 'predicate',
category: 'operators',
spec: '%s \u2264 %s'
},
reportGreaterThan: {
type: 'predicate',
category: 'operators',
spec: '%s > %s'
},
reportGreaterThanOrEquals: {
type: 'predicate',
category: 'operators',
spec: '%s \u2265 %s'
},
reportAnd: {
type: 'predicate',
category: 'operators',
@ -1654,9 +1664,12 @@ SpriteMorph.prototype.blockAlternatives = {
'reportQuotient', 'reportPower', 'reportModulus', 'reportMax'],
reportMax: ['reportSum', 'reportDifference', 'reportProduct',
'reportQuotient', 'reportPower', 'reportModulus', 'reportMin'],
reportLessThan: ['reportEquals', 'reportGreaterThan'],
reportEquals: ['reportLessThan', 'reportGreaterThan'],
reportGreaterThan: ['reportEquals', 'reportLessThan'],
reportLessThan: ['reportLessThanOrEquals', 'reportEquals',
'reportGreaterThan', 'reportGreaterThanOrEquals'],
reportEquals: ['reportLessThan', 'reportLessThanOrEquals',
'reportGreaterThan', 'reportGreaterThanOrEquals'],
reportGreaterThan: ['reportGreaterThanOrEquals', 'reportEquals',
'reportLessThan', 'reportLessThanOrEquals'],
reportAnd: ['reportOr'],
reportOr: ['reportAnd'],

Wyświetl plik

@ -3743,6 +3743,14 @@ Process.prototype.reportLessThan = function (a, b) {
return this.hyperDyadic(this.reportBasicLessThan, a, b);
};
Process.prototype.reportLessThanOrEquals = function (a, b) {
return this.hyperDyadic(
(a, b) => !this.reportBasicGreaterThan(a, b),
a,
b
);
};
Process.prototype.reportBasicLessThan = function (a, b) {
var x = +a,
y = +b;
@ -3753,20 +3761,18 @@ Process.prototype.reportBasicLessThan = function (a, b) {
return x < y;
};
Process.prototype.reportNot = function (bool) {
if (this.enableHyperOps) {
if (bool instanceof List) {
return bool.map(each => this.reportNot(each));
}
}
// this.assertType(bool, 'Boolean');
return !bool;
};
Process.prototype.reportGreaterThan = function (a, b) {
return this.hyperDyadic(this.reportBasicGreaterThan, a, b);
};
Process.prototype.reportGreaterThanOrEquals = function (a, b) {
return this.hyperDyadic(
(a, b) => !this.reportBasicLessThan(a, b),
a,
b
);
};
Process.prototype.reportBasicGreaterThan = function (a, b) {
var x = +a,
y = +b;
@ -3781,6 +3787,16 @@ Process.prototype.reportEquals = function (a, b) {
return snapEquals(a, b);
};
Process.prototype.reportNot = function (bool) {
if (this.enableHyperOps) {
if (bool instanceof List) {
return bool.map(each => this.reportNot(each));
}
}
// this.assertType(bool, 'Boolean');
return !bool;
};
Process.prototype.reportIsIdentical = function (a, b) {
var tag = 'idTag';
if (this.isImmutable(a) || this.isImmutable(b)) {