summaryrefslogtreecommitdiff
path: root/libraries/iteration-composition.xml
diff options
context:
space:
mode:
authorMichael Ball <cycomachead@gmail.com>2013-12-29 03:02:05 -0800
committerMichael Ball <cycomachead@gmail.com>2013-12-29 03:03:49 -0800
commited5173863799378c699da426c4cd41348d0bcbf8 (patch)
treea95c8d87763b2c6cd37af2a87dc77c6f54103d0e /libraries/iteration-composition.xml
parente9020b4ed3f7190dc78e622fbe3b2665e227c30f (diff)
downloadsnap-yow-ed5173863799378c699da426c4cd41348d0bcbf8.tar.gz
snap-yow-ed5173863799378c699da426c4cd41348d0bcbf8.zip
adding libraries to the repo
Diffstat (limited to 'libraries/iteration-composition.xml')
-rw-r--r--libraries/iteration-composition.xml1
1 files changed, 1 insertions, 0 deletions
diff --git a/libraries/iteration-composition.xml b/libraries/iteration-composition.xml
new file mode 100644
index 0000000..0f16bb6
--- /dev/null
+++ b/libraries/iteration-composition.xml
@@ -0,0 +1 @@
+<blocks app="Snap! 4.0, http://snap.berkeley.edu" version="1"><block-definition s="cascade %&apos;num&apos; times %&apos;function&apos; %&apos;init&apos; %&apos;#&apos;" type="reporter" category="control"><comment w="138" collapsed="false">Call f(f(f(...(f(x))))) n times where the three input slots are n, f, and x from left to right. The # variable can be used inside f to represent how many times f has been called.</comment><code></code><inputs><input type="%n"></input><input type="%repRing"></input><input type="%s"></input><input type="%upvar"></input></inputs><script><block s="doDeclareVariables"><list><l>result</l></list></block><block s="doSetVar"><l>result</l><block var="init"/></block><block s="doSetVar"><l>#</l><l>0</l></block><block s="doRepeat"><block var="num"/><script><block s="doChangeVar"><l>#</l><l>1</l></block><block s="doSetVar"><l>result</l><block s="evaluate"><block var="function"/><list><block var="result"/></list></block></block></script></block><block s="doReport"><block var="result"/></block></script></block-definition><block-definition s="cascade until %&apos;pred&apos; %&apos;function&apos; %&apos;init&apos; %&apos;#&apos;" type="reporter" category="control"><comment w="90" collapsed="false">Call f(f(f(...(f(x))))) until condition is true, where the three input slots are condition, f, and x from left to right. The # variable can be used inside f or condition to indicate how many times f has been called.</comment><code></code><inputs><input type="%predRing"></input><input type="%repRing"></input><input type="%s"></input><input type="%upvar"></input></inputs><script><block s="doDeclareVariables"><list><l>result</l></list></block><block s="doSetVar"><l>result</l><block var="init"/></block><block s="doSetVar"><l>#</l><l>0</l></block><block s="doUntil"><block s="evaluate"><block var="pred"/><list><block var="result"/></list></block><script><block s="doChangeVar"><l>#</l><l>1</l></block><block s="doSetVar"><l>result</l><block s="evaluate"><block var="function"/><list><block var="result"/></list></block></block></script></block><block s="doReport"><block var="result"/></block></script></block-definition><block-definition s="compose %&apos;f&apos; %&apos;g&apos;" type="reporter" category="control"><comment w="90" collapsed="false">Returns the function f(g(x)) where f and g are the two inputs.</comment><code></code><inputs><input type="%repRing"></input><input type="%repRing"></input></inputs><script><block s="doReport"><block s="reifyReporter"><autolambda><block s="evaluate"><block var="f"/><list><block s="evaluate"><block var="g"/><list><l></l></list></block></list></block></autolambda><list></list></block></block></script></block-definition><block-definition s="repeat %&apos;action&apos; until %&apos;pred&apos;" type="command" category="control"><comment w="90" collapsed="false">Like the built-in REPEAT UNTIL block, except that the ending condition is not tested until the script has been run the first time. So the script is run at least once.</comment><code></code><inputs><input type="%cs"></input><input type="%boolUE"></input></inputs><script><block s="doRun"><block var="action"/><list></list></block><block s="doUntil"><block s="evaluate"><block var="pred"/><list></list></block><script><block s="doRun"><block var="action"/><list></list></block></script></block></script></block-definition><block-definition s="repeat %&apos;action&apos; while %&apos;pred&apos;" type="command" category="control"><comment w="90" collapsed="false">Run the script repeatedly, as long as the given condition is true. Runs the script at least once before testing the condition.</comment><code></code><inputs><input type="%cs"></input><input type="%boolUE"></input></inputs><script><block s="doRun"><block var="action"/><list></list></block><block s="doUntil"><block s="reportNot"><block s="evaluate"><block var="pred"/><list></list></block></block><script><block s="doRun"><block var="action"/><list></list></block></script></block></script></block-definition><block-definition s="repeat while %&apos;pred&apos; %&apos;action&apos;" type="command" category="control"><comment w="90" collapsed="false">Runs the script repeatedly, as long as the condition is true. Tests the condition before the first time the script is run. Like the built in REPEAT UNTIL except that in this block the condition must be true, not false.</comment><code></code><inputs><input type="%boolUE"></input><input type="%cs"></input></inputs><script><block s="doUntil"><block s="reportNot"><block s="evaluate"><block var="pred"/><list></list></block></block><script><block s="doRun"><block var="action"/><list></list></block></script></block></script></block-definition><block-definition s="repeat %&apos;num&apos; %&apos;#&apos; %&apos;action&apos;" type="command" category="control"><comment w="171" collapsed="false">Runs the script the specified number of times, like the built-in REPEAT block, but this one provides the # variable that can be used inside the script. Try&#xD;REPEAT (200)&#xD; MOVE (#) STEPS&#xD; RIGHT 92&#xD;with the pen down.</comment><code></code><inputs><input type="%n"></input><input type="%upvar"></input><input type="%cs"></input></inputs><script><block s="doSetVar"><l>#</l><l>0</l></block><block s="doRepeat"><block var="num"/><script><block s="doChangeVar"><l>#</l><l>1</l></block><block s="doRun"><block var="action"/><list></list></block></script></block></script></block-definition></blocks> \ No newline at end of file