kopia lustrzana https://github.com/backface/turtlestitch
New "reportAtomicGroup" HOF primitive using the JIT compiler
rodzic
e17d5e343b
commit
ed297096e4
|
@ -3,6 +3,7 @@
|
|||
## Development
|
||||
### 2018-10-23
|
||||
* Objects: Don't stamp if the canvas is too small (and would throw an error)
|
||||
* Threads: New "reportAtomicGroup" HOF primitive using the JIT compiler
|
||||
|
||||
### 2018-10-22
|
||||
* "Bigger Data" library: Added "analyze" function for fast frequency distributions
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<script type="text/javascript" src="src/morphic.js?version=2018-10-02"></script>
|
||||
<script type="text/javascript" src="src/widgets.js?version=2018-10-02"></script>
|
||||
<script type="text/javascript" src="src/blocks.js?version=2018-10-02"></script>
|
||||
<script type="text/javascript" src="src/threads.js?version=2018-10-19"></script>
|
||||
<script type="text/javascript" src="src/threads.js?version=2018-10-23"></script>
|
||||
<script type="text/javascript" src="src/objects.js?version=2018-10-23"></script>
|
||||
<script type="text/javascript" src="src/gui.js?version=2018-10-23"></script>
|
||||
<script type="text/javascript" src="src/paint.js?version=2018-10-02"></script>
|
||||
|
|
|
@ -60,9 +60,9 @@ degrees, detect, nop, radians, ReporterSlotMorph, CSlotMorph, RingMorph, Sound,
|
|||
IDE_Morph, ArgLabelMorph, localize, XML_Element, hex_sha512, TableDialogMorph,
|
||||
StageMorph, SpriteMorph, StagePrompterMorph, Note, modules, isString, copy,
|
||||
isNil, WatcherMorph, List, ListWatcherMorph, alert, console, TableMorph,
|
||||
TableFrameMorph, ColorSlotMorph, isSnapObject*/
|
||||
TableFrameMorph, ColorSlotMorph, isSnapObject, Map*/
|
||||
|
||||
modules.threads = '2018-October-19';
|
||||
modules.threads = '2018-October-23';
|
||||
|
||||
var ThreadManager;
|
||||
var Process;
|
||||
|
@ -4007,6 +4007,51 @@ Process.prototype.reportAtomicSort = function (list, reporter) {
|
|||
);
|
||||
};
|
||||
|
||||
Process.prototype.reportAtomicGroup = function (list, reporter) {
|
||||
this.assertType(list, 'list');
|
||||
var result = [],
|
||||
dict = new Map(),
|
||||
groupKey,
|
||||
src = list.asArray(),
|
||||
len = src.length,
|
||||
func,
|
||||
i;
|
||||
|
||||
// try compiling the reporter into generic JavaScript
|
||||
// fall back to the morphic reporter if unsuccessful
|
||||
try {
|
||||
func = this.reportCompiled(reporter, 1); // a single expected input
|
||||
} 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) {
|
||||
groupKey = invoke(
|
||||
func,
|
||||
new List([src[i]]),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
this.capture(reporter) // process
|
||||
);
|
||||
if (dict.has(groupKey)) {
|
||||
dict.get(groupKey).push(src[i]);
|
||||
} else {
|
||||
dict.set(groupKey, [src[i]]);
|
||||
}
|
||||
}
|
||||
|
||||
dict.forEach(function (value, key) {
|
||||
result.push(new List([key, value.length, new List(value)]));
|
||||
});
|
||||
return new List(result);
|
||||
};
|
||||
|
||||
// Context /////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
|
|
Ładowanie…
Reference in New Issue