From b5e210e65721e2cfd83d5af6ab64b088b2d1f1ab Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 27 Jan 2021 08:40:26 +0100 Subject: [PATCH] hyperized new experimental "column" primitive --- HISTORY.md | 3 +++ snap.html | 2 +- src/threads.js | 14 ++++++++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index ae9eebfa..ea374a6b 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -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 _" diff --git a/snap.html b/snap.html index 0589b633..0fa06840 100755 --- a/snap.html +++ b/snap.html @@ -9,7 +9,7 @@ - + diff --git a/src/threads.js b/src/threads.js index d9a5543f..4f3e852a 100644 --- a/src/threads.js +++ b/src/threads.js @@ -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)); };