new library: Frequency Distribution Analysis, separated from "Bigger Data"

pull/68/head
jmoenig 2018-11-02 17:32:32 +01:00
rodzic 2e4f52f40a
commit 9cb98f849a
4 zmienionych plików z 6 dodań i 1 usunięć

Wyświetl plik

@ -1,5 +1,8 @@
# Snap<em>!</em> (BYOB) History
###2018-11-02
* new library: Frequency Distribution Analysis, separated from "Bigger Data"
## v4.2.2.4
###2018-10-29
* Blocks: fixed #2234 (display all reachable local variables in drop-down menu)

Wyświetl plik

@ -18,6 +18,7 @@ animation_module.xml Animation glide, grow and rotate using easing functions.
pixel_module.xml Pixels manipulate costumes pixel-wise.
audioComp_module.xml Audio Comp analyze, manipulate and generate sound samples.
atomic_HOFs_module.xml "Bigger" Data [EXPERIMENTAL] crunch large lists very fast
frequency_distribution_module.xml Frequency Distribution Analysis [EXPERIMENTAL] analyze data for frequency distribution
make-variables.xml create variables in program declare global or sprite-local variables in a script
json.xml Deal with JSON data Turn JSON strings into lists with the listify block, then retrieve data out of them by using the value at key block.
parallel_module.xml Parallelization Run several scripts in parallel and wait until all are done.

Wyświetl plik

@ -1 +1 @@
<blocks app="Snap! 4.2, http://snap.berkeley.edu" version="1"><block-definition s="$flash map %&apos;fn&apos; over %&apos;data&apos;" type="reporter" category="lists"><header></header><code></code><translations></translations><inputs><input type="%repRing"></input><input type="%l"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>fn</l><l>data</l><l>proc</l></list><l>return proc.reportAtomicMap(fn, data);</l></block><list><block var="fn"/><block var="data"/></list></block></block></script></block-definition><block-definition s="$flash keep %&apos;test&apos; from %&apos;data&apos;" type="reporter" category="lists"><header></header><code></code><translations></translations><inputs><input type="%predRing"></input><input type="%l"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>fn</l><l>data</l><l>proc</l></list><l>return proc.reportAtomicKeep(fn, data);</l></block><list><block var="test"/><block var="data"/></list></block></block></script></block-definition><block-definition s="$flash combine %&apos;fn&apos; with %&apos;data&apos;" type="reporter" category="lists"><header></header><code></code><translations></translations><inputs><input type="%repRing"></input><input type="%l"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>fn</l><l>data</l><l>proc</l></list><l>return proc.reportAtomicCombine(fn, data);</l></block><list><block var="fn"/><block var="data"/></list></block></block></script></block-definition><block-definition s="$flash sort %&apos;data&apos; by %&apos;fn&apos;" type="reporter" category="lists"><header></header><code></code><translations></translations><inputs><input type="%l"></input><input type="%predRing"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>data</l><l>fn</l><l>proc</l></list><l>return proc.reportAtomicSort(data, fn);</l></block><list><block var="data"/><block var="fn"/></list></block></block></script></block-definition><block-definition s="$flash reverse %&apos;list&apos;" type="reporter" category="lists"><header></header><code></code><translations></translations><inputs><input type="%l"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>list</l></list><l>return new List(list.asArray().slice().reverse());</l></block><list><block var="list"/></list></block></block></script></block-definition><block-definition s="$flash analyze %&apos;data&apos;" type="reporter" category="lists"><comment x="0" y="0" w="149" collapsed="false">returns a frequency analysis of the argument list, represented as a two-column table, where the first column contains the unique values and the second column their occurrences</comment><header></header><code></code><translations></translations><inputs><input type="%l"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>list</l></list><l>var dict = new Map(),&#xD; result = [],&#xD; data = list.asArray(),&#xD; len = data.length,&#xD; i;&#xD;for (i = 0; i &lt; len; i += 1) {&#xD; if (dict.has(data[i])) {&#xD; dict.set(data[i], dict.get(data[i]) + 1);&#xD; } else {&#xD; dict.set(data[i], 1);&#xD; }&#xD;}&#xD;dict.forEach(function (value, key) {&#xD; result.push(new List([key, value]));&#xD;});&#xD;return new List(result);</l></block><list><block var="data"/></list></block></block></script></block-definition><block-definition s="$flash group %&apos;data&apos; by %&apos;fn&apos;" type="reporter" category="lists"><header></header><code></code><translations></translations><inputs><input type="%l"></input><input type="%repRing"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>data</l><l>fn</l><l>proc</l></list><l>return proc.reportAtomicGroup(data, fn);</l></block><list><block var="data"/><block var="fn"/></list></block></block></script></block-definition></blocks>
<blocks app="Snap! 4.2, http://snap.berkeley.edu" version="1"><block-definition s="$flash map %&apos;fn&apos; over %&apos;data&apos;" type="reporter" category="lists"><header></header><code></code><translations></translations><inputs><input type="%repRing"></input><input type="%l"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>fn</l><l>data</l><l>proc</l></list><l>return proc.reportAtomicMap(fn, data);</l></block><list><block var="fn"/><block var="data"/></list></block></block></script></block-definition><block-definition s="$flash keep %&apos;test&apos; from %&apos;data&apos;" type="reporter" category="lists"><header></header><code></code><translations></translations><inputs><input type="%predRing"></input><input type="%l"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>fn</l><l>data</l><l>proc</l></list><l>return proc.reportAtomicKeep(fn, data);</l></block><list><block var="test"/><block var="data"/></list></block></block></script></block-definition><block-definition s="$flash combine %&apos;fn&apos; with %&apos;data&apos;" type="reporter" category="lists"><header></header><code></code><translations></translations><inputs><input type="%repRing"></input><input type="%l"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>fn</l><l>data</l><l>proc</l></list><l>return proc.reportAtomicCombine(fn, data);</l></block><list><block var="fn"/><block var="data"/></list></block></block></script></block-definition><block-definition s="$flash sort %&apos;data&apos; by %&apos;fn&apos;" type="reporter" category="lists"><header></header><code></code><translations></translations><inputs><input type="%l"></input><input type="%predRing"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>data</l><l>fn</l><l>proc</l></list><l>return proc.reportAtomicSort(data, fn);</l></block><list><block var="data"/><block var="fn"/></list></block></block></script></block-definition><block-definition s="$flash reverse %&apos;list&apos;" type="reporter" category="lists"><header></header><code></code><translations></translations><inputs><input type="%l"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>list</l></list><l>return new List(list.asArray().slice().reverse());</l></block><list><block var="list"/></list></block></block></script></block-definition></blocks>

