kopia lustrzana https://github.com/backface/turtlestitch
added "cross product" to "append" as dropdown, and "reverse" to "length"
rodzic
5cd2d58063
commit
2576ae12bd
|
@ -13,6 +13,7 @@
|
|||
* lists, objects, threads: new RESHAPE primitive
|
||||
* lists: added internal naive (recursive) version of CROSSPRODUCT
|
||||
* lists: added TRANSPOSE for higher dimensions, thanks, Brian!
|
||||
* objects, blocks, threads: added "cross product" to "append" as dropdown, and "reverse" to "length"
|
||||
|
||||
### 2021-02-06
|
||||
* simplified private list.range() method
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<script src="src/morphic.js?version=2021-01-30"></script>
|
||||
<script src="src/symbols.js?version=2020-10-07"></script>
|
||||
<script src="src/widgets.js?version=2021-01-05"></script>
|
||||
<script src="src/blocks.js?version=2021-02-07"></script>
|
||||
<script src="src/blocks.js?version=2021-02-08"></script>
|
||||
<script src="src/threads.js?version=2021-02-08"></script>
|
||||
<script src="src/objects.js?version=2021-02-08"></script>
|
||||
<script src="src/gui.js?version=2021-02-04"></script>
|
||||
|
|
|
@ -158,7 +158,7 @@ CustomCommandBlockMorph, SymbolMorph, ToggleButtonMorph, DialMorph*/
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.blocks = '2021-February-07';
|
||||
modules.blocks = '2021-February-08';
|
||||
|
||||
var SyntaxElementMorph;
|
||||
var BlockMorph;
|
||||
|
@ -471,12 +471,21 @@ SyntaxElementMorph.prototype.labelParts = {
|
|||
'dimensions' : ['dimensions'],
|
||||
'flatten' : ['flatten'],
|
||||
'transpose' : ['transpose'],
|
||||
'reverse' : ['reverse'],
|
||||
'~' : null,
|
||||
'lines' : ['lines'],
|
||||
'csv' : ['csv'],
|
||||
'json' : ['json']
|
||||
}
|
||||
},
|
||||
'%mlfunc': {
|
||||
type: 'input',
|
||||
tags: 'read-only static',
|
||||
menu: {
|
||||
'append' : ['append'],
|
||||
'cross product' : ['cross product']
|
||||
}
|
||||
},
|
||||
'%dim': {
|
||||
type: 'input',
|
||||
tags: 'numeric',
|
||||
|
|
|
@ -1385,8 +1385,13 @@ SpriteMorph.prototype.initBlocks = function () {
|
|||
spec: 'numbers from %n to %n',
|
||||
defaults: [1, 10]
|
||||
},
|
||||
|
||||
reportConcatenatedLists: {
|
||||
reportListCombination: {
|
||||
type: 'reporter',
|
||||
category: 'lists',
|
||||
spec: '%mlfunc %lists',
|
||||
defaults: [['append']]
|
||||
},
|
||||
reportConcatenatedLists: { // deprecated
|
||||
type: 'reporter',
|
||||
category: 'lists',
|
||||
spec: 'append %lists'
|
||||
|
@ -1601,6 +1606,11 @@ SpriteMorph.prototype.initBlockMigrations = function () {
|
|||
selector: 'reportListAttribute',
|
||||
inputs: [['length']],
|
||||
offset: 1
|
||||
},
|
||||
reportConcatenatedLists: {
|
||||
selector: 'reportListCombination',
|
||||
inputs: [['append']],
|
||||
offset: 1
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@ -2783,7 +2793,7 @@ SpriteMorph.prototype.blockTemplates = function (category) {
|
|||
blocks.push('-');
|
||||
blocks.push(block('doForEach'));
|
||||
blocks.push('-');
|
||||
blocks.push(block('reportConcatenatedLists'));
|
||||
blocks.push(block('reportListCombination'));
|
||||
blocks.push(block('reportReshape'));
|
||||
blocks.push('-');
|
||||
blocks.push(block('doAddToList'));
|
||||
|
@ -2960,7 +2970,7 @@ SpriteMorph.prototype.freshPalette = function (category) {
|
|||
'reportCDR',
|
||||
'reportListAttribute',
|
||||
'reportListIndex',
|
||||
'reportConcatenatedLists',
|
||||
'reportListCombination',
|
||||
'reportReshape',
|
||||
'reportListContainsItem',
|
||||
'reportListIsEmpty',
|
||||
|
@ -8944,7 +8954,7 @@ StageMorph.prototype.blockTemplates = function (category) {
|
|||
blocks.push('-');
|
||||
blocks.push(block('doForEach'));
|
||||
blocks.push('-');
|
||||
blocks.push(block('reportConcatenatedLists'));
|
||||
blocks.push(block('reportListCombination'));
|
||||
blocks.push(block('reportReshape'));
|
||||
blocks.push('-');
|
||||
blocks.push(block('doAddToList'));
|
||||
|
|
|
@ -1988,6 +1988,8 @@ Process.prototype.reportListAttribute = function (choice, list) {
|
|||
return list.ravel();
|
||||
case 'transpose':
|
||||
return list.transpose();
|
||||
case 'reverse':
|
||||
return list.reversed();
|
||||
case 'lines':
|
||||
if (list.canBeTXT()) {
|
||||
return list.asTXT();
|
||||
|
@ -2077,6 +2079,18 @@ Process.prototype.reportBasicNumbers = function (start, end) {
|
|||
return new List(result);
|
||||
};
|
||||
|
||||
Process.prototype.reportListCombination = function (choice, lists) {
|
||||
var option = this.inputOption(choice);
|
||||
switch (option) {
|
||||
case 'append':
|
||||
return this.reportConcatenatedLists(lists);
|
||||
case 'cross product':
|
||||
return this.reportCrossproduct(lists);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
Process.prototype.reportConcatenatedLists = function (lists) {
|
||||
var first, result, rows, row, rowIdx, cols, col;
|
||||
this.assertType(lists, 'list');
|
||||
|
|
Ładowanie…
Reference in New Issue