hyperized new experimental "column" primitive

pull/95/head
jmoenig 2021-01-27 08:40:26 +01:00
rodzic 5482bf7474
commit b5e210e657
3 zmienionych plików z 16 dodań i 3 usunięć

Wyświetl plik

@ -17,6 +17,9 @@
* German
* Turkish
### 2021-01-27
* threads: hyperized new experimental "column" primitive
### 2021-01-26
* threads: handle single values as greyscale when constructing a costume from a pixel list
* threads, objects experimental "column _ of _" reporter relabelling option for "item _ of _"

Wyświetl plik

@ -9,7 +9,7 @@
<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-26"></script>
<script src="src/threads.js?version=2021-01-27"></script>
<script src="src/objects.js?version=2021-01-26"></script>
<script src="src/gui.js?version=2021-01-21"></script>
<script src="src/paint.js?version=2020-05-17"></script>

Wyświetl plik

@ -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-26';
modules.threads = '2021-January-27';
var ThreadManager;
var Process;
@ -2019,7 +2019,7 @@ Process.prototype.reportTableWidth = function (list) {
Process.prototype.reportTableColumn = function (index, list) {
// experimental and probably controversial as a primitive,
// because it's so nice and easy to write in Snap!
var col;
var rank, col;
if (!this.isMatrix(list)) {
throw new Error(
'expecting ' + 'table' + ' but getting ' + this.reportTypeOf(list)
@ -2035,6 +2035,16 @@ Process.prototype.reportTableColumn = function (index, list) {
if (this.inputOption(index) === 'last') {
return list.map(row => row.at(this.reportTableWidth(list)));
}
rank = this.rank(index);
if (rank > 0 && this.enableHyperOps) {
if (rank === 1) {
if (index.isEmpty()) {
return list.map(item => item);
}
return list.map(row => index.map(idx => row.at(idx)));
}
throw new Error('cannot use nested list\nfor selecting columns');
}
return list.map(row => row.at(index));
};