Wyświetl plik

@ -0,0 +1 @@
<blocks app="Snap! 4.2, http://snap.berkeley.edu" version="1"><block-definition s="$flash analyze %&apos;data&apos;" type="reporter" category="lists"><comment x="0" y="0" w="149" collapsed="false">returns a frequency analysis of the argument list, represented as a two-column table, where the first column contains the unique values and the second column their occurrences</comment><header></header><code></code><translations></translations><inputs><input type="%l"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>list</l></list><l>var dict = new Map(),&#xD; result = [],&#xD; data = list.asArray(),&#xD; len = data.length,&#xD; i;&#xD;for (i = 0; i &lt; len; i += 1) {&#xD; if (dict.has(data[i])) {&#xD; dict.set(data[i], dict.get(data[i]) + 1);&#xD; } else {&#xD; dict.set(data[i], 1);&#xD; }&#xD;}&#xD;dict.forEach(function (value, key) {&#xD; result.push(new List([key, value]));&#xD;});&#xD;return new List(result);</l></block><list><block var="data"/></list></block></block></script></block-definition><block-definition s="$flash group %&apos;data&apos; by %&apos;fn&apos;" type="reporter" category="lists"><header></header><code></code><translations></translations><inputs><input type="%l"></input><input type="%repRing"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>data</l><l>fn</l><l>proc</l></list><l>return proc.reportAtomicGroup(data, fn);</l></block><list><block var="data"/><block var="fn"/></list></block></block></script></block-definition></blocks>