turtlestitch/libraries/frequency_distribution_modu...

1 wiersz
12 KiB
XML

<blocks app="Snap! 5.0, 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>pt:$flash as frequências dos itens de _&#xD;</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>pt:o agrupamento dos itens de _ de acordo com _&#xD;</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><block-definition s="$flash sort %&apos;data&apos; by %&apos;fn&apos;" type="reporter" category="lists"><header></header><code></code><translations>pt:uma ordenação de _ com critério _&#xD;</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="histogram of %&apos;data&apos; from: %&apos;floor&apos; to: %&apos;ceiling&apos; interval: %&apos;interval&apos;" type="reporter" category="lists"><header></header><code></code><translations>pt:o histograma de _ entre _ e _ com intervalo _&#xD;</translations><inputs><input type="%l"></input><input type="%n"></input><input type="%n"></input><input type="%n">1</input></inputs><script><block s="doReport"><custom-block s="fill %l key: %repRing from: %n to: %n interval: %repRing with: %repRing"><custom-block s="$flash sort %l by %predRing"><custom-block s="$flash analyze %l"><block var="data"/></custom-block><block s="reifyPredicate"><autolambda><block s="reportLessThan"><block s="reportListItem"><l>1</l><l/></block><block s="reportListItem"><l>1</l><l/></block></block></autolambda><list></list></block></custom-block><block s="reifyReporter"><autolambda><block s="reportListItem"><l>1</l><l/></block></autolambda><list></list></block><block var="floor"/><block var="ceiling"/><block s="reifyReporter"><autolambda><block s="reportSum"><l></l><block var="interval"/></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportNewList"><list><l></l><l>0</l></list></block></autolambda><list></list></block></custom-block></block></script></block-definition><block-definition s="histogram of %&apos;data&apos; grouped by: %&apos;key&apos; from: %&apos;floor&apos; to: %&apos;ceiling&apos; interval: %&apos;interval&apos;" type="reporter" category="lists"><header></header><code></code><translations>pt:o histograma de _ agrupado de acordo com _ entre _ e _ com passo _&#xD;</translations><inputs><input type="%l"></input><input type="%repRing"></input><input type="%n"></input><input type="%n"></input><input type="%repRing"></input></inputs><script><block s="doReport"><custom-block s="fill %l key: %repRing from: %n to: %n interval: %repRing with: %repRing"><custom-block s="$flash sort %l by %predRing"><custom-block s="$flash group %l by %repRing"><block var="data"/><block var="key"/></custom-block><block s="reifyPredicate"><autolambda><block s="reportLessThan"><block s="reportListItem"><l>1</l><l/></block><block s="reportListItem"><l>1</l><l/></block></block></autolambda><list></list></block></custom-block><block s="reifyReporter"><autolambda><block s="reportListItem"><l>1</l><l/></block></autolambda><list></list></block><block var="floor"/><block var="ceiling"/><block var="interval"/><block s="reifyReporter"><autolambda><block s="reportNewList"><list><l></l><l>0</l><block s="reportNewList"><list></list></block></list></block></autolambda><list></list></block></custom-block></block></script></block-definition><block-definition s="fill %&apos;data&apos; key: %&apos;key&apos; from: %&apos;floor&apos; to: %&apos;ceiling&apos; interval: %&apos;interval&apos; with: %&apos;generator&apos;" type="reporter" category="lists"><comment w="103" collapsed="false">add missing entries to a sorted list. Used for histograms</comment><header></header><code></code><translations>pt:os itens de _ com a chave _ entre _ e _ com passo _ completados por _&#xD;</translations><inputs><input type="%l"></input><input type="%repRing"></input><input type="%n"></input><input type="%n"></input><input type="%repRing"></input><input type="%repRing"></input></inputs><script><block s="doIf"><block s="reportGreaterThan"><block var="floor"/><block var="ceiling"/></block><script><block s="doReport"><block s="reportNewList"><list></list></block></block></script></block><block s="doIf"><block s="reportEquals"><block var="data"/><block s="reportNewList"><list></list></block></block><script><block s="doReport"><block s="reportCONS"><block s="evaluate"><block var="generator"/><list><block var="floor"/></list></block><custom-block s="fill %l key: %repRing from: %n to: %n interval: %repRing with: %repRing"><block var="data"/><block var="key"/><block s="evaluate"><block var="interval"/><list><block var="floor"/></list></block><block var="ceiling"/><block var="interval"/><block var="generator"/></custom-block></block></block></script></block><block s="doIf"><block s="reportLessThan"><block s="evaluate"><block var="key"/><list><block s="reportListItem"><l>1</l><block var="data"/></block></list></block><block var="floor"/></block><script><block s="doReport"><custom-block s="fill %l key: %repRing from: %n to: %n interval: %repRing with: %repRing"><block s="reportCDR"><block var="data"/></block><block var="key"/><block var="floor"/><block var="ceiling"/><block var="interval"/><block var="generator"/></custom-block></block></script></block><block s="doIf"><block s="reportEquals"><block s="evaluate"><block var="key"/><list><block s="reportListItem"><l>1</l><block var="data"/></block></list></block><block var="floor"/></block><script><block s="doReport"><block s="reportCONS"><block s="reportListItem"><l>1</l><block var="data"/></block><custom-block s="fill %l key: %repRing from: %n to: %n interval: %repRing with: %repRing"><block s="reportCDR"><block var="data"/></block><block var="key"/><block s="evaluate"><block var="interval"/><list><block var="floor"/></list></block><block var="ceiling"/><block var="interval"/><block var="generator"/></custom-block></block></block></script></block><block s="doReport"><block s="reportCONS"><block s="evaluate"><block var="generator"/><list><block var="floor"/></list></block><custom-block s="fill %l key: %repRing from: %n to: %n interval: %repRing with: %repRing"><block var="data"/><block var="key"/><block s="evaluate"><block var="interval"/><list><block var="floor"/></list></block><block var="ceiling"/><block var="interval"/><block var="generator"/></custom-block></block></block></script></block-definition><block-definition s="pipe %&apos;value&apos; $arrowRight %&apos;pipe&apos;" type="reporter" category="control"><header></header><code></code><translations>pt:a aplicação a _ de _&#xD;</translations><inputs><input type="%s"></input><input type="%mult%repRing"></input></inputs><script><block s="doIf"><block s="reportListIsEmpty"><block var="pipe"/></block><script><block s="doReport"><block var="value"/></block></script></block><block s="doReport"><custom-block s="pipe %s $arrowRight %mult%repRing"><block s="evaluate"><block s="reportListItem"><l>1</l><block var="pipe"/></block><list><block var="value"/></list></block><block s="reportCDR"><block var="pipe"/></block></custom-block></block></script></block-definition><block-definition s="%&apos;text&apos; $arrowRight lower case" type="reporter" category="operators"><header></header><code></code><translations>pt:_ em minúsculas&#xD;</translations><inputs><input type="%s"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>txt</l></list><l>return txt.toLowerCase()</l></block><list><block var="text"/></list></block></block></script></block-definition><block-definition s="plot %&apos;data&apos; bars at x: %&apos;left&apos; y: %&apos;bottom&apos; width: %&apos;width&apos; height: %&apos;height&apos;" type="command" category="pen"><header></header><code></code><translations>pt:desenha gráfico de barras de _ em (x: _ , y: _ ) com largura _ e altura _&#xD;</translations><inputs><input type="%l"></input><input type="%n">-200</input><input type="%n">-100</input><input type="%n">400</input><input type="%n">200</input></inputs><script><block s="doDeclareVariables"><list><l>ratio</l><l>step</l><l>flat line ends</l><l>col</l><l>sorted</l><l>min</l></list></block><block s="doSetVar"><l>flat line ends</l><block s="evaluate"><block s="reportJSFunction"><list></list><l>var isFlat = SpriteMorph.prototype.useFlatLineEnds;&#xD;SpriteMorph.prototype.useFlatLineEnds = true;&#xD;return isFlat;</l></block><list></list></block></block><block s="doSetVar"><l>sorted</l><custom-block s="$flash sort %l by %predRing"><block var="data"/><block s="reifyPredicate"><autolambda><block s="reportGreaterThan"><l></l><l></l></block></autolambda><list></list></block></custom-block></block><block s="doIfElse"><block s="reportLessThan"><block s="reportListItem"><l><option>last</option></l><block var="sorted"/></block><l>0</l></block><script><block s="doSetVar"><l>min</l><block s="reportListItem"><l><option>last</option></l><block var="sorted"/></block></block></script><script><block s="doSetVar"><l>min</l><l>0</l></block></script></block><block s="doSetVar"><l>ratio</l><block s="reportQuotient"><block var="height"/><block s="reportDifference"><block s="reportListItem"><l>1</l><block var="sorted"/></block><block var="min"/></block></block></block><block s="doSetVar"><l>step</l><block s="reportQuotient"><block var="width"/><block s="reportListLength"><block var="data"/></block></block></block><block s="doIfElse"><block s="reportGreaterThan"><block var="step"/><l>2</l></block><script><block s="doSetVar"><l>col</l><block s="reportDifference"><block var="step"/><l>1</l></block></block></script><script><block s="doSetVar"><l>col</l><block s="reportProduct"><block var="step"/><l>0.8</l></block></block></script></block><block s="gotoXY"><block var="left"/><block var="bottom"/></block><block s="setSize"><l>0.5</l></block><block s="down"></block><block s="changeXPosition"><block s="reportQuotient"><block var="step"/><l>2</l></block></block><block s="doWarp"><script><block s="doUntil"><block s="reportEquals"><block s="reportListLength"><block var="data"/></block><l>0</l></block><script><block s="setSize"><block var="col"/></block><block s="changeYPosition"><block s="reportProduct"><block s="reportDifference"><block s="reportListItem"><l>1</l><block var="data"/></block><block var="min"/></block><block var="ratio"/></block></block><block s="setYPosition"><block var="bottom"/></block><block s="setSize"><l>0.5</l></block><block s="doSetVar"><l>data</l><block s="reportCDR"><block var="data"/></block></block><block s="doIfElse"><block s="reportGreaterThan"><block s="reportListLength"><block var="data"/></block><l>0</l></block><script><block s="changeXPosition"><block var="step"/></block></script><script><block s="changeXPosition"><block s="reportQuotient"><block var="step"/><l>2</l></block></block></script></block></script></block></script></block><block s="up"></block><block s="doRun"><block s="reportJSFunction"><list><l>flag</l></list><l>SpriteMorph.prototype.useFlatLineEnds = flag;</l></block><list><block var="flat line ends"/></list></block></script></block-definition></blocks>