Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add procedure modification library #3128

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libraries/LIBRARIES
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ parallel_module.xml Parallelization Run several scripts in parallel and wait unt
Eisenbergification.xml Getters and setters Eisenberg's Law: Anything that can be done from the GUI should be doable from the programming language, and vice versa.
variadic-reporters.xml Variadic reporters Versions of AND and OR that take more than two inputs.
list_comprehension_module.xml List comprehension HOF version of ZIP, letting you "hyperize" any dyadic function
procedure_modification.xml Procedure modification Allows procedure modifying.
~ ~
~ ~
~ ~
Expand Down
1 change: 1 addition & 0 deletions libraries/procedure-modification.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<blocks app="Snap! 7, https://snap.berkeley.edu" version="2"><palette><category name="Procedure" color="204,224,0,1"/></palette><block-definition s="procedure $arrowRight structure %&apos;block&apos;" type="reporter" category="Procedure"><comment w="90" collapsed="false">Converts procedure to list. Similar to (split _ by blocks).</comment><header></header><code></code><translations></translations><inputs><input type="%repRing"></input></inputs><script><block s="doReport"><block s="reportIfElse"><block s="reportOr"><block s="reportIsA"><block var="block"/><l><option>predicate</option></l></block><block s="reportOr"><block s="reportIsA"><block var="block"/><l><option>reporter</option></l></block><block s="reportIsA"><block var="block"/><l><option>command</option></l></block></block></block><custom-block s="deep map %repRing over %l"><block s="reifyReporter"><autolambda><block s="reportIfElse"><block s="reportOr"><block s="reportIsA"><block var="value"/><l><option>predicate</option></l></block><block s="reportOr"><block s="reportIsA"><block var="value"/><l><option>reporter</option></l></block><block s="reportIsA"><block var="value"/><l><option>command</option></l></block></block></block><block s="reportIfElse"><block s="reportEquals"><block s="reportListItem"><l>1</l><block s="reportTextSplit"><block var="value"/><l><option>blocks</option></l></block></block><block var="value"/></block><block var="value"/><block s="reportTextSplit"><block var="value"/><l><option>blocks</option></l></block></block><block var="value"/></block></autolambda><list><l>value</l></list></block><block s="reportTextSplit"><block var="block"/><l><option>blocks</option></l></block></custom-block><block var="block"/></block></block></script></block-definition><block-definition s="structure $arrowRight procedure %&apos;list&apos;" type="reporter" category="Procedure"><comment w="90" collapsed="false">Converts from list to procedure, if poosible. Opposite of (procedure to structure _).</comment><header></header><code></code><translations></translations><inputs><input type="%l"></input></inputs><script><block s="doWarp"><script><block s="doIfElse"><block s="reportNot"><block s="reportIsA"><block var="list"/><l><option>list</option></l></block></block><script><block s="doReport"><block var="list"/></block></script><script><block s="doDeclareVariables"><list><l>test</l></list></block><block s="doSetVar"><l>test</l><block s="reportIfElse"><block s="reportEquals"><block s="reportListAttribute"><l><option>flatten</option></l><block var="list"/></block><block var="list"/></block><block s="reportJoinWords"><block var="list"/></block><block s="reportJoinWords"><block s="reportMap"><block s="reifyReporter"><autolambda><custom-block s="structure $arrowRight procedure %l"><l/></custom-block></autolambda><list></list></block><block var="list"/></block></block></block></block><block s="doIfElse"><block s="reportEquals"><custom-block s="procedure $arrowRight structure %repRing"><block var="test"/></custom-block><block var="list"/></block><script><block s="doReport"><block var="test"/></block></script><script><block s="doReport"><block s="reportIfElse"><block s="reportEquals"><block s="reportListAttribute"><l><option>flatten</option></l><block var="list"/></block><block var="list"/></block><block s="reportJoinWords"><block var="list"/></block><block s="reportJoinWords"><block var="list"/></block></block></block></script></block></script></block></script></block></script></block-definition><block-definition s="change procedure %&apos;block&apos; by %&apos;lambda&apos;" type="reporter" category="Procedure"><comment w="90" collapsed="false">Changes a procedure to another by a function that takes the procedure structure as input.</comment><header></header><code></code><translations></translations><inputs><input type="%repRing"></input><input type="%repRing"></input></inputs><script><block s="doReport"><custom-block s="structure $arrowRight procedure %l"><block s="evaluate"><block var="lambda"/><list><custom-block s="procedure $arrowRight structure %repRing"><block var="block"/></custom-block></list></block></custom-block></block></script></block-definition><block-definition s="item %&apos;numbers&apos; of %&apos;list&apos;" type="reporter" category="lists"><header></header><code></code><translations></translations><inputs><input type="%mult%n"></input><input type="%l"></input></inputs><script><block s="doReport"><block s="reportIfElse"><block s="reportListIsEmpty"><block var="numbers"/></block><block var="list"/><block s="reportListItem"><block s="reportListItem"><l>1</l><block var="numbers"/></block><custom-block s="item %mult%n of %l"><block s="reportCDR"><block var="numbers"/></block><block var="list"/></custom-block></block></block></block></script></block-definition><block-definition s="insert %&apos;wrapped&apos; in %&apos;wrapper&apos; on %&apos;i&apos;" type="reporter" category="Procedure"><comment w="90" collapsed="false">Inserts or changes a slot in the procedure by index stacked from right to left.</comment><header></header><code></code><translations></translations><inputs><input type="%s">10</input><input type="%repRing"></input><input type="%mult%n">1</input></inputs><script><block s="doReport"><block s="reportIfElse"><block s="reportEquals"><block s="reportListAttribute"><l><option>length</option></l><block var="i"/></block><l>1</l></block><custom-block s="change procedure %repRing by %repRing"><block var="wrapper"/><block s="reifyReporter"><autolambda><block s="reportMap"><block s="reifyReporter"><autolambda><block s="reportIfElse"><block s="reportEquals"><block var="index"/><block s="reportVariadicSum"><list><block s="reportListItem"><l>1</l><block var="i"/></block><l>1</l></list></block></block><block var="wrapped"/><block var="value"/></block></autolambda><list><l>value</l><l>index</l></list></block><l/></block></autolambda><list></list></block></custom-block><custom-block s="change procedure %repRing by %repRing"><block var="wrapper"/><block s="reifyReporter"><autolambda><custom-block s="insert %s in %repRing on %mult%n"><custom-block s="insert %s in %repRing on %mult%n"><block var="wrapped"/><custom-block s="change procedure %repRing by %repRing"><block var="wrapper"/><block s="reifyReporter"><autolambda><custom-block s="item %mult%n of %l"><block s="reportCDR"><block var="i"/></block><l/></custom-block></autolambda><list></list></block></custom-block><list><block s="reportListItem"><l>1</l><block var="i"/></block></list></custom-block><block s="reifyReporter"><script></script><list></list></block><block s="reportCDR"><block var="i"/></block></custom-block></autolambda><list></list></block></custom-block></block></block></script></block-definition><block-definition s="deep map %&apos;lambda&apos; over %&apos;list&apos;" type="reporter" category="lists"><header></header><code></code><translations></translations><inputs><input type="%repRing"></input><input type="%l"></input></inputs><script><block s="doReport"><block s="reportIfElse"><block s="reportIsA"><block var="list"/><l><option>list</option></l></block><block s="reportIfElse"><block s="reportEquals"><block var="list"/><block s="reportListAttribute"><l><option>flatten</option></l><block var="list"/></block></block><block s="reportMap"><block var="lambda"/><block var="list"/></block><block s="reportMap"><block s="reifyReporter"><autolambda><custom-block s="deep map %repRing over %l"><block var="lambda"/><l/></custom-block></autolambda><list></list></block><block var="list"/></block></block><block s="evaluate"><block var="lambda"/><list><block var="list"/></list></block></block></block></script></block-definition><block-definition s="switch all %&apos;from&apos; in %&apos;block&apos; to %&apos;to&apos;" type="reporter" category="Procedure"><comment w="90" collapsed="false">Switch all single procedures or text/number in the procedure to the one specified.</comment><header></header><code></code><translations></translations><inputs><input type="%s"></input><input type="%repRing"></input><input type="%s"></input></inputs><script><block s="doWarp"><script><block s="doReport"><custom-block s="change procedure %repRing by %repRing"><block var="block"/><block s="reifyReporter"><autolambda><custom-block s="deep map %repRing over %l"><block s="reifyReporter"><autolambda><block s="reportIfElse"><block s="reportEquals"><block var="from"/><block var="value"/></block><block var="to"/><block var="value"/></block></autolambda><list><l>value</l></list></block><block var="block."/></custom-block></autolambda><list><l>block.</l></list></block></custom-block></block></script></block></script></block-definition></blocks>