Skip to content

Instantly share code, notes, and snippets.

@stevenbird
Created June 29, 2015 10:23
Show Gist options
  • Save stevenbird/798f224bdbf52f6e12df to your computer and use it in GitHub Desktop.
Save stevenbird/798f224bdbf52f6e12df to your computer and use it in GitHub Desktop.
An Edgy file containing a block that generates a tree with given degree and depth
<blocks app="Snap! 4.0, http://snap.berkeley.edu" version="1"><block-definition s="tree %&apos;degree&apos; %&apos;depth&apos;" type="reporter" category="other"><header></header><code></code><inputs><input type="%s"></input><input type="%s"></input></inputs><script><block s="doDeclareVariables"><list><l>node</l></list></block><block s="doSetVar"><l>node</l><custom-block s="new node"></custom-block></block><block s="doIf"><block s="reportGreaterThan"><block var="depth"/><l>0</l></block><script><block s="doRepeat"><block var="degree"/><script><block s="addEdge"><list><block s="reportEdge"><block var="node"/><custom-block s="tree %s %s"><block var="degree"/><block s="reportDifference"><block var="depth"/><l>1</l></block></custom-block></block></list></block></script></block></script></block><block s="doReport"><block var="node"/></block></script><password></password><salt></salt></block-definition></blocks>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment