diff --git a/HISTORY.md b/HISTORY.md index 6220cec5..ea031b6a 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -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 diff --git a/src/objects.js b/src/objects.js index 1e3f0792..1429445f 100644 --- a/src/objects.js +++ b/src/objects.js @@ -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'], diff --git a/src/threads.js b/src/threads.js index f85d5e9e..236bf870 100644 --- a/src/threads.js +++ b/src/threads.js @@ -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)) {