<snapdata remixID="9157153"><project name="MidtermExam" app="Snap! 5.4, http://snap.berkeley.edu" version="1"><notes></notes><thumbnail>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAB4CAYAAAB1ovlvAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAG2SURBVHhe7dcxakJBFEDRMS5FcD8WVu7GvQiCtdsR3IYIxoRfSMAETMJtzmn+m6kvf2Zmt7sBkbfpCwkBkhIgKQGSEiApAZISICkBkhIgKQGSEiApAZISICkBkhIgKQGSEiApAZISICkBkhIgKQGSEiApAZISICkBkhIgKQGSEiApAZISICkBkhIgKQGSEiApAZISICkBkhIgKQGSEiApAZISICkBkhIgKQGSEiApAZISICkBkhIgKQGSEiApAZISICkBkhLgE4vFYux2u2nFf5nd7qaZL1ar1TSNcTqdxuFwGMvlctrhLwjwB48RPrpcLuN4PE4rXuUIfsF8Pp8mfssf8Bvr9Xpcr9fP+Xw+j/1+7wj+YwJ84uMRst1ux2azmXb4DwIk5Q5ISoCkBEhKgKQESEqApARISoCkBEhKgKQESEqApARISoCkBEhKgKQESEqApARISoCkBEhKgKQESEqApARISoCkBEhKgKQESEqApARISoCkBEhKgKQESEqApARISoCkBEhKgKQESEqApARISoCkBEhKgKQESEqApARISoCkBEhKgKQESEqApARISoCExngHa3czNKhQh4YAAAAASUVORK5CYII=</thumbnail><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" codify="false" inheritance="false" sublistIDs="false" scheduled="false" id="1"><pentrails>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAeAAAAFoCAYAAACPNyggAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAK1SURBVHhe7cExAQAAAMKg9U9tDB8gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgIsajf4AAXBXLv8AAAAASUVORK5CYII=</pentrails><costumes><list struct="atomic" id="2"></list></costumes><sounds><list struct="atomic" id="3"></list></sounds><variables></variables><blocks></blocks><scripts></scripts><sprites><sprite name="Sprite" idx="1" x="0" y="0" heading="90" scale="1" volume="100" pan="0" rotation="1" draggable="true" costume="0" color="80,80,80,1" pen="tip" id="8"><costumes><list struct="atomic" id="9"></list></costumes><sounds><list struct="atomic" id="10"></list></sounds><blocks></blocks><variables></variables><scripts><comment x="22" y="10" w="457" collapsed="false">1. Write your own version of the SNAP &quot;contains&quot; block, which takes a list and avalue as arguments and reports true if the value is anywhere in the list and reports false otherwise.  &#xD;&#xD;You should NOT use the existing &quot;contains&quot; block in your implementation.</comment><comment x="22" y="325" w="457" collapsed="false">2. Write a custom block called &quot;index of&quot; that takes a list and a value as arguments and reports the index at which the value is found in the list, if it is there.  If the value is not present anywhere in the list, report -1.</comment><script x="22" y="421"><custom-block s="run test suite %l"><custom-block s="make test suite %mult%l"><list><custom-block s="make test (index of %s in %l ) = %n"><l>foo</l><block s="reportNewList"><list></list></block><l>-1</l></custom-block><custom-block s="make test (index of %s in %l ) = %n"><l>foo</l><block s="reportNewList"><list><l>foo</l></list></block><l>1</l></custom-block><custom-block s="make test (index of %s in %l ) = %n"><l>foo</l><block s="reportNewList"><list><l>bar</l></list></block><l>-1</l></custom-block><custom-block s="make test (index of %s in %l ) = %n"><l>foo</l><block s="reportNewList"><list><l>foo</l><l>bar</l><l>baz</l></list></block><l>1</l></custom-block><custom-block s="make test (index of %s in %l ) = %n"><l>bar</l><block s="reportNewList"><list><l>foo</l><l>bar</l><l>baz</l></list></block><l>2</l></custom-block><custom-block s="make test (index of %s in %l ) = %n"><l>baz</l><block s="reportNewList"><list><l>foo</l><l>bar</l><l>baz</l></list></block><l>3</l></custom-block><custom-block s="make test (index of %s in %l ) = %n"><l>quuz</l><block s="reportNewList"><list><l>foo</l><l>bar</l><l>baz</l></list></block><l>-1</l></custom-block></list></custom-block></custom-block><block s="doReport"><l>Tests pass</l></block></script><comment x="22" y="636" w="457" collapsed="false">3. Write a custom block called &quot;first e-word&quot; that takes a list as an argument and reports the first word in the list that starts with the letter &apos;e&apos;.  If no such word exists, report a blank (nothing).</comment><script x="22" y="695"><custom-block s="first e-word of %l"><l/><comment w="90" collapsed="true">Implement me</comment></custom-block></script><script x="22" y="721"><custom-block s="run test suite %l"><custom-block s="make test suite %mult%l"><list><custom-block s="make test (first e-word of %l ) = %s"><block s="reportNewList"><list></list></block><l></l></custom-block><custom-block s="make test (first e-word of %l ) = %s"><block s="reportNewList"><list><l>foo</l></list></block><l></l></custom-block><custom-block s="make test (first e-word of %l ) = %s"><block s="reportNewList"><list><l>foo</l><l>bar</l><l>baz</l></list></block><l></l></custom-block><custom-block s="make test (first e-word of %l ) = %s"><block s="reportNewList"><list><l>eFoo</l><l>bar</l><l>baz</l></list></block><l>eFoo</l></custom-block><custom-block s="make test (first e-word of %l ) = %s"><block s="reportNewList"><list><l>foo</l><l>eBar</l><l>baz</l></list></block><l>eBar</l></custom-block><custom-block s="make test (first e-word of %l ) = %s"><block s="reportNewList"><list><l>foo</l><l>bar</l><l>eBaz</l></list></block><l>eBaz</l></custom-block><custom-block s="make test (first e-word of %l ) = %s"><block s="reportNewList"><list><l>eFoo</l><l>bar</l><l>eBaz</l></list></block><l>eFoo</l></custom-block><custom-block s="make test (first e-word of %l ) = %s"><block s="reportNewList"><list><l>foo</l><l>eBar</l><l>eBaz</l></list></block><l>eBar</l></custom-block></list></custom-block></custom-block><block s="doReport"><l>Tests pass</l></block></script><comment x="22" y="958" w="457" collapsed="false">4. BONUS: Write a custom block called &quot;first word that starts with&quot; that takes a list and a letter as arguments, and reports the first word in the list that starts with the given letter.  If no such word exists, report a blank (nothing).</comment><script x="22" y="1032"><custom-block s="first word of %l that starts with %s"><l/><l></l><comment w="90" collapsed="true">Implement me</comment></custom-block></script><script x="22" y="1060"><custom-block s="run test suite %l"><custom-block s="make test suite %mult%l"><list><custom-block s="make test (first word of %l that starts with %s ) = %s"><block s="reportNewList"><list></list></block><l>q</l><l></l></custom-block><custom-block s="make test (first word of %l that starts with %s ) = %s"><block s="reportNewList"><list><l>foo</l></list></block><l>q</l><l></l></custom-block><custom-block s="make test (first word of %l that starts with %s ) = %s"><block s="reportNewList"><list><l>foo</l><l>bar</l><l>baz</l></list></block><l>q</l><l></l></custom-block><custom-block s="make test (first word of %l that starts with %s ) = %s"><block s="reportNewList"><list><l>foo</l><l>bar</l><l>baz</l></list></block><l>f</l><l>foo</l></custom-block><custom-block s="make test (first word of %l that starts with %s ) = %s"><block s="reportNewList"><list><l>foo</l><l>bar</l><l>baz</l></list></block><l>b</l><l>bar</l></custom-block><custom-block s="make test (first word of %l that starts with %s ) = %s"><block s="reportNewList"><list><l>foo</l><l>bar</l><l>baz</l><l>quux</l></list></block><l>q</l><l>quux</l></custom-block></list></custom-block></custom-block><block s="doReport"><l>Tests pass</l></block></script><script x="23" y="397"><custom-block s="index of %s in %l"><l></l><l/><comment w="90" collapsed="true">Implement me</comment></custom-block></script><script x="25" y="121.80000000000001"><custom-block s="run test suite %l"><custom-block s="make test suite %mult%l"><list><custom-block s="make test &lt; %s is in %l ?&gt; = %b"><l>foo</l><block s="reportNewList"><list></list></block><l><bool>false</bool></l></custom-block><custom-block s="make test &lt; %s is in %l ?&gt; = %b"><l>foo</l><block s="reportNewList"><list><l>foo</l></list></block><l><bool>true</bool></l></custom-block><custom-block s="make test &lt; %s is in %l ?&gt; = %b"><l>foo</l><block s="reportNewList"><list><l>bar</l></list></block><l><bool>false</bool></l></custom-block><custom-block s="make test &lt; %s is in %l ?&gt; = %b"><l>foo</l><block s="reportNewList"><list><l>foo</l><l>bar</l><l>baz</l></list></block><l><bool>true</bool></l></custom-block><custom-block s="make test &lt; %s is in %l ?&gt; = %b"><l>bar</l><block s="reportNewList"><list><l>foo</l><l>bar</l><l>baz</l></list></block><l><bool>true</bool></l></custom-block><custom-block s="make test &lt; %s is in %l ?&gt; = %b"><l>baz</l><block s="reportNewList"><list><l>foo</l><l>bar</l><l>baz</l></list></block><l><bool>true</bool></l></custom-block><custom-block s="make test &lt; %s is in %l ?&gt; = %b"><l>quuz</l><block s="reportNewList"><list><l>foo</l><l>bar</l><l>baz</l></list></block><l><bool>false</bool></l></custom-block></list></custom-block></custom-block><block s="doReport"><l>Tests pass</l></block></script><script x="46.64000086648559" y="92.80000099999984"><custom-block s="%s is in %l ?"><l></l><l/><comment w="90" collapsed="true">Implement me</comment></custom-block></script><script x="515" y="138"><block s="receiveKey"><l><option>1</option></l></block><block s="doSayFor"><custom-block s="%l contains %s"><block s="reportNewList"><list><l>Jah</l><l>bruh</l><l>moment</l><l>idk</l><l>dude</l></list></block><l>Jah</l></custom-block><l>2</l></block></script><script x="536" y="450"><block s="receiveKey"><l><option>2</option></l></block><block s="doSayFor"><custom-block s="%l index of"><block s="reportNewList"><list><l>a</l><l>b</l><l>c</l><l>d</l><l>e</l><l>f</l><l>g</l></list></block></custom-block><l>2</l></block></script><script x="537" y="756"><block s="receiveKey"><l><option>3</option></l></block><block s="doSayFor"><custom-block s="%l first E-word"><block s="reportNewList"><list><l>foo</l><l>bar</l><l>eFoo</l><l>baz</l><l>eBar</l><l>eBaz</l></list></block></custom-block><l>2</l></block></script><script x="507" y="1069"><block s="receiveKey"><l><option>4</option></l></block><block s="doSayFor"><custom-block s="%l first word that starts with %s"><block s="reportNewList"><list><l>Jah</l><l>Bruh</l><l>Moment</l><l>idk</l><l>dude</l></list></block><l>b</l></custom-block><l>2</l></block></script></scripts></sprite></sprites></stage><hidden></hidden><headers></headers><code></code><blocks><block-definition s="%&apos;item&apos; is in %&apos;list&apos; ?" type="predicate" category="lists"><header></header><code></code><translations></translations><inputs><input type="%s"></input><input type="%l"></input></inputs><script><block s="doReport"><l>Not implemented</l></block></script></block-definition><block-definition s="index of %&apos;item&apos; in %&apos;list&apos;" type="reporter" category="lists"><header></header><code></code><translations></translations><inputs><input type="%s"></input><input type="%l"></input></inputs><script><block s="doReport"><l>Not implemented</l></block></script></block-definition><block-definition s="first e-word of %&apos;list&apos;" type="reporter" category="lists"><header></header><code></code><translations></translations><inputs><input type="%l"></input></inputs><script><block s="doReport"><l>Not implemented</l></block></script></block-definition><block-definition s="first word of %&apos;list&apos; that starts with %&apos;letter&apos;" type="reporter" category="lists"><header></header><code></code><translations></translations><inputs><input type="%l"></input><input type="%s"></input></inputs><script><block s="doReport"><l>Not implemented</l></block></script></block-definition><block-definition s="safely try %&apos;action&apos; then if %&apos;error&apos; %&apos;handler&apos;" type="command" category="control"><header></header><code></code><translations></translations><inputs><input type="%cs"></input><input type="%upvar"></input><input type="%cs"></input></inputs><script><custom-block s="let %upvar be %s"><l>reset</l><block s="evaluate"><block s="reportJSFunction"><list><l>proc</l></list><l>var oldHandleError = proc.handleError,&#xD;    oldCatchingErrors = proc.isCatchingErrors;&#xD;&#xD;return function(){&#xD; proc.handleError = oldHandleError;&#xD; proc.isCatchingErrors = oldCatchingErrors;&#xD;}</l></block><list></list></block></custom-block><block s="doCallCC"><block s="reifyScript"><script><block s="doRun"><block s="reportJSFunction"><list><l>reset</l><l>action</l><l>handler</l><l>proc</l></list><l>proc.isCatchingErrors = true;&#xD;proc.handleError = function(error, element){&#xD; reset();&#xD; proc.context = handler;&#xD; proc.context.variables.setVar("error", error);&#xD;}&#xD;&#xD;try{&#xD; proc.evaluate(action, new List(), true);&#xD;}&#xD;catch(e){&#xD; proc.handleError(e, null);&#xD;} </l></block><list><block var="reset"/><block var="action"/><block s="reifyScript"><script><block s="doRun"><block s="reifyScript"><script><block s="doRun"><block var="handler"/><list></list></block><block s="doRun"><block var="return"/><list></list></block></script><list></list></block><list></list></block></script><list></list></block></list></block></script><list><l>return</l></list></block></block><block s="doRun"><block var="reset"/><list></list></block></script></block-definition><block-definition s="error %&apos;msg&apos;" type="command" category="control"><header></header><code></code><translations></translations><inputs><input type="%txt"></input></inputs><script><block s="doRun"><block s="reportJSFunction"><list><l>msg</l></list><l>throw new Error(msg);</l></block><list><block var="msg"/></list></block></script></block-definition><block-definition s="let %&apos;var&apos; be %&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="run test suite %&apos;suite&apos;" type="command" category="other"><comment x="0" y="0" w="262" collapsed="false">Runs the tests in the given suite and throws an error if any fail.&#xD;&#xD;If the this block finished without error, then all tests passed.&#xD;&#xD;Use (make test suite ...) to build a test quite.&#xD;&#xD;Enables strict list bounds checking before running.</comment><header></header><code></code><translations></translations><inputs><input type="%l"></input></inputs><script><custom-block s="set strict lists %b"><l><bool>true</bool></l></custom-block><custom-block s="let %upvar be %s"><l>index</l><l>1</l></custom-block><block s="doRepeat"><block s="reportListLength"><block var="suite"/></block><script><custom-block s="run test %l"><block s="reportListItem"><block var="index"/><block var="suite"/></block></custom-block><block s="doChangeVar"><l>index</l><l>1</l></block></script></block></script></block-definition><block-definition s="run test %&apos;test&apos;" type="command" category="other"><comment x="0" y="0" w="243" collapsed="false">Run a single test.&#xD;&#xD;If this block completes without error, then the test passed, otherwise this block will throw an error that includes:&#xD;- a description of the test&#xD;- the expected result&#xD;- the actual result&#xD;&#xD;Use (make test ...) to create a test.</comment><header></header><code></code><translations></translations><inputs><input type="%l"></input></inputs><script><custom-block s="unpack test %l $arrowRight %upvar %upvar %upvar"><block var="test"/><l>expr</l><l>expected</l><l>desc</l></custom-block><block s="doDeclareVariables"><list><l>result</l></list></block><custom-block s="safely try %cs then if %upvar %cs"><script><block s="doSetVar"><l>result</l><block s="evaluate"><block var="expr"/><list></list></block></block></script><l>error</l><script><block s="doSetVar"><l>result</l><block var="error"/></block></script></custom-block><block s="doIf"><block s="reportNot"><block s="reportEquals"><block var="result"/><block var="expected"/></block></block><script><block s="doIf"><block s="reportIsA"><block var="expected"/><l><option>list</option></l></block><script><block s="doSetVar"><l>expected</l><custom-block s="list %l $arrowRight text"><block var="expected"/></custom-block></block></script></block><block s="doIf"><block s="reportIsA"><block var="result"/><l><option>list</option></l></block><script><block s="doSetVar"><l>result</l><custom-block s="list %l $arrowRight text"><block var="result"/></custom-block></block></script></block><custom-block s="error %txt"><block s="reportJoinWords"><list><l>Test case </l><block var="desc"/><l> expected </l><block var="expected"/><l> but got </l><block var="result"/></list></block></custom-block></script></block></script></block-definition><block-definition s="make test expr: %&apos;expr&apos; expected: %&apos;expected&apos; description: %&apos;desc&apos;" type="reporter" category="other"><comment x="0" y="0" w="330" collapsed="false">Create a test.&#xD;&#xD;expr - an unevaluated expression to be evaluated when the test is run&#xD;&#xD;expected - the expected result of evaluating expr&#xD;&#xD;description - a text string to identify the test</comment><header></header><code></code><translations></translations><inputs><input type="%anyUE"></input><input type="%s"></input><input type="%txt"></input></inputs><script><block s="doReport"><block s="reportNewList"><list><l>test-case</l><block var="expr"/><block var="expected"/><block var="desc"/></list></block></block></script></block-definition><block-definition s="make test suite %&apos;tests&apos;" type="reporter" category="other"><comment x="0" y="0" w="310" collapsed="false">Create a test suite from one or more tests.&#xD;&#xD;Use (make test ...) to create tests.</comment><header></header><code></code><translations></translations><inputs><input type="%mult%l"></input></inputs><script><block s="doReport"><block var="tests"/></block></script></block-definition><block-definition s="test case? %&apos;obj&apos;" type="predicate" category="other"><comment x="0" y="0" w="243" collapsed="true">Check if the given object is a test case.</comment><header></header><code></code><translations></translations><inputs><input type="%s"></input></inputs><script><block s="doReport"><block s="reportAnd"><block s="reportIsA"><block var="obj"/><l><option>list</option></l></block><block s="reportEquals"><block s="reportListItem"><l>1</l><block var="obj"/></block><l>test-case</l></block></block></block></script></block-definition><block-definition s="unpack test %&apos;test&apos; $arrowRight %&apos;expr&apos; %&apos;expected&apos; %&apos;desc&apos;" type="command" category="other"><comment x="0" y="0" w="256" collapsed="false">Populate the given variables with the contents of the given test case.</comment><header></header><code></code><translations></translations><inputs><input type="%l"></input><input type="%upvar"></input><input type="%upvar"></input><input type="%upvar"></input></inputs><script><block s="doIf"><block s="reportNot"><custom-block s="test case? %s"><block var="test"/></custom-block></block><script><custom-block s="error %txt"><block s="reportJoinWords"><list><l>expected a test case, but got </l><block var="test"/></list></block></custom-block></script></block><block s="doSetVar"><l>expr</l><block s="reportListItem"><l>2</l><block var="test"/></block></block><block s="doSetVar"><l>expected</l><block s="reportListItem"><l>3</l><block var="test"/></block></block><block s="doSetVar"><l>desc</l><block s="reportListItem"><l>4</l><block var="test"/></block></block></script></block-definition><block-definition s="list %&apos;list&apos; $arrowRight text" type="reporter" category="lists"><comment x="0" y="0" w="312" collapsed="false">Convert a list (of numbers) to a text string of the form (list 1 2 ...)</comment><header></header><code></code><translations></translations><inputs><input type="%l"></input></inputs><script><block s="doReport"><block s="reportJoinWords"><list><l>(list </l><custom-block s="join %l with %txt"><block var="list"/><l> </l></custom-block><l>)</l></list></block></block></script></block-definition><block-definition s="join %&apos;list&apos; with %&apos;delimiter&apos;" type="reporter" category="lists"><comment x="0" y="0" w="187" collapsed="false">Convert a list to a text string with each item separated by the given delimiter.</comment><header></header><code></code><translations></translations><inputs><input type="%l"></input><input type="%txt"></input></inputs><script><block s="doIfElse"><block s="reportEquals"><block var="list"/><block s="reportNewList"><list></list></block></block><script><block s="doReport"><l></l></block></script><script><block s="doIfElse"><block s="reportEquals"><block s="reportListLength"><block var="list"/></block><l>1</l></block><script><block s="doReport"><block s="reportListItem"><l>1</l><block var="list"/></block></block></script><script><block s="doReport"><block s="reportJoinWords"><list><block s="reportListItem"><l>1</l><block var="list"/></block><block var="delimiter"/><custom-block s="join %l with %txt"><block s="reportCDR"><block var="list"/></block><block var="delimiter"/></custom-block></list></block></block></script></block></script></block></script></block-definition><block-definition s="set strict lists %&apos;value&apos;" type="command" category="lists"><comment x="0" y="0" w="324" collapsed="true">Enable (or disable) strict bounds checking on list operations.</comment><header></header><code></code><translations></translations><inputs><input type="%b"></input></inputs><script><block s="doRun"><block s="reportJSFunction"><list><l>value</l></list><l>if (value) {&#xD;  if (!Process.prototype.reportListItem_orig) Process.prototype.reportListItem_orig = Process.prototype.reportListItem;&#xD;  if (!Process.prototype.doDeleteFromList_orig) Process.prototype.doDeleteFromList_orig = Process.prototype.doDeleteFromList;&#xD;  if (!Process.prototype.doInsertInList_orig) Process.prototype.doInsertInList_orig = Process.prototype.doInsertInList;&#xD;  if (!Process.prototype.doReplaceInList_orig) Process.prototype.doReplaceInList_orig = Process.prototype.doReplaceInList;&#xD;&#xD;  Process.prototype.reportListItem = function (index, list) {&#xD;&#xD;&#xD;    var idx = index;&#xD;&#xD;&#xD;    // this.assertType(list, &apos;list&apos;);&#xD;&#xD;&#xD;    if (index === &apos;&apos;) {&#xD;&#xD;&#xD;        return &apos;&apos;;&#xD;&#xD;&#xD;    }&#xD;&#xD;&#xD;    if (this.inputOption(index) === &apos;any&apos;) {&#xD;&#xD;&#xD;        idx = this.reportRandom(1, list.length());&#xD;&#xD;&#xD;    }&#xD;&#xD;&#xD;    if (this.inputOption(index) === &apos;last&apos;) {&#xD;&#xD;&#xD;        idx = list.length();&#xD;&#xD;&#xD;    }&#xD;&#xD;&#xD;    if (index &lt; 1) throw new Error("&apos;item&apos; expected a positive list index, but got "+index);&#xD;&#xD;&#xD;    if (index &gt; list.length()) throw new Error("&apos;item&apos; expected a list index less than "+(list.length()+1)+", but got "+index);&#xD;&#xD;&#xD;    return list.at(idx);&#xD;&#xD;&#xD;  };&#xD;  Process.prototype.doDeleteFromList = function (index, list) {&#xD;&#xD;&#xD;    var idx = index;&#xD;&#xD;&#xD;    // this.assertType(list, &apos;list&apos;);&#xD;&#xD;&#xD;    if (this.inputOption(index) === &apos;all&apos;) {&#xD;&#xD;&#xD;        return list.clear();&#xD;&#xD;&#xD;    }&#xD;&#xD;&#xD;    if (index === &apos;&apos;) {&#xD;&#xD;&#xD;        return null;&#xD;&#xD;&#xD;    }&#xD;&#xD;&#xD;    if (this.inputOption(index) === &apos;last&apos;) {&#xD;&#xD;&#xD;        idx = list.length();&#xD;&#xD;&#xD;    } else if (isNaN(+this.inputOption(index))) {&#xD;&#xD;&#xD;        return null;&#xD;&#xD;&#xD;    }&#xD;&#xD;&#xD;    if (index &lt; 1) throw new Error("&apos;delete&apos; expected a positive list index, but got "+index);&#xD;&#xD;&#xD;    if (index &gt; list.length()) throw new Error("&apos;delete&apos; expected a list index less than "+(list.length()+1)+", but got "+index);&#xD;&#xD;&#xD;    list.remove(idx);&#xD;&#xD;&#xD;  };&#xD;&#xD;&#xD;  Process.prototype.doInsertInList = function (element, index, list) {&#xD;&#xD;&#xD;    var idx = index;&#xD;&#xD;&#xD;    // this.assertType(list, &apos;list&apos;);&#xD;&#xD;&#xD;    if (index === &apos;&apos;) {&#xD;&#xD;&#xD;        return null;&#xD;&#xD;&#xD;    }&#xD;&#xD;&#xD;    if (this.inputOption(index) === &apos;any&apos;) {&#xD;&#xD;&#xD;        idx = this.reportRandom(1, list.length() + 1);&#xD;&#xD;&#xD;    }&#xD;&#xD;&#xD;    if (this.inputOption(index) === &apos;last&apos;) {&#xD;&#xD;&#xD;        idx = list.length() + 1;&#xD;&#xD;&#xD;    }&#xD;&#xD;&#xD;    if (index &lt; 1) throw new Error("&apos;add&apos; expected a positive list index, but got "+index);&#xD;&#xD;&#xD;    if (index &gt; list.length()+1) throw new Error("&apos;add&apos; expected a list index less than "+(list.length()+2)+", but got "+index);&#xD;&#xD;&#xD;    list.add(element, idx);&#xD;&#xD;&#xD;  };&#xD;  Process.prototype.doReplaceInList = function (index, list, element) {&#xD;&#xD;&#xD;    var idx = index;&#xD;&#xD;&#xD;    // this.assertType(list, &apos;list&apos;);&#xD;&#xD;&#xD;    if (index === &apos;&apos;) {&#xD;&#xD;&#xD;        return null;&#xD;&#xD;&#xD;    }&#xD;&#xD;&#xD;    if (this.inputOption(index) === &apos;any&apos;) {&#xD;&#xD;&#xD;        idx = this.reportRandom(1, list.length());&#xD;&#xD;&#xD;    }&#xD;&#xD;&#xD;    if (this.inputOption(index) === &apos;last&apos;) {&#xD;&#xD;&#xD;        idx = list.length();&#xD;&#xD;&#xD;    }&#xD;&#xD;&#xD;    if (index &lt; 1) throw new Error("&apos;replace&apos; expected a positive list index, but got "+index);&#xD;&#xD;&#xD;    if (index &gt; list.length()) throw new Error("&apos;replace&apos; expected a list index less than "+(list.length()+1)+", but got "+index);&#xD;&#xD;&#xD;    list.put(element, idx);&#xD;&#xD;&#xD;  };&#xD;}&#xD;else {&#xD;  if (Process.prototype.reportListItem_orig) Process.prototype.reportListItem = Process.prototype.reportListItem_orig;&#xD;&#xD;&#xD;  if (Process.prototype.doDeleteFromList_orig) Process.prototype.doDeleteFromList = Process.prototype.doDeleteFromList_orig;&#xD;&#xD;&#xD;  if (Process.prototype.doInsertInList_orig) Process.prototype.doInsertInList = Process.prototype.doInsertInList_orig;&#xD;&#xD;&#xD;  if (Process.prototype.doReplaceInList_orig) Process.prototype.doReplaceInList = Process.prototype.doReplaceInList_orig;&#xD;&#xD;&#xD;}</l></block><list><block var="value"/></list></block></script></block-definition><block-definition s="make test &lt; %&apos;item&apos; is in %&apos;list&apos; ?&gt; = %&apos;expected&apos;" type="reporter" category="other"><header></header><code></code><translations></translations><inputs><input type="%s"></input><input type="%l"></input><input type="%b"></input></inputs><script><block s="doReport"><custom-block s="make test expr: %anyUE expected: %s description: %txt"><custom-block s="%s is in %l ?"><block var="item"/><block var="list"/></custom-block><block var="expected"/><block s="reportJoinWords"><list><l>&lt;</l><block var="item"/><l> is in </l><custom-block s="list %l $arrowRight text"><block var="list"/></custom-block><l>&gt;</l></list></block></custom-block></block></script></block-definition><block-definition s="make test (index of %&apos;item&apos; in %&apos;list&apos; ) = %&apos;expected&apos;" type="reporter" category="other"><header></header><code></code><translations></translations><inputs><input type="%s"></input><input type="%l"></input><input type="%n"></input></inputs><script><block s="doReport"><custom-block s="make test expr: %anyUE expected: %s description: %txt"><custom-block s="index of %s in %l"><block var="item"/><block var="list"/></custom-block><block var="expected"/><block s="reportJoinWords"><list><l>(index of </l><block var="item"/><l> in </l><custom-block s="list %l $arrowRight text"><block var="list"/></custom-block><l>)</l></list></block></custom-block></block></script></block-definition><block-definition s="make test (first e-word of %&apos;list&apos; ) = %&apos;expected&apos;" type="reporter" category="other"><header></header><code></code><translations></translations><inputs><input type="%l"></input><input type="%s"></input></inputs><script><block s="doReport"><custom-block s="make test expr: %anyUE expected: %s description: %txt"><custom-block s="first e-word of %l"><block var="list"/></custom-block><block var="expected"/><block s="reportJoinWords"><list><l>(first e-word of </l><custom-block s="list %l $arrowRight text"><block var="list"/></custom-block><l>)</l></list></block></custom-block></block></script></block-definition><block-definition s="make test (first word of %&apos;list&apos; that starts with %&apos;letter&apos; ) = %&apos;expected&apos;" type="reporter" category="other"><header></header><code></code><translations></translations><inputs><input type="%l"></input><input type="%s"></input><input type="%s"></input></inputs><script><block s="doReport"><custom-block s="make test expr: %anyUE expected: %s description: %txt"><custom-block s="first word of %l that starts with %s"><block var="list"/><block var="letter"/></custom-block><block var="expected"/><block s="reportJoinWords"><list><l>(first word of </l><custom-block s="list %l $arrowRight text"><block var="list"/></custom-block><l> that starts with </l><block var="letter"/><l>)</l></list></block></custom-block></block></script></block-definition><block-definition s="%&apos;list&apos; contains %&apos;inputItem&apos;" type="predicate" category="motion"><header></header><code></code><translations></translations><inputs><input type="%l"></input><input type="%s"></input></inputs><script><block s="doFor"><l>i</l><l>1</l><block s="reportListLength"><block var="list"/></block><script><block s="doIfElse"><block s="reportIsIdentical"><block var="inputItem"/><block s="reportListItem"><block var="i"/><block var="list"/></block></block><script><block s="doReport"><block s="reportBoolean"><l><bool>true</bool></l></block></block></script><script><block s="doReport"><block s="reportBoolean"><l><bool>false</bool></l></block></block></script></block></script></block></script></block-definition><block-definition s="%&apos;list&apos; index of" type="reporter" category="motion"><header></header><code></code><translations></translations><inputs><input type="%l"></input></inputs><script><block s="doFor"><l>i</l><l>1</l><block s="reportStringSize"><block var="list"/></block><script><block s="doAsk"><l>What letter are you looking for?</l></block><block s="doIfElse"><block s="reportListContainsItem"><block var="list"/><block s="getLastAnswer"></block></block><script><block s="doIf"><block s="reportEquals"><block s="getLastAnswer"></block><l>a</l></block><script><block s="doReport"><l>1</l></block></script></block><block s="doIf"><block s="reportEquals"><block s="getLastAnswer"></block><l>b</l></block><script><block s="doReport"><l>2</l></block></script></block><block s="doIf"><block s="reportEquals"><block s="getLastAnswer"></block><l>c</l></block><script><block s="doReport"><l>3</l></block></script></block><block s="doIf"><block s="reportEquals"><block s="getLastAnswer"></block><l>d</l></block><script><block s="doReport"><l>4</l></block></script></block><block s="doIf"><block s="reportEquals"><block s="getLastAnswer"></block><l>e</l></block><script><block s="doReport"><l>5</l></block></script></block><block s="doIf"><block s="reportEquals"><block s="getLastAnswer"></block><l>f</l></block><script><block s="doReport"><l>6</l></block></script></block><block s="doIf"><block s="reportEquals"><block s="getLastAnswer"></block><l>g</l></block><script><block s="doReport"><l>7</l></block></script></block></script><script><block s="doReport"><l>-1</l></block></script></block></script></block></script></block-definition><block-definition s="%&apos;list&apos; first E-word" type="reporter" category="motion"><header></header><code></code><translations></translations><inputs><input type="%l"></input></inputs><script><block s="doFor"><l>i</l><l>1</l><block s="reportStringSize"><block var="list"/></block><script><block s="doIf"><block s="reportEquals"><block s="reportLetter"><l>1</l><block s="reportListItem"><block var="i"/><block var="list"/></block></block><l>e</l></block><script><block s="doReport"><block s="reportListItem"><block var="i"/><block var="list"/></block></block></script></block></script></block><block s="doReport"><l>(blank)</l></block></script></block-definition><block-definition s="%&apos;list&apos; first word that starts with %&apos;letter&apos;" type="reporter" category="motion"><header></header><code></code><translations></translations><inputs><input type="%l"></input><input type="%s"></input></inputs><script><block s="doFor"><l>i</l><l>1</l><block s="reportStringSize"><block var="list"/></block><script><block s="doIf"><block s="reportEquals"><block s="reportLetter"><l>1</l><block s="reportListItem"><block var="i"/><block var="list"/></block></block><block var="letter"/></block><script><block s="doReport"><block s="reportListItem"><block var="i"/><block var="list"/></block></block></script></block></script></block><block s="doReport"><l>(blank)</l></block></script></block-definition></blocks><variables></variables></project><media name="MidtermExam" app="Snap! 5.4, http://snap.berkeley.edu" version="1"></media></snapdata>