kopia lustrzana https://github.com/backface/turtlestitch
reverted multimap
let's use a JS-block based custom block to engineer it firstpull/95/head
rodzic
5aece84881
commit
cf267df944
|
@ -7,7 +7,6 @@
|
||||||
* hyperdyadic MIN and MAX primitives reachable via "relabel"
|
* hyperdyadic MIN and MAX primitives reachable via "relabel"
|
||||||
* hyperdyadic less / great than or equals primitives reachable via "relabel"
|
* hyperdyadic less / great than or equals primitives reachable via "relabel"
|
||||||
* new SIGN function in arithmetic dropdown
|
* new SIGN function in arithmetic dropdown
|
||||||
* new experimental compiled Multimap, thanks, Brian
|
|
||||||
* **Notable Changes:**
|
* **Notable Changes:**
|
||||||
* searching for blocks and keyboard entry now includes the contents of dropdown menus
|
* 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)
|
* 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
|
### 2020-12-07
|
||||||
* GUI: improved SVG loading, thanks, Joan!
|
* GUI: improved SVG loading, thanks, Joan!
|
||||||
* threads, objects, blocks: compiled multimap, thanks, Brian
|
* 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
|
### 2020-12-05
|
||||||
* objects: alternative collision detection method using the video-cache, commented out for reference.
|
* objects: alternative collision detection method using the video-cache, commented out for reference.
|
||||||
|
|
|
@ -2853,7 +2853,6 @@ BlockMorph.prototype.userMenu = function () {
|
||||||
contains(
|
contains(
|
||||||
[
|
[
|
||||||
'reportAtomicMap',
|
'reportAtomicMap',
|
||||||
'reportAtomicMultimap',
|
|
||||||
'reportAtomicKeep',
|
'reportAtomicKeep',
|
||||||
'reportAtomicFindFirst',
|
'reportAtomicFindFirst',
|
||||||
'reportAtomicCombine'
|
'reportAtomicCombine'
|
||||||
|
@ -2863,7 +2862,6 @@ BlockMorph.prototype.userMenu = function () {
|
||||||
) {
|
) {
|
||||||
alternatives = {
|
alternatives = {
|
||||||
reportAtomicMap : 'reportMap',
|
reportAtomicMap : 'reportMap',
|
||||||
reportAtomicMultimap : 'reportMap',
|
|
||||||
reportAtomicKeep : 'reportKeep',
|
reportAtomicKeep : 'reportKeep',
|
||||||
reportAtomicFindFirst: 'reportFindFirst',
|
reportAtomicFindFirst: 'reportFindFirst',
|
||||||
reportAtomicCombine : 'reportCombine'
|
reportAtomicCombine : 'reportCombine'
|
||||||
|
@ -11716,7 +11714,6 @@ MultiArgMorph.prototype.is3ArgRingInHOF = function () {
|
||||||
[
|
[
|
||||||
'reportMap',
|
'reportMap',
|
||||||
'reportAtomicMap',
|
'reportAtomicMap',
|
||||||
'reportAtomicMultimap',
|
|
||||||
'reportKeep',
|
'reportKeep',
|
||||||
'reportAtomicKeep',
|
'reportAtomicKeep',
|
||||||
'reportFindFirst',
|
'reportFindFirst',
|
||||||
|
|
|
@ -1381,12 +1381,6 @@ SpriteMorph.prototype.initBlocks = function () {
|
||||||
category: 'lists',
|
category: 'lists',
|
||||||
spec: '%blitz map %repRing over %l'
|
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: {
|
reportKeep: {
|
||||||
type: 'reporter',
|
type: 'reporter',
|
||||||
category: 'lists',
|
category: 'lists',
|
||||||
|
@ -1694,12 +1688,7 @@ SpriteMorph.prototype.blockAlternatives = {
|
||||||
reportKeep: ['reportFindFirst', 'reportMap'],
|
reportKeep: ['reportFindFirst', 'reportMap'],
|
||||||
reportFindFirst: ['reportKeep', 'reportMap'],
|
reportFindFirst: ['reportKeep', 'reportMap'],
|
||||||
doForEach: [['doFor', 1], ['doForever', -2], ['doRepeat', -1],
|
doForEach: [['doFor', 1], ['doForever', -2], ['doRepeat', -1],
|
||||||
['doUntil', -1]],
|
['doUntil', -1]]
|
||||||
|
|
||||||
// lists - special hidden HOFs
|
|
||||||
reportAtomicMap: ['reportAtomicMultimap'],
|
|
||||||
reportAtomicMultimap: ['reportAtomicMap']
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// SpriteMorph instance creation
|
// SpriteMorph instance creation
|
||||||
|
|
|
@ -6100,75 +6100,6 @@ Process.prototype.reportAtomicMap = function (reporter, list) {
|
||||||
return new List(result);
|
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) {
|
Process.prototype.reportAtomicKeep = function (reporter, list) {
|
||||||
// if the reporter uses formal parameters instead of implicit empty slots
|
// if the reporter uses formal parameters instead of implicit empty slots
|
||||||
// there are two additional optional parameters:
|
// there are two additional optional parameters:
|
||||||
|
|
Ładowanie…
Reference in New Issue