From cf267df9441eb7ff8a2409ad95e0fedc199c48bf Mon Sep 17 00:00:00 2001 From: jmoenig Date: Mon, 7 Dec 2020 14:11:40 +0100 Subject: [PATCH] reverted multimap let's use a JS-block based custom block to engineer it first --- HISTORY.md | 2 +- src/blocks.js | 3 --- src/objects.js | 13 +--------- src/threads.js | 69 -------------------------------------------------- 4 files changed, 2 insertions(+), 85 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 6fbb17a6..8a1e88df 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -7,7 +7,6 @@ * hyperdyadic MIN and MAX primitives reachable via "relabel" * hyperdyadic less / great than or equals primitives reachable via "relabel" * new SIGN function in arithmetic dropdown - * new experimental compiled Multimap, thanks, Brian * **Notable Changes:** * searching for blocks and keyboard entry now includes the contents of dropdown menus * disabled dropping reporters into certain dropdowns (monadic functions, types, costume attributees, graphic effects, layers, audio attributes, pen attributes, dates, relation, keys, video attributes) @@ -24,6 +23,7 @@ ### 2020-12-07 * GUI: improved SVG loading, thanks, Joan! * threads, objects, blocks: compiled multimap, thanks, Brian +* reverted multimap, let's use a JS-block based custom block to engineer it first ### 2020-12-05 * objects: alternative collision detection method using the video-cache, commented out for reference. diff --git a/src/blocks.js b/src/blocks.js index 9fd03eef..f02379f9 100644 --- a/src/blocks.js +++ b/src/blocks.js @@ -2853,7 +2853,6 @@ BlockMorph.prototype.userMenu = function () { contains( [ 'reportAtomicMap', - 'reportAtomicMultimap', 'reportAtomicKeep', 'reportAtomicFindFirst', 'reportAtomicCombine' @@ -2863,7 +2862,6 @@ BlockMorph.prototype.userMenu = function () { ) { alternatives = { reportAtomicMap : 'reportMap', - reportAtomicMultimap : 'reportMap', reportAtomicKeep : 'reportKeep', reportAtomicFindFirst: 'reportFindFirst', reportAtomicCombine : 'reportCombine' @@ -11716,7 +11714,6 @@ MultiArgMorph.prototype.is3ArgRingInHOF = function () { [ 'reportMap', 'reportAtomicMap', - 'reportAtomicMultimap', 'reportKeep', 'reportAtomicKeep', 'reportFindFirst', diff --git a/src/objects.js b/src/objects.js index d57355d7..6f918fd4 100644 --- a/src/objects.js +++ b/src/objects.js @@ -1381,12 +1381,6 @@ SpriteMorph.prototype.initBlocks = function () { category: 'lists', spec: '%blitz map %repRing over %l' }, - reportAtomicMultimap: { - dev: true, // not shown in palette, only accessible via relabelling - type: 'reporter', - category: 'lists', - spec: '%blitz multimap %repRing over %lists' - }, reportKeep: { type: 'reporter', category: 'lists', @@ -1694,12 +1688,7 @@ SpriteMorph.prototype.blockAlternatives = { reportKeep: ['reportFindFirst', 'reportMap'], reportFindFirst: ['reportKeep', 'reportMap'], doForEach: [['doFor', 1], ['doForever', -2], ['doRepeat', -1], - ['doUntil', -1]], - - // lists - special hidden HOFs - reportAtomicMap: ['reportAtomicMultimap'], - reportAtomicMultimap: ['reportAtomicMap'] - + ['doUntil', -1]] }; // SpriteMorph instance creation diff --git a/src/threads.js b/src/threads.js index 25ab605f..122b57cd 100644 --- a/src/threads.js +++ b/src/threads.js @@ -6100,75 +6100,6 @@ Process.prototype.reportAtomicMap = function (reporter, list) { return new List(result); }; -// Multimap takes a list of lists and gives the indexth item of each list -// to the reporter. If formal parameters, a single list of all the indexth -// items are bound to the "value" parameter; if not, the individual items are -// distributed among the empty slots. - -Process.prototype.reportAtomicMultimap = function (reporter, list) { - // if the reporter uses formal parameters instead of implicit empty slots - // there are two additional optional parameters: - // #1 - element - // #2 - optional | index - // #3 - optional | source list - - this.assertType(list, 'list'); - if (list.itemsArray().length == 1) { - return this.reportAtomicMap(reporter, list.at(1)); - } - var result = [], - src = list.itemsArray().map(onelist => onelist.itemsArray()), - len = src[1].length, - width = src.length, - formalParameterCount = reporter.inputs.length, - column = (list, index) => list.map(row => row[index]), - parms, - func, - i; - - // try compiling the reporter into generic JavaScript - // fall back to the morphic reporter if unsuccessful - try { - if (formalParameterCount > 0) { - func = this.reportCompiled(reporter, 1); // val is list of items - } else { - func = this.reportCompiled(reporter, width); // variadicish - } - } catch (err) { - console.log(err.message); - func = reporter; - } - - // iterate over the data in a single frame: - // to do: Insert some kind of user escape mechanism - - for (i = 0; i < len; i += 1) { - if (formalParameterCount > 0) { - parms = [new List(column(src, i))]; - } else { - parms = column(src, i); - } - if (formalParameterCount > 1) { - parms.push(i + 1); - } - if (formalParameterCount > 2) { - parms.push(list); - } - result.push( - invoke( - func, - new List(parms), - null, - null, - null, - null, - this.capture(reporter) // process - ) - ); - } - return new List(result); -}; - Process.prototype.reportAtomicKeep = function (reporter, list) { // if the reporter uses formal parameters instead of implicit empty slots // there are two additional optional parameters: