kopia lustrzana https://github.com/backface/turtlestitch
new "numbers" constructor primitive in List category
rodzic
b570f95a3e
commit
6ee0d05968
|
@ -25,7 +25,7 @@
|
|||
* new "get graphic effect" reporter
|
||||
* new "get pen attribute" reporter
|
||||
* new "write" command in pen category (used to be "label" in tools)
|
||||
* new "is empty", "map","keep", "combine" and "for each" primitives in list category
|
||||
* new "numbers", "is empty", "map","keep", "combine" and "for each" primitives in list category
|
||||
* new "for" loop and "if then else" reporter primitives in the Control category
|
||||
* added "neg", "lg" (log2) and "2^" selectors to monadic function reporter in Operators
|
||||
* added "^" reporter (power of) in the Operators category
|
||||
|
@ -73,6 +73,7 @@
|
|||
|
||||
### 2019-04-26
|
||||
* Lists, Threads, Objects: new "is empty" predicate primitive in List category
|
||||
* Threads, Objects: new "numbers" constructor primitive in List category
|
||||
|
||||
### 2019-04-26
|
||||
* updated Catalan translation (for new HOF prims)
|
||||
|
|
|
@ -1280,6 +1280,14 @@ SpriteMorph.prototype.initBlocks = function () {
|
|||
defaults: [1, null, localize('thing')]
|
||||
},
|
||||
|
||||
// numbers - linked
|
||||
reportNumbers: {
|
||||
type: 'reporter',
|
||||
category: 'lists',
|
||||
spec: 'numbers from %n to %n',
|
||||
defaults: [1, 10]
|
||||
},
|
||||
|
||||
// HOFs
|
||||
reportMap: {
|
||||
type: 'reporter',
|
||||
|
@ -2429,6 +2437,7 @@ SpriteMorph.prototype.blockTemplates = function (category) {
|
|||
blocks.push('=');
|
||||
|
||||
blocks.push(block('reportNewList'));
|
||||
blocks.push(block('reportNumbers'));
|
||||
blocks.push('-');
|
||||
blocks.push(block('reportCONS'));
|
||||
blocks.push(block('reportListItem'));
|
||||
|
@ -2617,6 +2626,7 @@ SpriteMorph.prototype.freshPalette = function (category) {
|
|||
[
|
||||
'doDeclareVariables',
|
||||
'reportNewList',
|
||||
'reportNumbers',
|
||||
'reportCONS',
|
||||
'reportListItem',
|
||||
'reportCDR',
|
||||
|
@ -7985,6 +7995,7 @@ StageMorph.prototype.blockTemplates = function (category) {
|
|||
blocks.push(block('doDeclareVariables'));
|
||||
blocks.push('=');
|
||||
blocks.push(block('reportNewList'));
|
||||
blocks.push(block('reportNumbers'));
|
||||
blocks.push('-');
|
||||
blocks.push(block('reportCONS'));
|
||||
blocks.push(block('reportListItem'));
|
||||
|
|
|
@ -1802,6 +1802,37 @@ Process.prototype.doShowTable = function (list) {
|
|||
new TableDialogMorph(list).popUp(this.blockReceiver().world());
|
||||
};
|
||||
|
||||
// Process interpolated non-HOF list primitives
|
||||
|
||||
Process.prototype.reportNumbers = function (start, end) {
|
||||
// answer a new linked list containing an linearly ascending progression
|
||||
// of integers beginning at start to end.
|
||||
// this is interpolated so it can handle big ranges of numbers
|
||||
// without blocking the UI
|
||||
|
||||
var dta;
|
||||
this.assertType(start, 'number');
|
||||
this.assertType(end, 'number');
|
||||
if (this.context.aggregation === null) {
|
||||
this.context.aggregation = {
|
||||
target : new List(),
|
||||
end : null,
|
||||
idx : start
|
||||
};
|
||||
this.context.aggregation.target.isLinked = true;
|
||||
this.context.aggregation.end = this.context.aggregation.target;
|
||||
}
|
||||
dta = this.context.aggregation;
|
||||
if (dta.idx > end) {
|
||||
this.returnValueToParentContext(dta.target.cdr());
|
||||
return;
|
||||
}
|
||||
dta.end.rest = dta.target.cons(dta.idx);
|
||||
dta.end = dta.end.rest;
|
||||
dta.idx += 1;
|
||||
this.pushContext();
|
||||
};
|
||||
|
||||
// Process conditionals primitives
|
||||
|
||||
Process.prototype.doIf = function () {
|
||||
|
|
Ładowanie…
Reference in New Issue