reverted multimap

let's use a JS-block based custom block to engineer it first
pull/95/head
jmoenig 2020-12-07 14:11:40 +01:00
rodzic 5aece84881
commit cf267df944
4 zmienionych plików z 2 dodań i 85 usunięć

Wyświetl plik

@ -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.

Wyświetl plik

@ -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',

Wyświetl plik

@ -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

Wyświetl plik

@ -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: