kopia lustrzana https://github.com/backface/turtlestitch
enamed experimental "rotate" primitive into "transpose"
rodzic
dd616d38f3
commit
65e3e64d35
|
@ -16,6 +16,9 @@
|
|||
* German
|
||||
* Turkish
|
||||
|
||||
### 2021-01-30
|
||||
* threads, objects, lists: renamed experimental "rotate" primitive into "transpose"
|
||||
|
||||
### 2021-01-29
|
||||
* threads, objects: new experimental "rotate (list)" primitive relabelling option for "all but first"
|
||||
* threads, objects: removed previous experimental "column" and "width" primitives again
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
<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=2020-12-22"></script>
|
||||
<script src="src/threads.js?version=2021-01-29"></script>
|
||||
<script src="src/objects.js?version=2021-01-29"></script>
|
||||
<script src="src/threads.js?version=2021-01-30"></script>
|
||||
<script src="src/objects.js?version=2021-01-30"></script>
|
||||
<script src="src/gui.js?version=2021-01-21"></script>
|
||||
<script src="src/paint.js?version=2020-05-17"></script>
|
||||
<script src="src/lists.js?version=2021-01-29"></script>
|
||||
<script src="src/lists.js?version=2021-01-30"></script>
|
||||
<script src="src/byob.js?version=2020-12-22"></script>
|
||||
<script src="src/tables.js?version=2020-10-06"></script>
|
||||
<script src="src/sketch.js?version=2020-07-13"></script>
|
||||
|
|
14
src/lists.js
14
src/lists.js
|
@ -63,7 +63,7 @@ MorphicPreferences, TableDialogMorph, SpriteBubbleMorph, SpeechBubbleMorph,
|
|||
TableFrameMorph, TableMorph, Variable, isSnapObject, Costume, contains, detect,
|
||||
ZERO, WHITE*/
|
||||
|
||||
modules.lists = '2021-January-29';
|
||||
modules.lists = '2021-January-30';
|
||||
|
||||
var List;
|
||||
var ListWatcherMorph;
|
||||
|
@ -101,7 +101,7 @@ var ListWatcherMorph;
|
|||
|
||||
conversion:
|
||||
-----------
|
||||
rotated() - answer a 2D list with rows turned into columns
|
||||
transpose() - answer a 2D list with rows turned into columns
|
||||
asArray() - answer me as JavaScript array, convert to arrayed
|
||||
itemsArray() - answer a JavaScript array shallow copy of myself
|
||||
asText() - answer my elements (recursively) concatenated
|
||||
|
@ -376,10 +376,10 @@ List.prototype.version = function (startRow, rows, startCol, cols) {
|
|||
|
||||
// List conversion:
|
||||
|
||||
List.prototype.rotated = function () {
|
||||
List.prototype.transpose = function () {
|
||||
// answer a 2D list where each item has turned into a row,
|
||||
// convert orphaned items into lists,
|
||||
// fill ragged columns with orphaned values
|
||||
// convert atomic items into lists,
|
||||
// fill ragged columns with atomic values, if any, or empty cells
|
||||
var col, src, i, item,
|
||||
width = 1,
|
||||
len = this.length(),
|
||||
|
@ -391,12 +391,12 @@ List.prototype.rotated = function () {
|
|||
width = Math.max(width, item instanceof List ? item.length() : 0);
|
||||
}
|
||||
|
||||
// convert orphaned items into rows
|
||||
// convert atomic items into rows
|
||||
src = this.map(row =>
|
||||
row instanceof List ? row : new List(new Array(width).fill(row))
|
||||
);
|
||||
|
||||
// define the mapper funciton
|
||||
// define the mapper function
|
||||
col = (tab, c) => tab.map(row => row.at(c));
|
||||
|
||||
// create the transform
|
||||
|
|
|
@ -84,7 +84,7 @@ BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, BooleanSlotMorph,
|
|||
localize, TableMorph, TableFrameMorph, normalizeCanvas, VectorPaintEditorMorph,
|
||||
AlignmentMorph, Process, WorldMap, copyCanvas, useBlurredShadows*/
|
||||
|
||||
modules.objects = '2021-January-29';
|
||||
modules.objects = '2021-January-30';
|
||||
|
||||
var SpriteMorph;
|
||||
var StageMorph;
|
||||
|
@ -1323,10 +1323,10 @@ SpriteMorph.prototype.initBlocks = function () {
|
|||
category: 'lists',
|
||||
spec: 'all but first of %l'
|
||||
},
|
||||
reportTableRotated: {
|
||||
reportTranspose: {
|
||||
type: 'reporter',
|
||||
category: 'lists',
|
||||
spec: 'rotate %l'
|
||||
spec: 'transpose %l'
|
||||
},
|
||||
reportListLength: {
|
||||
type: 'reporter',
|
||||
|
@ -1575,6 +1575,10 @@ SpriteMorph.prototype.initBlockMigrations = function () {
|
|||
selector: 'doSetGlobalFlag',
|
||||
inputs: [['turbo mode']],
|
||||
offset: 1
|
||||
},
|
||||
reportTableRotated: {
|
||||
selector: 'reportTranspose',
|
||||
offset: 0
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@ -1716,9 +1720,9 @@ SpriteMorph.prototype.blockAlternatives = {
|
|||
doHideVar: ['doShowVar'],
|
||||
|
||||
// lists
|
||||
reportCDR: ['reportTableRotated', 'reportListLength'],
|
||||
reportTableRotated: ['reportCDR', 'reportListLength'],
|
||||
reportListLength: ['reportTableRotated', 'reportCDR'],
|
||||
reportCDR: ['reportTranspose', 'reportListLength'],
|
||||
reportTranspose: ['reportCDR', 'reportListLength'],
|
||||
reportListLength: ['reportTranspose', 'reportCDR'],
|
||||
|
||||
// HOFs
|
||||
reportMap: ['reportKeep', 'reportFindFirst'],
|
||||
|
|
|
@ -61,7 +61,7 @@ StageMorph, SpriteMorph, StagePrompterMorph, Note, modules, isString, copy, Map,
|
|||
isNil, WatcherMorph, List, ListWatcherMorph, alert, console, TableMorph, BLACK,
|
||||
TableFrameMorph, ColorSlotMorph, isSnapObject, newCanvas, Symbol, SVG_Costume*/
|
||||
|
||||
modules.threads = '2021-January-29';
|
||||
modules.threads = '2021-January-30';
|
||||
|
||||
var ThreadManager;
|
||||
var Process;
|
||||
|
@ -2008,11 +2008,9 @@ Process.prototype.reportItems = function (indices, list) {
|
|||
|
||||
// Process - experimental tabular list accessors
|
||||
|
||||
Process.prototype.reportTableRotated = function (list) {
|
||||
// experimental and probably controversial as a primitive,
|
||||
// because it's so nice and easy to write in Snap!
|
||||
Process.prototype.reportTranspose = function (list) {
|
||||
this.assertType(list, 'list');
|
||||
return list.rotated();
|
||||
return list.transpose();
|
||||
};
|
||||
|
||||
// Process - other basic list accessors
|
||||
|
|
Ładowanie…
Reference in New Issue