<snapdata remixID="11418931"><project name="functions" app="Snap! 7, https://snap.berkeley.edu" version="2"><notes></notes><thumbnail>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAB4CAYAAAB1ovlvAAAEw0lEQVR4Xu3dwUubdwDG8SckEjBmOmQgbp2jYzDQg2AuvXRgD92horaHQHGjqwoWh9hL1x02CtNKiKUdAwtldHTL6P4NGZs9exxjgx1mgoeNwGydg2yvByEz9RXnzyfOr7fyxt/z5vt+iKU9mKj98yW+KGAqkACgqTyz2wUACARrAQBa8zMOQAxYCwDQmp9xAP7PDJTLZRUujev9pYJ6et9UKpVq6ncIwKZ+PAe7uVLxM7Xe+HL7m8utNW1dPaeL16/p1OnXDnZgwO8CYMC4zqNLl2fV+vi7XbfwfUtVg/c/0lv5EWXa2py3yD/D2OsHvIGHZ/LqePJT3cLvLTX90veSLjz4RLlcLuD6/o/mE3D/rY7NK+9emVHPoxVVE3/pWe8rapu9qLHx95ry/gHYlI/l4De1tramh7fv6Oa9gpLJ5MEPOqLvBOARhWamcQEAIsNaAIDW/IwDEAPWAgC05mccgBiwFgCgNT/jAMSAtQAArfkZByAGrAUAaM3POAAxYC0AQGt+xgGIAWsBAFrzMw5ADFgLANCan3EAYsBaAIDW/IwDEAPWAgC05mccgBiwFgCgNT/jAMSAtQAArfkZByAGrAUAaM3POAAxYC0AQGt+xgGIAWsBAFrzMw5ADFgLANCan3EAYsBaAIDW/IwDEAPWAgC05mccgBiwFgCgNT/jAMSAtQAArfkZByAGrAUAaM3POAAxYC0AQGt+xgG4h4FaraZEIoGSgAUAuEfcmZkZra6uKp/Pa3h4WN3d3QEfxck8GoAxz31oaEipVGrnVevr65qbm1N/f786OjpOpppDfNcA3EfM0dHRhq+KfjxHvyB6ZWVlH6fwkkYFABjjYmpqSpVKZedVW1tbymazmpyc1ODgIKr+YwEA7hGwWCxqeXlZnZ2dGhgYUPR3Qr4OtwAA9+i5ubmpdDp9uMU5ra4AAAFhLQBAa37GAYgBawEAWvMzDkAMWAsA0JqfcQBiwFoAgNb8jAMQA9YCALTmZxyAGLAWAKA1P+MAxIC1AACt+RkHIAasBQBozc84ADFgLQBAa37GAYgBawEAWvMzDkAMWAsA0JqfcQBiwFoAgNb8jAMQA9YCALTmZxyAGLAWAKA1P+MAxIC1AACt+RkHIAasBQBozc84ADFgLQBAa37GAYgBawEAWvMzHhRguVzW4s1Luvbhknpe7637hS+kp0BUICjAaODrz4t68ccb27V/rbZq4+WrGn3nuk69eponQIHwAKPG39y5rBfWH+/K/e0PLTo7dl9nz+eVybTxOE5ggeCfgFHTrz4+o84/n9Tl/e1pi37e7NPbEw+Uy+VOYHre8pH8CP701hW98eyRqk8T+iPdq3TfrMbeHac+BbYLBP0EjH6R3xdLt/XBrXtKJpMkp8CuAkEB0psCcQUAGFeI60ELADBoXg6PKwDAuEJcD1oAgEHzcnhcAQDGFeJ60AIADJqXw+MKADCuENeDFgBg0LwcHlcAgHGFuB60AAD/lbdQKGhhYUETExNaXFwMGp/DA/9f8HENnMlktLGxsXP70Z9LpZJGRkaO61tq2vvmE/A5j6a9vV3VarXh1Ww2+9xrTfukm/TGANjgwVQqFXV1ddVdiUBOT09rfn6+SR/l8bytvwHRXHS3QRVxvAAAAABJRU5ErkJggg==</thumbnail><scenes select="1"><scene name="functions"><notes></notes><palette><category name="assoc" color="217,77,17,1"/></palette><hidden></hidden><headers></headers><code></code><blocks><block-definition s="var %&apos;var&apos;" type="reporter" category="variables"><header></header><code></code><translations></translations><inputs><input type="%code"><options>§_getVarNamesDict</options></input></inputs><script><block s="doReport"><block s="reportApplyExtension"><l>var_get(name)</l><list><block var="var"/></list></block></block></script></block-definition><block-definition s="function %&apos;func&apos; ( %&apos;parameters&apos; ) %&apos;body&apos;" type="command" category="control"><header></header><code></code><translations></translations><inputs><input type="%s" readonly="true"><options>§_getVarNamesDict</options></input><input type="%mult%t"></input><input type="%c"></input></inputs><script><block s="doApplyExtension"><l>var_set(name, val)</l><list><block var="func"/><block s="reifyScript"><block var="body"/><block var="parameters"/></block></list></block></script></block-definition><block-definition s="function ( %&apos;parameters&apos; ) %&apos;body&apos;" type="reporter" category="control"><header></header><code></code><translations></translations><inputs><input type="%mult%t"></input><input type="%c"></input></inputs><script><block s="doIf"><block s="reportEquals"><block var="body"/><l>0</l></block><script><block s="doReport"><block var="body"/></block></script></block><block s="doRun"><block s="reifyScript"><script><block s="doReport"><block s="reifyScript"><block var="body"/><block var="parameters"/></block></block></script><list><l>body</l></list></block><list><block var="body"/></list></block></script></block-definition><block-definition s="%&apos;function&apos; ( %&apos;arguments&apos; )" type="command" category="control"><header></header><code></code><translations></translations><inputs><input type="%s" readonly="true"><options>§_getVarNamesDict</options></input><input type="%mult%s"></input></inputs><script><block s="doIf"><block s="reportIsA"><block var="function"/><l><option>text</option></l></block><script><block s="doSetVar"><l>function</l><block s="reportApplyExtension"><l>var_get(name)</l><list><block var="function"/></list></block></block></script></block><block s="doCallCC"><block s="reifyScript"><script><block s="doSetVar"><l>return</l><block var="continuation"/></block><block s="doRun"><block var="function"/><block var="arguments"/></block></script><list><l>continuation</l></list></block></block></script></block-definition><block-definition s="%&apos;function&apos; ( %&apos;arguments&apos; ) $nl" type="reporter" category="control"><header></header><code></code><translations></translations><inputs><input type="%s" readonly="true"><options>§_getVarNamesDict</options></input><input type="%mult%s"></input></inputs><script><block s="doIf"><block s="reportIsA"><block var="function"/><l><option>text</option></l></block><script><block s="doSetVar"><l>function</l><block s="reportApplyExtension"><l>var_get(name)</l><list><block var="function"/></list></block></block></script></block><block s="doCallCC"><block s="reifyScript"><script><block s="doSetVar"><l>return</l><block var="continuation"/></block><block s="doReport"><block s="evaluate"><block var="function"/><block var="arguments"/></block></block></script><list><l>continuation</l></list></block></block></script></block-definition><block-definition s="list %&apos;vert&apos;" type="reporter" category="lists"><header></header><code></code><translations></translations><inputs><input type="%mult%cmdRing"></input></inputs><script><block s="doReport"><block var="vert"/></block></script></block-definition><block-definition s="function %&apos;func&apos; ( %&apos;parameters&apos; ) %&apos;body&apos;" type="command" category="control"><header></header><code></code><translations></translations><inputs><input type="%upvar" readonly="true"><options>§_getVarNamesDict</options></input><input type="%mult%t"></input><input type="%c"></input></inputs><script><block s="doApplyExtension"><l>var_declare(scope, name)</l><list><l>script</l><block var="func"/></list></block><block s="doApplyExtension"><l>var_set(name, val)</l><list><block var="func"/><block s="reifyScript"><block var="body"/><block var="parameters"/></block></list></block></script></block-definition><block-definition s="var %&apos;var&apos; = %&apos;val&apos;" type="command" category="other"><header></header><code></code><translations></translations><inputs><input type="%upvar"></input><input type="%s"></input></inputs><script><block s="doSetVar"><l>var</l><block var="val"/></block></script></block-definition><block-definition s="function %&apos;func&apos; ( %&apos;parameters&apos; ) %&apos;body&apos; $nl" type="reporter" category="control"><header></header><code></code><translations></translations><inputs><input type="%upvar"></input><input type="%mult%t"></input><input type="%c"></input></inputs><script><block s="doApplyExtension"><l>var_declare(scope, name)</l><list><l>script</l><block var="func"/></list></block><block s="doApplyExtension"><l>var_set(name, val)</l><list><block var="func"/><block s="reifyScript"><block var="body"/><block var="parameters"/></block></list></block><block s="doReport"><block var="func"/></block></script></block-definition><block-definition s="( %&apos;parameters&apos; ) =&gt; %&apos;body&apos;" type="reporter" category="control"><header></header><code></code><translations></translations><inputs><input type="%mult%t"></input><input type="%rc"></input></inputs><script><block s="doRun"><block s="reifyScript"><script><block s="doReport"><block s="reifyScript"><block var="body"/><block var="parameters"/></block></block></script><list><l>body</l></list></block><list><block var="body"/></list></block></script></block-definition><block-definition s="( %&apos;parameters&apos; ) =&gt; %&apos;body&apos;" type="reporter" category="control"><header></header><code></code><translations></translations><inputs><input type="%mult%t"></input><input type="%rr"></input></inputs><script><block s="doRun"><block s="reifyScript"><script><block s="doReport"><block s="reifyScript"><block var="body"/><block var="parameters"/></block></block></script><list><l>body</l></list></block><list><block var="body"/></list></block></script></block-definition><block-definition s="( %&apos;parameters&apos; ) =&gt; %&apos;body&apos;" type="reporter" category="control"><header></header><code></code><translations></translations><inputs><input type="%mult%t"></input><input type="%rp"></input></inputs><script><block s="doRun"><block s="reifyScript"><script><block s="doReport"><block s="reifyScript"><block var="body"/><block var="parameters"/></block></block></script><list><l>body</l></list></block><list><block var="body"/></list></block></script></block-definition><block-definition s="get %&apos;key&apos; of %&apos;arr&apos;" type="reporter" category="assoc"><header></header><code></code><translations></translations><inputs><input type="%s"></input><input type="%l"></input></inputs><script><block s="doWarp"><script><block s="doReport"><block s="reportListItem"><block s="reportListIndex"><block var="key"/><custom-block s="%l keys"><block var="arr"/></custom-block></block><custom-block s="%l values"><block var="arr"/></custom-block></block></block></script></block></script></block-definition><block-definition s="set %&apos;key&apos; of %&apos;arr&apos; to %&apos;val&apos;" type="command" category="assoc"><header></header><code></code><translations></translations><inputs><input type="%s"></input><input type="%l"></input><input type="%s"></input></inputs><script><block s="doWarp"><script><block s="doIfElse"><custom-block s="%l has %s"><block var="arr"/><block var="key"/></custom-block><script><block s="doReplaceInList"><block s="reportListIndex"><block var="key"/><custom-block s="%l keys"><block var="arr"/></custom-block></block><block var="arr"/><block s="reportNewList"><list><block var="key"/><block var="val"/></list></block></block></script><script><block s="doAddToList"><block s="reportNewList"><list><block var="key"/><block var="val"/></list></block><block var="arr"/></block></script></block></script></block></script></block-definition><block-definition s="%&apos;arr&apos; keys" type="reporter" category="assoc"><header></header><code></code><translations></translations><inputs><input type="%l"></input></inputs><script><block s="doReport"><block s="reportListItem"><l>1</l><block s="reportListAttribute"><l><option>columns</option></l><block var="arr"/></block></block></block></script></block-definition><block-definition s="%&apos;arr&apos; values" type="reporter" category="assoc"><header></header><code></code><translations></translations><inputs><input type="%l"></input></inputs><script><block s="doReport"><block s="reportListItem"><l>2</l><block s="reportListAttribute"><l><option>columns</option></l><block var="arr"/></block></block></block></script></block-definition><block-definition s="%&apos;arr&apos; has %&apos;key&apos;" type="predicate" category="assoc"><header></header><code></code><translations></translations><inputs><input type="%l"></input><input type="%s"></input></inputs><script><block s="doReport"><block s="reportListContainsItem"><custom-block s="%l keys"><block var="arr"/></custom-block><block var="key"/></block></block></script></block-definition><block-definition s="return" type="command" category="control"><header></header><code></code><translations></translations><inputs></inputs><script><block s="doRun"><block var="return"/><list></list></block></script></block-definition><block-definition s="# %&apos;code&apos;" type="reporter" category="other"><header></header><code></code><translations></translations><inputs><input type="%code"></input></inputs></block-definition><block-definition s="let %&apos;var&apos; = %&apos;val&apos;" type="command" category="other"><header></header><code></code><translations></translations><inputs><input type="%upvar"></input><input type="%s"></input></inputs><script><block s="doApplyExtension"><l>var_declare(scope, name)</l><list><l>script</l><block var="var"/></list></block><block s="doApplyExtension"><l>var_set(name, val)</l><list><block var="var"/><block var="val"/></list></block></script></block-definition><block-definition s="var %&apos;vars&apos;" type="command" category="other"><header></header><code></code><translations></translations><inputs><input type="%mult%upvar"></input></inputs><script><block s="doForEach"><l>var</l><block var="vars"/><script><block s="doApplyExtension"><l>var_declare(scope, name)</l><list><l>script</l><block var="var"/></list></block></script></block></script></block-definition><block-definition s="return %&apos;result&apos;" type="command" category="control"><header></header><code></code><translations></translations><inputs><input type="%s"></input></inputs><script><block s="doRun"><block s="reifyScript"><script><block s="doReport"><block var="result"/></block></script><list><l>result</l></list></block><list></list></block></script></block-definition><block-definition s="init" type="command" category="operators"><header></header><code></code><translations></translations><inputs></inputs><script><block s="doRun"><block s="reportJSFunction"><list></list><l>[&#xD;"function %s ( %mult%t ) %c",&#xD;"function ( %mult%t ) %c",&#xD;"function %upvar ( %mult%t ) %c",&#xD;"function %upvar ( %mult%t ) %c %br",&#xD;"( %mult%t ) =&gt; %rc",&#xD;"( %mult%t ) =&gt; %rr",&#xD;"( %mult%t ) =&gt; %rp",&#xD;].forEach(spec =&gt; {&#xD;&#xD;var def = this.globalBlocks.find(b =&gt; b.blockSpec() == spec);&#xD;&#xD;var setdfaults = function(block) {&#xD;    m = block.inputs()[&#xD;            Array.from(def.declarations)&#xD;            .findIndex(d =&gt; d[1][0] == &apos;%mult%t&apos;)&#xD;        ];&#xD;    if (block.parentThatIsA(ScriptsMorph) == null) m.collapseAll();&#xD;    m.addInput = function (contents) {&#xD;        var newPart = this.labelPart(this.slotSpec),&#xD;            i, name, idx;&#xD;&#xD;        idx = this.children.length - 1;&#xD;    &#xD;            name = &apos;&apos;;&#xD;            i = idx + 1;&#xD;            while (i &gt; 0) {&#xD;                name = String.fromCharCode(97 + (i - 1) % 26) + name;&#xD;                i = Math.floor((i - 1) / 26);&#xD;            }&#xD;            newPart.setContents(name);&#xD;    &#xD;        newPart.parent = this;&#xD;        this.children.splice(idx, 0, newPart);&#xD;        newPart.fixLayout();&#xD;        this.fixLayout();&#xD;        return newPart;&#xD;    };&#xD;}&#xD;&#xD;def.blockInstance = function (storeTranslations) {&#xD;    var block;&#xD;    if (this.type === &apos;command&apos;) {&#xD;        block = new CustomCommandBlockMorph(this);&#xD;    } else {&#xD;        block = new CustomReporterBlockMorph(&#xD;            this,&#xD;            this.type === &apos;predicate&apos;&#xD;        );&#xD;    }&#xD;    block.isDraggable = true;&#xD;    if (storeTranslations) { // only for "wishes"&#xD;    	block.storedTranslations = this.translationsAsText();&#xD;    }&#xD;    setdfaults(block, true);&#xD;    return block;&#xD;}&#xD;&#xD;this.allBlockInstances(this.globalBlocks.find(b =&gt; b.blockSpec() == spec)).forEach(setdfaults)&#xD;&#xD;});</l></block><list></list><comment w="141" collapsed="false">set parameter input defaults:&#xD;&#xD;start with none;&#xD;&#xD;follow the alphabet (like script vars)</comment></block><block s="doRun"><block s="reportJSFunction"><list></list><l>[&#xD;"%s ( %mult%s )",&#xD;"%s ( %mult%s ) %br", &#xD;].forEach(spec =&gt; {&#xD;&#xD;var def = this.globalBlocks.find(b =&gt; b.blockSpec() == spec);&#xD;&#xD;def.blockInstance = function (storeTranslations) {&#xD;    var block;&#xD;    if (this.type === &apos;command&apos;) {&#xD;        block = new CustomCommandBlockMorph(this);&#xD;    } else {&#xD;        block = new CustomReporterBlockMorph(&#xD;            this,&#xD;            this.type === &apos;predicate&apos;&#xD;        );&#xD;    }&#xD;    block.isDraggable = true;&#xD;    if (storeTranslations) { // only for "wishes"&#xD;    	block.storedTranslations = this.translationsAsText();&#xD;    }&#xD;    m = block.inputs()[&#xD;            Array.from(def.declarations)&#xD;            .findIndex(d =&gt; d[1][0] == &apos;%mult%s&apos;)&#xD;        ];&#xD;    m.collapseAll();&#xD;    return block;&#xD;}});</l></block><list></list><comment w="90" collapsed="false">set argument input defaults to start with none (only update new blocks + palette) </comment></block><block s="doRun"><block s="reportJSFunction"><list></list><l>[&#xD;"return",&#xD;"return %s", &#xD;].forEach(spec =&gt; {&#xD;&#xD;var def = this.globalBlocks.find(b =&gt; b.blockSpec() == spec);&#xD;&#xD;def.blockInstance = function (storeTranslations) {&#xD;    var block;&#xD;    if (this.type === &apos;command&apos;) {&#xD;        block = new CustomCommandBlockMorph(this);&#xD;    } else {&#xD;        block = new CustomReporterBlockMorph(&#xD;            this,&#xD;            this.type === &apos;predicate&apos;&#xD;        );&#xD;    }&#xD;    block.isDraggable = true;&#xD;    if (storeTranslations) { // only for "wishes"&#xD;    	block.storedTranslations = this.translationsAsText();&#xD;    }&#xD;    block.isStop = () =&gt; true;&#xD;    return block;&#xD;}&#xD;&#xD;this.allBlockInstances(this.globalBlocks.find(b =&gt; b.blockSpec() == spec)).forEach(r =&gt; r.isStop = () =&gt; true)&#xD;&#xD;});</l></block><list></list><comment w="90" collapsed="false">flat bottoms on return blocks (end of script)</comment></block><block s="doRun"><block s="reportJSFunction"><list></list><l>if (!this.globalVariables().silentFind(&apos;__return&apos;)) this.globalVariables().addVar(&apos;__return&apos;);&#xD;this.globalVariables().vars.__return.isHidden = true;</l></block><list></list><comment w="90" collapsed="false">create and hide global return variable (needed for continuations)</comment></block><block s="doRun"><block s="reportJSFunction"><list></list><l>this.parentThatIsA(IDE_Morph).flushBlocksCache();&#xD;this.parentThatIsA(IDE_Morph).refreshPalette();</l></block><list></list><comment w="90" collapsed="false">refresh palette</comment></block><block s="doRun"><block s="reportJSFunction"><list></list><l>RingMorph.prototype.contents = function () {&#xD;   try{return this.parts()[0].nestedBlock();} catch {return}&#xD;};</l></block><list></list><comment w="90" collapsed="false">guard against infinite loops</comment></block></script></block-definition></blocks><stage name="Stage" width="480" height="360" costume="0" color="255,255,255,1" tempo="60" threadsafe="false" penlog="false" volume="100" pan="0" lines="round" ternary="true" hyperops="true" codify="false" inheritance="true" sublistIDs="false" id="404"><pentrails>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAeAAAAFoCAYAAACPNyggAAAOhUlEQVR4Xu3VwQkAAAjEMN1/abewn7jAQRC64wgQIECAAIF3gX1fNEiAAAECBAiMAHsCAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQIHLFxAWmhEwHPAAAAAElFTkSuQmCC</pentrails><costumes><list struct="atomic" id="405"></list></costumes><sounds><list struct="atomic" id="406"></list></sounds><variables></variables><blocks></blocks><scripts><script x="20" y="10"><custom-block s="%s ( %mult%s ) %br"><l></l><list></list></custom-block></script><script x="20" y="43.999999999999886"><custom-block s="%s ( %mult%s )"><l></l><list></list></custom-block></script><script x="20" y="83.99999999999983"><custom-block s="function ( %mult%t ) %c"><list></list><script></script></custom-block></script><script x="20" y="135.83333333333331"><custom-block s="function %s ( %mult%t ) %c"><l></l><list></list><script></script></custom-block></script><script x="20" y="194.8333333333331"><custom-block s="function %upvar ( %mult%t ) %c %br"><l>func</l><list></list><script></script></custom-block></script><script x="20" y="254.6666666666668"><custom-block s="function %upvar ( %mult%t ) %c"><l>func</l><list></list><script></script></custom-block></script><script x="20" y="317.49999999999983"><custom-block s="( %mult%t ) =&gt; %rc"><list></list><script></script></custom-block></script><script x="20" y="348.4999999999997"><custom-block s="( %mult%t ) =&gt; %rr"><list></list><script></script></custom-block></script><script x="20" y="379.4999999999996"><custom-block s="( %mult%t ) =&gt; %rp"><list></list><script></script></custom-block></script><script x="20" y="446.3333333333321"><custom-block s="return %s"><l></l></custom-block></script><script x="20" y="412.4999999999998"><custom-block s="return"></custom-block></script></scripts><sprites select="1"><sprite name="Sprite" idx="1" x="2.274881516587584" y="-1.8100996894918069" heading="90" scale="1" volume="100" pan="0" rotation="1" draggable="true" costume="0" color="80,80,80,1" pen="tip" id="453"><costumes><list struct="atomic" id="454"></list></costumes><sounds><list struct="atomic" id="455"></list></sounds><blocks></blocks><variables></variables><scripts><script x="20" y="20"><block s="doTellTo"><l>Stage</l><block s="reifyScript"><script><custom-block s="init"><comment w="90" collapsed="false">recommended run this first, see inside for details</comment></custom-block></script><list></list></block><list></list></block></script></scripts></sprite><sprite name="Sprite(2)" idx="3" x="-139.72511848341287" y="-128.8100996894923" heading="90" scale="1" volume="100" pan="0" rotation="1" draggable="true" costume="0" color="181.04999999999998,119.49300000000001,0,1" pen="tip" id="470"><costumes><list struct="atomic" id="471"></list></costumes><sounds><list struct="atomic" id="472"></list></sounds><blocks></blocks><variables></variables><scripts><script x="25" y="10"><block s="doDeclareVariables"><list><l>add</l><l>sub</l><l>mul</l><l>div</l><l>exp</l></list></block><custom-block s="function %s ( %mult%t ) %c"><l>add</l><list><l>a</l><l>b</l></list><script><custom-block s="return %s"><block s="reportVariadicSum"><list><block var="a"/><block var="b"/></list></block></custom-block></script></custom-block><custom-block s="function %s ( %mult%t ) %c"><l>sub</l><list><l>a</l><l>b</l></list><script><custom-block s="return %s"><block s="reportDifference"><block var="a"/><block var="b"/></block></custom-block></script></custom-block><custom-block s="function %s ( %mult%t ) %c"><l>mul</l><list><l>a</l><l>b</l></list><script><custom-block s="return %s"><block s="reportVariadicProduct"><list><block var="a"/><block var="b"/></list></block></custom-block></script></custom-block><custom-block s="function %s ( %mult%t ) %c"><l>div</l><list><l>a</l><l>b</l></list><script><custom-block s="return %s"><block s="reportQuotient"><block var="a"/><block var="b"/></block></custom-block></script></custom-block><custom-block s="function %s ( %mult%t ) %c"><l>exp</l><list><l>a</l><l>b</l></list><script><custom-block s="return %s"><block s="reportPower"><block var="a"/><block var="b"/></block></custom-block></script></custom-block><block s="doReport"><custom-block s="list %mult%cmdRing"><list><custom-block s="%s ( %mult%s ) %br"><l>add</l><list><l>2</l><l>3</l></list></custom-block><custom-block s="%s ( %mult%s ) %br"><l>sub</l><list><l>2</l><l>3</l></list></custom-block><custom-block s="%s ( %mult%s ) %br"><l>mul</l><list><l>2</l><l>3</l></list></custom-block><custom-block s="%s ( %mult%s ) %br"><l>div</l><list><l>2</l><l>3</l></list></custom-block><custom-block s="%s ( %mult%s ) %br"><l>exp</l><list><l>2</l><l>3</l></list></custom-block></list></custom-block></block></script><script x="384" y="10.666666666666544"><block s="doDeclareVariables"><list><l>menu</l></list></block><block s="doSetVar"><l>menu</l><block s="reportNewList"><list></list></block></block><custom-block s="var %upvar = %s"><l>addItem</l><custom-block s="function ( %mult%t ) %c"><list><l>contents</l><l>action</l></list><script><block s="doAddToList"><block s="reportNewList"><list><block var="contents"/><block var="action"/></list></block><custom-block s="var %code"><l>menu</l></custom-block></block></script></custom-block></custom-block><custom-block s="%s ( %mult%s )"><l>addItem</l><list><l>one</l><custom-block s="function ( %mult%t ) %c"><list></list><script><block s="doSayFor"><l>one</l><l>1</l></block></script></custom-block></list></custom-block><custom-block s="%s ( %mult%s )"><l>addItem</l><list><l>two</l><custom-block s="function ( %mult%t ) %c"><list></list><script><block s="doSayFor"><l>two</l><l>2</l></block></script></custom-block></list></custom-block><custom-block s="%s ( %mult%s )"><l>addItem</l><list><l>three</l><custom-block s="function ( %mult%t ) %c"><list></list><script><block s="doSayFor"><l>three</l><l>3</l></block></script></custom-block></list></custom-block><block s="doReport"><block var="menu"/></block></script><script x="387" y="368"><custom-block s="%s ( %mult%s ) %br"><custom-block s="( %mult%t ) =&gt; %rc"><list><l>a</l></list><script><block s="doChangeVar"><l>a</l><l>1</l></block><block s="doReport"><block s="reportVariadicProduct"><list><block var="a"/><l>2</l></list></block></block></script></custom-block><list><l>3</l></list></custom-block></script><script x="388.6666650772095" y="442.83333333333314"><custom-block s="%s ( %mult%s ) %br"><custom-block s="( %mult%t ) =&gt; %rr"><list><l>a</l></list><autolambda><block s="reportVariadicSum"><list><block var="a"/><l>6</l></list></block></autolambda></custom-block><list><l>3</l></list></custom-block></script><script x="22" y="555.8333333333331"><custom-block s="var %upvar = %s"><l>summation</l><custom-block s="function ( %mult%t ) %c"><list><l>n</l></list><script><block s="doIf"><block s="reportGreaterThan"><block var="n"/><l>1</l></block><script><custom-block s="return %s"><block s="reportVariadicSum"><list><block var="n"/><custom-block s="%s ( %mult%s ) %br"><l>summation</l><list><block s="reportDifference"><block var="n"/><l>1</l></block></list></custom-block></list></block></custom-block></script></block><custom-block s="return %s"><block var="n"/></custom-block></script></custom-block></custom-block><block s="doReport"><custom-block s="%s ( %mult%s ) %br"><l>summation</l><list><l>5</l></list></custom-block></block></script><script x="23" y="731.6666666666666"><custom-block s="var %upvar = %s"><l>factorial</l><custom-block s="function ( %mult%t ) %c"><list><l>n</l></list><script><block s="doIf"><block s="reportGreaterThan"><block var="n"/><l>1</l></block><script><custom-block s="return %s"><block s="reportVariadicProduct"><list><block var="n"/><custom-block s="%s ( %mult%s ) %br"><l>factorial</l><list><block s="reportDifference"><block var="n"/><l>1</l></block></list></custom-block></list></block></custom-block></script></block><custom-block s="return %s"><block var="n"/></custom-block></script></custom-block></custom-block><block s="doReport"><custom-block s="%s ( %mult%s ) %br"><l>factorial</l><list><l>15</l></list></custom-block></block></script></scripts></sprite><sprite name="Sprite(3)" idx="4" x="139.27488151658645" y="153.18990031050828" heading="90" scale="1" volume="100" pan="0" rotation="1" draggable="true" costume="0" color="173.4,0,52.020000000000124,1" pen="tip" id="784"><costumes><list struct="atomic" id="785"></list></costumes><sounds><list struct="atomic" id="786"></list></sounds><blocks></blocks><variables></variables><scripts><script x="12" y="2191.6666666666606"><custom-block s="function %upvar ( %mult%t ) %c"><l>factorial</l><list><l>n</l></list><script><block s="doIfElse"><block s="reportOr"><block s="reportEquals"><block var="n"/><l>0</l></block><block s="reportEquals"><block var="n"/><l>1</l></block></block><script><custom-block s="return %s"><l>1</l></custom-block></script><script><custom-block s="return %s"><block s="reportVariadicProduct"><list><block var="n"/><custom-block s="%s ( %mult%s ) %br"><l>factorial</l><list><block s="reportDifference"><block var="n"/><l>1</l></block></list></custom-block></list></block></custom-block></script></block></script></custom-block><block s="doDeclareVariables"><list><l>a</l><l>b</l><l>c</l><l>d</l><l>e</l></list></block><block s="doSetVar"><l>a</l><custom-block s="%s ( %mult%s ) %br"><l>factorial</l><list><l>1</l></list></custom-block></block><block s="doSetVar"><l>b</l><custom-block s="%s ( %mult%s ) %br"><l>factorial</l><list><l>2</l></list></custom-block></block><block s="doSetVar"><l>c</l><custom-block s="%s ( %mult%s ) %br"><l>factorial</l><list><l>3</l></list></custom-block></block><block s="doSetVar"><l>d</l><custom-block s="%s ( %mult%s ) %br"><l>factorial</l><list><l>4</l></list></custom-block></block><block s="doSetVar"><l>e</l><custom-block s="%s ( %mult%s ) %br"><l>factorial</l><list><l>5</l></list></custom-block></block><block s="doReport"><custom-block s="list %mult%cmdRing"><list><block s="reportNewList"><list><l>a</l><block var="a"/></list></block><block s="reportNewList"><list><l>b</l><block var="b"/></list></block><block s="reportNewList"><list><l>c</l><block var="c"/></list></block><block s="reportNewList"><list><l>d</l><block var="d"/></list></block><block s="reportNewList"><list><l>e</l><block var="e"/></list></block></list></custom-block></block></script><script x="10" y="83"><custom-block s="function %upvar ( %mult%t ) %c"><l>square</l><list><l>number</l></list><script><custom-block s="return %s"><block s="reportVariadicProduct"><list><block var="number"/><block var="number"/></list></block></custom-block></script></custom-block><block s="doReport"><custom-block s="%s ( %mult%s ) %br"><l>square</l><list><l>5</l></list></custom-block></block></script><script x="325" y="83.80000000000018"><custom-block s="# %code"><l>function square(number) {&#xD;  return number * number;&#xD;}</l></custom-block></script><script x="350" y="340"><custom-block s="# %code"><l>function myFunc(theObject) {&#xD;  theObject.make = &apos;Toyota&apos;;&#xD;}&#xD;&#xD;var mycar = {make: &apos;Honda&apos;, model: &apos;Accord&apos;, year: 1998};&#xD;var x, y;&#xD;&#xD;x = mycar.make; // x gets the value "Honda"&#xD;&#xD;myFunc(mycar);&#xD;y = mycar.make; // y gets the value "Toyota"&#xD;                // (the make property was changed by the function)&#xD;</l></custom-block></script><script x="18" y="746.1666666666656"><custom-block s="var %upvar = %s"><l>square</l><custom-block s="function ( %mult%t ) %c"><list><l>number</l></list><script><custom-block s="return %s"><block s="reportVariadicProduct"><list><block var="number"/><block var="number"/></list></block></custom-block></script></custom-block></custom-block><custom-block s="var %upvar = %s"><l>x</l><custom-block s="%s ( %mult%s ) %br"><l>square</l><list><l>4</l></list></custom-block></custom-block><block s="doReport"><block var="x"/></block></script><script x="380" y="746.9999999999995"><custom-block s="# %code"><l>const square = function(number) { return number * number }&#xD;var x = square(4) // x gets the value 16&#xD;</l></custom-block></script><script x="17" y="984.3333333333321"><custom-block s="var %upvar = %s"><l>factorial</l><custom-block s="function %upvar ( %mult%t ) %c %br"><l>fac</l><list><l>n</l></list><script><custom-block s="return %s"><block s="reportIfElse"><block s="reportLessThan"><block var="n"/><l>2</l></block><l>1</l><block s="reportVariadicProduct"><list><block var="n"/><custom-block s="%s ( %mult%s ) %br"><l>fac</l><list><block s="reportDifference"><block var="n"/><l>1</l></block></list></custom-block></list></block></block></custom-block></script></custom-block></custom-block><block s="doReport"><custom-block s="%s ( %mult%s ) %br"><l>factorial</l><list><l>3</l></list></custom-block></block></script><script x="485" y="986"><custom-block s="# %code"><l>const factorial = function fac(n) { return n &lt; 2 ? 1 : n * fac(n - 1) }&#xD;&#xD;console.log(factorial(3))&#xD;</l></custom-block></script><script x="16" y="1321.6666666666683"><custom-block s="function %upvar ( %mult%t ) %c"><l>map</l><list><l>f</l><l>a</l></list><script><custom-block s="var %upvar = %s"><l>result</l><block s="reportNewList"><list></list></block></custom-block><custom-block s="var %mult%upvar"><list><l>i</l></list></custom-block><block s="doFor"><l>i</l><l>1</l><block s="reportListAttribute"><l><option>length</option></l><block var="a"/></block><script><block s="doInsertInList"><custom-block s="%s ( %mult%s ) %br"><l>f</l><list><block s="reportListItem"><block var="i"/><block var="a"/></block></list></custom-block><block var="i"/><block var="result"/></block></script></block><custom-block s="return %s"><block var="result"/></custom-block></script></custom-block><custom-block s="var %upvar = %s"><l>f</l><custom-block s="function ( %mult%t ) %c"><list><l>x</l></list><script><custom-block s="return %s"><block s="reportVariadicProduct"><list><block var="x"/><block var="x"/><block var="x"/></list></block></custom-block></script></custom-block></custom-block><custom-block s="var %upvar = %s"><l>numbers</l><block s="reportNewList"><list><l>0</l><l>1</l><l>2</l><l>5</l><l>10</l></list></block></custom-block><custom-block s="var %upvar = %s"><l>cube</l><custom-block s="%s ( %mult%s ) %br"><l>map</l><list><block var="f"/><block var="numbers"/></list></custom-block></custom-block><block s="doReport"><block var="cube"/></block></script><script x="395" y="1321.3333333333353"><custom-block s="# %code"><l>function map(f, a) {&#xD;  let result = []; // Create a new Array&#xD;  let i; // Declare variable&#xD;  for (i = 0; i != a.length; i++)&#xD;    result[i] = f(a[i]);&#xD;  return result;&#xD;}&#xD;const f = function(x) {&#xD;   return x * x * x;&#xD;}&#xD;let numbers = [0, 1, 2, 5, 10];&#xD;let cube = map(f,numbers);&#xD;console.log(cube);&#xD;</l></custom-block></script><script x="21" y="1833.5000000000014"><custom-block s="var %upvar = %s"><l>num</l><l>0</l></custom-block><block s="doDeclareVariables"><list><l>myFunc</l></list></block><block s="doIf"><block s="reportEquals"><block var="num"/><l>0</l></block><script><custom-block s="function %upvar ( %mult%t ) %c"><l>myFunc</l><list><l>theObject</l></list><script><custom-block s="set %s of %l to %s"><l>make</l><block var="theObject"/><l>Toyota</l></custom-block></script></custom-block></script></block><block s="doReport"><block var="myFunc"/></block></script><script x="367" y="1826.333333333328"><custom-block s="# %code"><l>var myFunc;&#xD;if (num === 0) {&#xD;  myFunc = function(theObject) {&#xD;    theObject.make = &apos;Toyota&apos;;&#xD;  }&#xD;}&#xD;</l></custom-block></script><script x="338" y="2190.3333333333258"><custom-block s="# %code"><l>function factorial(n) {&#xD;  if ((n === 0) || (n === 1))&#xD;    return 1;&#xD;  else&#xD;    return (n * factorial(n - 1));&#xD;}&#xD;&#xD;var a, b, c, d, e;&#xD;a = factorial(1); // a gets the value 1&#xD;b = factorial(2); // b gets the value 2&#xD;c = factorial(3); // c gets the value 6&#xD;d = factorial(4); // d gets the value 24&#xD;e = factorial(5); // e gets the value 120&#xD;</l></custom-block></script><script x="18" y="2821.499999999995"><custom-block s="var %upvar = %s"><l>num1</l><l>20</l></custom-block><custom-block s="var %upvar = %s"><l>num2</l><l>3</l></custom-block><custom-block s="var %upvar = %s"><l>name</l><l>Chamakh</l></custom-block><custom-block s="function %upvar ( %mult%t ) %c"><l>multiply</l><list></list><script><custom-block s="return %s"><block s="reportVariadicProduct"><list><custom-block s="var %code"><l>num1</l></custom-block><custom-block s="var %code"><l>num2</l></custom-block></list></block></custom-block></script></custom-block><custom-block s="function %upvar ( %mult%t ) %c"><l>getScore</l><list></list><script><custom-block s="let %upvar = %s"><l>num1</l><l>2</l><comment w="168" collapsed="false">local override ( doesnt work with regular vars , use extension blocks )</comment></custom-block><custom-block s="let %upvar = %s"><l>num2</l><l>3</l></custom-block><custom-block s="function %upvar ( %mult%t ) %c"><l>add</l><list></list><script><custom-block s="return %s"><block s="reportJoinWords"><list><custom-block s="var %code"><l>name</l></custom-block><l> scored </l><block s="reportVariadicSum"><list><custom-block s="var %code"><l>num1</l></custom-block><custom-block s="var %code"><l>num2</l></custom-block></list></block></list></block></custom-block></script></custom-block><custom-block s="return %s"><custom-block s="%s ( %mult%s ) %br"><l>add</l><list></list></custom-block></custom-block></script></custom-block><block s="doReport"><block s="reportNewList"><list><custom-block s="%s ( %mult%s ) %br"><l>multiply</l><list></list></custom-block><custom-block s="%s ( %mult%s ) %br"><l>getScore</l><list></list></custom-block></list></block></block></script><script x="472" y="2812.9999999999936"><custom-block s="# %code"><l>// The following variables are defined in the global scope&#xD;var num1 = 20,&#xD;    num2 = 3,&#xD;    name = &apos;Chamakh&apos;;&#xD;&#xD;// This function is defined in the global scope&#xD;function multiply() {&#xD;  return num1 * num2;&#xD;}&#xD;&#xD;multiply(); // Returns 60&#xD;&#xD;// A nested function example&#xD;function getScore() {&#xD;  var num1 = 2,&#xD;      num2 = 3;&#xD;&#xD;  function add() {&#xD;    return name + &apos; scored &apos; + (num1 + num2);&#xD;  }&#xD;&#xD;  return add();&#xD;}&#xD;&#xD;getScore(); // Returns "Chamakh scored 5"&#xD;</l></custom-block></script><script x="24" y="3379.333333333322"><custom-block s="function %upvar ( %mult%t ) %c"><l>loop</l><list><l>x</l></list><script><block s="doIf"><block s="reportGreaterThanOrEquals"><block var="x"/><l>10</l></block><script><custom-block s="return"></custom-block></script></block><block s="doSayFor"><block var="x"/><l>.25</l></block><custom-block s="%s ( %mult%s )"><l>loop</l><list><block s="reportVariadicSum"><list><block var="x"/><l>1</l></list></block></list></custom-block></script></custom-block><custom-block s="%s ( %mult%s )"><l>loop</l><list><l>0</l></list></custom-block></script><script x="300" y="3385.9999999999936"><custom-block s="# %code"><l>function loop(x) {&#xD;  if (x &gt;= 10) // "x &gt;= 10" is the exit condition (equivalent to "!(x &lt; 10)")&#xD;    return;&#xD;  // do stuff&#xD;  loop(x + 1); // the recursive call&#xD;}&#xD;loop(0);&#xD;</l></custom-block></script><script x="15" y="4237.333333333336"><custom-block s="function %upvar ( %mult%t ) %c"><l>addSquares</l><list></list><script><custom-block s="function %upvar ( %mult%t ) %c"><l>square</l><list></list><script><custom-block s="return %s"><block s="reportVariadicProduct"><list><block var="x"/><block var="x"/></list></block></custom-block></script></custom-block><custom-block s="return %s"><block s="reportVariadicSum"><list><custom-block s="%s ( %mult%s ) %br"><l>square</l><list><block var="a"/></list></custom-block><custom-block s="%s ( %mult%s ) %br"><l>square</l><list><block var="b"/></list></custom-block></list></block></custom-block></script></custom-block><custom-block s="var %upvar = %s"><l>a</l><custom-block s="%s ( %mult%s ) %br"><l>addSquares</l><list><l>2</l><l>3</l></list></custom-block></custom-block><custom-block s="var %upvar = %s"><l>b</l><custom-block s="%s ( %mult%s ) %br"><l>addSquares</l><list><l>3</l><l>4</l></list></custom-block></custom-block><custom-block s="var %upvar = %s"><l>c</l><custom-block s="%s ( %mult%s ) %br"><l>addSquares</l><list><l>4</l><l>5</l></list></custom-block></custom-block><block s="doReport"><custom-block s="list %mult%cmdRing"><list><block s="reportNewList"><list><l>a</l><block var="a"/></list></block><block s="reportNewList"><list><l>b</l><block var="b"/></list></block><block s="reportNewList"><list><l>c</l><block var="c"/></list></block></list></custom-block></block></script><script x="370" y="4231.333333333336"><custom-block s="# %code"><l>function addSquares(a, b) {&#xD;  function square(x) {&#xD;    return x * x;&#xD;  }&#xD;  return square(a) + square(b);&#xD;}&#xD;a = addSquares(2, 3); // returns 13&#xD;b = addSquares(3, 4); // returns 25&#xD;c = addSquares(4, 5); // returns 41&#xD;</l></custom-block></script><script x="299" y="3776.9999999999955"><custom-block s="# %code"><l>function foo(i) {&#xD;  if (i &lt; 0)&#xD;    return;&#xD;  console.log(&apos;begin: &apos; + i);&#xD;  foo(i - 1);&#xD;  console.log(&apos;end: &apos; + i);&#xD;}&#xD;foo(3);&#xD;&#xD;// Output:&#xD;&#xD;// begin: 3&#xD;// begin: 2&#xD;// begin: 1&#xD;// begin: 0&#xD;// end: 0&#xD;// end: 1&#xD;// end: 2&#xD;// end: 3&#xD;</l></custom-block></script><script x="19" y="347.66666666666606"><custom-block s="function %upvar ( %mult%t ) %c"><l>myFunc</l><list><l>theObject</l></list><script><custom-block s="set %s of %l to %s"><l>make</l><block var="theObject"/><l>Toyota</l></custom-block></script></custom-block><custom-block s="var %upvar = %s"><l>mycar</l><custom-block s="list %mult%cmdRing"><list><block s="reportNewList"><list><l>make</l><l>Honda</l></list></block><block s="reportNewList"><list><l>model</l><l>Accord</l></list></block><block s="reportNewList"><list><l>year</l><l>1998</l></list></block></list></custom-block></custom-block><custom-block s="var %mult%upvar"><list><l>x</l><l>y</l></list></custom-block><block s="doSetVar"><l>x</l><custom-block s="get %s of %l"><l>make</l><block var="mycar"/></custom-block></block><custom-block s="%s ( %mult%s )"><l>myFunc</l><list><block var="mycar"/></list></custom-block><block s="doSetVar"><l>y</l><custom-block s="get %s of %l"><l>make</l><block var="mycar"/></custom-block></block><block s="doReport"><block s="reportNewList"><list><block s="reportNewList"><list><l>x</l><block var="x"/></list></block><block s="reportNewList"><list><l>y</l><block var="y"/></list></block></list></block></block></script><script x="10" y="10"><custom-block s="# %code"><l>https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions</l></custom-block></script><script x="34" y="3788.49999999999"><custom-block s="function %upvar ( %mult%t ) %c"><l>foo</l><list><l>i</l></list><script><block s="doIf"><block s="reportLessThan"><block var="i"/><l>0</l></block><script><custom-block s="return"></custom-block></script></block><block s="doSayFor"><block s="reportJoinWords"><list><l>begin: </l><block var="i"/></list></block><l>.5</l></block><custom-block s="%s ( %mult%s )"><l>foo</l><list><block s="reportDifference"><block var="i"/><l>1</l></block></list></custom-block><block s="doSayFor"><block s="reportJoinWords"><list><l>end: </l><block var="i"/></list></block><l>.5</l></block></script></custom-block><custom-block s="%s ( %mult%s )"><l>foo</l><list><l>3</l></list></custom-block><block s="doReport"><block var="log"/></block></script></scripts></sprite><sprite name="Sprite(4)" idx="2" x="-6" y="-176" heading="90" scale="1" volume="100" pan="0" rotation="1" draggable="true" costume="0" color="0,0,0,1" pen="tip" id="1452"><costumes><list struct="atomic" id="1453"></list></costumes><sounds><list struct="atomic" id="1454"></list></sounds><blocks></blocks><variables></variables><scripts><script x="17" y="10"><custom-block s="function %s ( %mult%t ) %c"><l></l><list></list><script></script><comment w="164" collapsed="false">function assignment (to an already created variable; any scope)</comment></custom-block></script><script x="19" y="92.50000000000057"><custom-block s="function %upvar ( %mult%t ) %c"><l>func</l><list></list><script></script><comment w="127" collapsed="false">function declaration (run)</comment></custom-block></script><script x="21" y="157.6666666666672"><custom-block s="function %upvar ( %mult%t ) %c %br"><l>func</l><list></list><script></script><comment w="128" collapsed="false">function declaration (call)</comment></custom-block></script><script x="23" y="226.00000000000006"><custom-block s="function ( %mult%t ) %c"><list></list><script></script><comment w="159" collapsed="false">function expression (anonymous)</comment></custom-block></script><script x="25" y="302.5000000000007"><custom-block s="%s ( %mult%s )"><l></l><list></list><comment w="121" collapsed="false">function invocation (run)</comment></custom-block></script><script x="27" y="366.5000000000007"><custom-block s="%s ( %mult%s ) %br"><l></l><list></list><comment w="121" collapsed="false">function invocation (call)</comment></custom-block></script><script x="34" y="456.1666666666672"><custom-block s="( %mult%t ) =&gt; %rc"><list></list><script></script></custom-block></script><script x="32" y="481.1666666666672"><custom-block s="( %mult%t ) =&gt; %rr"><list></list><script></script></custom-block></script><script x="32" y="505.1666666666672"><custom-block s="( %mult%t ) =&gt; %rp"><list></list><script></script></custom-block></script><comment x="132" y="455" w="80" collapsed="false">lambdas</comment><script x="39" y="596.0000000000002"><custom-block s="return %s"><l></l></custom-block></script><script x="39" y="570.1666666666672"><custom-block s="return"></custom-block></script><comment x="110.3499984741211" y="571.1666666666672" w="89" collapsed="false">return (duh, stop &apos;functioning&apos; and resume &apos;scripting&apos;, optoionally bring back a value)</comment><script x="447" y="549"><custom-block s="%s ( %mult%s ) %br"><custom-block s="function ( %mult%t ) %c"><list></list><script><block s="doGotoObject"><l><option>random position</option></l></block><custom-block s="return %s"><block s="xPosition"></block></custom-block></script></custom-block><list></list><comment w="80" collapsed="true">IIFE</comment></custom-block></script></scripts></sprite><watcher var="return" style="normal" x="1.36677358570455" y="1.3667735857046068" color="243,118,29" hidden="true"/></sprites></stage><variables><variable name="return" hidden="true"><l>0</l></variable><variable name="__return" hidden="true"><l>0</l></variable><variable name="globalFunc"><context id="1516"><inputs><input>a</input><input>b</input></inputs><variables></variables><script><block s="doSayFor"><block s="reportJoinWords"><list><block var="a"/><l> + </l><block var="b"/><l> = </l><block s="reportVariadicSum"><list><block var="a"/><block var="b"/></list></block></list></block><l>2</l></block></script><receiver><ref id="1452"></ref></receiver><origin><ref id="1452"></ref></origin><context id="1535"><inputs></inputs><variables><variable name="func"><l>globalFunc</l></variable><variable name="parameters"><list struct="atomic" id="1537">a,b</list></variable><variable name="body"/></variables><receiver><ref id="1452"></ref></receiver><origin></origin></context></context></variable></variables></scene></scenes></project><media name="functions" app="Snap! 7, https://snap.berkeley.edu" version="2"></media></snapdata>