aboutsummaryrefslogtreecommitdiff
path: root/Gem/examples/13.recursion
diff options
context:
space:
mode:
Diffstat (limited to 'Gem/examples/13.recursion')
-rw-r--r--Gem/examples/13.recursion/04.binary_tree.pd168
-rw-r--r--Gem/examples/13.recursion/05.n-ary_tree.pd120
-rw-r--r--Gem/examples/13.recursion/nrepeat.pd4
3 files changed, 152 insertions, 140 deletions
diff --git a/Gem/examples/13.recursion/04.binary_tree.pd b/Gem/examples/13.recursion/04.binary_tree.pd
index 01dcd99..89cf3d8 100644
--- a/Gem/examples/13.recursion/04.binary_tree.pd
+++ b/Gem/examples/13.recursion/04.binary_tree.pd
@@ -1,4 +1,4 @@
-#N canvas 6 61 602 516 10;
+#N canvas 6 61 602 553 10;
#X declare -lib Gem;
#X obj 14 66 gemwin;
#X obj 14 9 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 1
@@ -9,92 +9,104 @@
#X text 170 17 A tutorial on recursion in Gem;
#X text 170 37 (GPL) 2007 Claude Heiland-Allen <claude@mathr.co.uk>
;
-#X obj 24 163 r \$0-recurse;
-#X obj 68 133 v \$0-depth;
-#X obj 14 113 t a b;
-#X floatatom 91 96 5 0 0 2 max-depth - -;
-#X obj 14 253 t a a;
-#X obj 59 253 circle;
-#X obj 14 223 separator;
-#X obj 36 473 s \$0-recurse;
-#X obj 14 353 t b a b;
-#X obj 99 383 v \$0-depth;
-#X obj 99 403 - 1;
-#X obj 99 423 max 0;
+#X obj 24 233 r \$0-recurse;
+#X obj 88 213 v \$0-depth;
+#X obj 14 193 t a b;
+#X floatatom 111 176 5 0 17 2 max-depth - -;
+#X obj 14 293 t a a;
+#X obj 14 273 separator;
+#X obj 36 533 s \$0-recurse;
+#X obj 14 413 t b a b;
#X obj 99 443 v \$0-depth;
-#X obj 36 453 spigot;
-#X obj 14 383 v \$0-depth;
-#X obj 14 423 v \$0-depth;
-#X obj 14 403 + 1;
-#X obj 184 253 t a a;
-#X obj 229 253 circle;
-#X obj 206 473 s \$0-recurse;
-#X obj 184 353 t b a b;
-#X obj 269 383 v \$0-depth;
-#X obj 269 403 - 1;
-#X obj 269 423 max 0;
+#X obj 99 463 - 1;
+#X obj 99 483 max 0;
+#X obj 116 533 v \$0-depth;
+#X obj 36 513 spigot;
+#X obj 14 443 v \$0-depth;
+#X obj 14 483 v \$0-depth;
+#X obj 14 463 + 1;
+#X obj 184 293 t a a;
+#X obj 206 533 s \$0-recurse;
+#X obj 184 413 t b a b;
#X obj 269 443 v \$0-depth;
-#X obj 206 453 spigot;
-#X obj 184 383 v \$0-depth;
-#X obj 184 423 v \$0-depth;
-#X obj 184 403 + 1;
-#X obj 184 223 separator;
-#X obj 14 183 t a a;
-#X obj 184 303 translate 1.5 0 1 0;
-#X obj 184 323 scale 0.5;
-#X obj 14 323 scale 0.5;
-#X obj 14 303 translate 1.5 0 1 0;
-#X obj 14 283 rotate -30 0 0 1;
-#X obj 184 283 rotate 30 0 0 1;
-#X obj 68 113 f 4;
-#X text 170 77 The simplest recursive branching structure is one that
+#X obj 269 463 - 1;
+#X obj 269 483 max 0;
+#X obj 286 533 v \$0-depth;
+#X obj 206 513 spigot;
+#X obj 184 443 v \$0-depth;
+#X obj 184 483 v \$0-depth;
+#X obj 184 463 + 1;
+#X obj 184 273 separator;
+#X obj 14 253 t a a;
+#X obj 184 363 translate 1.5 0 1 0;
+#X obj 14 363 translate 1.5 0 1 0;
+#X obj 14 343 rotate -30 0 0 1;
+#X obj 184 343 rotate 30 0 0 1;
+#X obj 88 193 f 4;
+#X text 211 77 The simplest recursive branching structure is one that
splits into two at each branch. Essentially what we are creating is
a circle \, plus two transformed copies of the whole structure \, limited
to a maximums depth of recursion.;
-#X text 170 137 Be careful not to increase the max-depth too much:
+#X text 211 137 Be careful not to increase the max-depth too much:
the splitting at each recursion leads to an exponential increase in
the number of circles to be drawn.;
#X obj 497 15 declare -lib Gem;
+#X obj 259 506 t a a;
+#X obj 89 506 t a a;
+#X obj 14 135 scale 0.4 0.4 1;
+#X obj 14 383 scale 0.95 0.95 1;
+#X obj 184 383 scale 0.95 0.95 1;
+#X obj 259 316 circle;
+#X obj 59 316 circle;
+#X obj 59 293 color 1 0 0;
+#X obj 259 293 color 0 0 1;
+#X obj 14 114 translateXYZ 2 -1 0;
#X connect 1 0 0 0;
#X connect 2 0 0 0;
#X connect 3 0 0 0;
-#X connect 4 0 9 0;
-#X connect 7 0 37 0;
-#X connect 9 0 37 0;
-#X connect 9 1 44 0;
-#X connect 10 0 44 1;
-#X connect 11 0 42 0;
-#X connect 11 1 12 0;
-#X connect 13 0 11 0;
-#X connect 15 0 21 0;
-#X connect 15 1 20 0;
-#X connect 15 2 16 0;
+#X connect 4 0 53 0;
+#X connect 7 0 35 0;
+#X connect 9 0 35 0;
+#X connect 9 1 40 0;
+#X connect 10 0 40 1;
+#X connect 11 0 38 0;
+#X connect 11 1 51 0;
+#X connect 12 0 11 0;
+#X connect 14 0 20 0;
+#X connect 14 1 19 0;
+#X connect 14 2 15 0;
+#X connect 15 0 16 0;
#X connect 16 0 17 0;
-#X connect 17 0 18 0;
-#X connect 18 0 19 0;
-#X connect 18 0 20 1;
-#X connect 20 0 14 0;
-#X connect 21 0 23 0;
-#X connect 23 0 22 0;
-#X connect 24 0 43 0;
-#X connect 24 1 25 0;
-#X connect 27 0 33 0;
-#X connect 27 1 32 0;
-#X connect 27 2 28 0;
-#X connect 28 0 29 0;
-#X connect 29 0 30 0;
-#X connect 30 0 31 0;
-#X connect 30 0 32 1;
-#X connect 32 0 26 0;
-#X connect 33 0 35 0;
-#X connect 35 0 34 0;
-#X connect 36 0 24 0;
-#X connect 37 0 13 0;
-#X connect 37 1 36 0;
-#X connect 38 0 39 0;
-#X connect 39 0 27 0;
-#X connect 40 0 15 0;
-#X connect 41 0 40 0;
-#X connect 42 0 41 0;
-#X connect 43 0 38 0;
-#X connect 44 0 8 0;
+#X connect 17 0 45 0;
+#X connect 19 0 13 0;
+#X connect 20 0 22 0;
+#X connect 22 0 21 0;
+#X connect 23 0 39 0;
+#X connect 23 1 52 0;
+#X connect 25 0 31 0;
+#X connect 25 1 30 0;
+#X connect 25 2 26 0;
+#X connect 26 0 27 0;
+#X connect 27 0 28 0;
+#X connect 28 0 44 0;
+#X connect 30 0 24 0;
+#X connect 31 0 33 0;
+#X connect 33 0 32 0;
+#X connect 34 0 23 0;
+#X connect 35 0 12 0;
+#X connect 35 1 34 0;
+#X connect 36 0 48 0;
+#X connect 37 0 47 0;
+#X connect 38 0 37 0;
+#X connect 39 0 36 0;
+#X connect 40 0 8 0;
+#X connect 44 0 30 1;
+#X connect 44 1 29 0;
+#X connect 45 0 19 1;
+#X connect 45 1 18 0;
+#X connect 46 0 9 0;
+#X connect 47 0 14 0;
+#X connect 48 0 25 0;
+#X connect 51 0 50 0;
+#X connect 52 0 49 0;
+#X connect 53 0 46 0;
diff --git a/Gem/examples/13.recursion/05.n-ary_tree.pd b/Gem/examples/13.recursion/05.n-ary_tree.pd
index 308f5e5..7c21b45 100644
--- a/Gem/examples/13.recursion/05.n-ary_tree.pd
+++ b/Gem/examples/13.recursion/05.n-ary_tree.pd
@@ -1,7 +1,7 @@
-#N canvas 6 61 600 605 10;
+#N canvas 788 283 600 605 10;
#X declare -lib Gem;
#X obj 14 66 gemwin;
-#X obj 14 9 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 1
+#X obj 14 9 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1 1
;
#X msg 48 10 create;
#X msg 55 33 destroy;
@@ -9,75 +9,73 @@
#X text 170 17 A tutorial on recursion in Gem;
#X text 170 37 (GPL) 2007 Claude Heiland-Allen <claude@mathr.co.uk>
;
-#X obj 30 159 r \$0-recurse;
-#X obj 68 133 v \$0-depth;
-#X obj 14 113 t a b;
-#X floatatom 84 70 5 0 0 2 max-depth - -;
-#X obj 14 187 t a a;
-#X obj 60 188 circle;
-#X obj 14 325 separator;
-#X obj 36 536 s \$0-recurse;
-#X obj 14 416 t b a b;
-#X obj 99 446 v \$0-depth;
-#X obj 99 466 - 1;
-#X obj 99 486 max 0;
-#X obj 99 506 v \$0-depth;
-#X obj 36 516 spigot;
-#X obj 14 446 v \$0-depth;
-#X obj 14 486 v \$0-depth;
-#X obj 14 466 + 1;
-#X obj 68 113 f 4;
-#X obj 14 346 rotate 0 0 0 1;
-#X obj 126 303 * 72;
-#X obj 14 366 translate 2 0 1 0;
-#X obj 14 386 scale 0.35;
-#X obj 14 270 nrepeat 5;
-#X obj 119 236 t f f;
-#X floatatom 118 196 5 0 0 2 count - -;
-#X obj 149 259 swap 360;
-#X obj 149 282 /;
-#X obj 118 215 clip 1 16;
-#X obj 84 89 clip 1 6;
-#X text 170 77 Recursion can be combined with iteration to make complex
+#X obj 30 239 r \$0-recurse;
+#X obj 68 213 v \$0-depth;
+#X obj 14 193 t a b;
+#X floatatom 83 170 5 1 6 2 max-depth - -;
+#X obj 14 267 t a a;
+#X obj 14 375 separator;
+#X obj 36 586 s \$0-recurse;
+#X obj 14 466 t b a b;
+#X obj 99 496 v \$0-depth;
+#X obj 99 516 - 1;
+#X obj 99 536 max 0;
+#X obj 99 556 v \$0-depth;
+#X obj 36 566 spigot;
+#X obj 14 496 v \$0-depth;
+#X obj 14 536 v \$0-depth;
+#X obj 14 516 + 1;
+#X obj 68 193 f 4;
+#X obj 14 396 rotate 0 0 0 1;
+#X obj 156 353 * 72;
+#X obj 14 416 translate 2 0 1 0;
+#X obj 149 286 t f f;
+#X floatatom 149 266 5 1 16 2 count - -;
+#X obj 179 309 swap 360;
+#X obj 179 332 /;
+#X text 230 57 Recursion can be combined with iteration to make complex
structures. However \, using the [repeat] from Zexy is no longer enough.
Trying to use it with an external counter leads to re-entrancy bugs
\, because the [repeat] is retriggered before the counter has finished
\, which messes up the counter's internal state. [nrepeat] is a "repeat
with a built in counter" \, which is re-entrancy safe.;
#X obj 440 9 declare -lib Gem;
+#X obj 14 320 nrepeat 4;
+#X obj 14 133 scaleXYZ 0.02 0.02 1;
+#X obj 60 268 square 0.8;
+#X obj 14 113 rotate 20 1 0 0;
#X connect 1 0 0 0;
#X connect 2 0 0 0;
#X connect 3 0 0 0;
-#X connect 4 0 9 0;
+#X connect 4 0 36 0;
#X connect 7 0 11 0;
#X connect 9 0 11 0;
-#X connect 9 1 24 0;
-#X connect 10 0 35 0;
-#X connect 11 0 29 0;
-#X connect 11 1 12 0;
-#X connect 13 0 25 0;
-#X connect 15 0 21 0;
-#X connect 15 1 20 0;
-#X connect 15 2 16 0;
+#X connect 9 1 23 0;
+#X connect 10 0 23 1;
+#X connect 11 0 33 0;
+#X connect 11 1 35 0;
+#X connect 12 0 24 0;
+#X connect 14 0 20 0;
+#X connect 14 1 19 0;
+#X connect 14 2 15 0;
+#X connect 15 0 16 0;
#X connect 16 0 17 0;
#X connect 17 0 18 0;
-#X connect 18 0 19 0;
-#X connect 18 0 20 1;
-#X connect 20 0 14 0;
-#X connect 21 0 23 0;
-#X connect 23 0 22 0;
-#X connect 24 0 8 0;
-#X connect 25 0 27 0;
-#X connect 26 0 25 1;
-#X connect 27 0 28 0;
-#X connect 28 0 15 0;
-#X connect 29 0 13 0;
-#X connect 29 1 26 0;
-#X connect 30 0 29 1;
-#X connect 30 1 32 0;
-#X connect 31 0 34 0;
-#X connect 32 0 33 0;
-#X connect 32 1 33 1;
-#X connect 33 0 26 1;
-#X connect 34 0 30 0;
-#X connect 35 0 24 1;
+#X connect 17 0 19 1;
+#X connect 19 0 13 0;
+#X connect 20 0 22 0;
+#X connect 22 0 21 0;
+#X connect 23 0 8 0;
+#X connect 24 0 26 0;
+#X connect 25 0 24 1;
+#X connect 26 0 14 0;
+#X connect 27 0 33 1;
+#X connect 27 1 29 0;
+#X connect 28 0 27 0;
+#X connect 29 0 30 0;
+#X connect 29 1 30 1;
+#X connect 30 0 25 1;
+#X connect 33 0 12 0;
+#X connect 33 1 25 0;
+#X connect 34 0 9 0;
+#X connect 36 0 34 0;
diff --git a/Gem/examples/13.recursion/nrepeat.pd b/Gem/examples/13.recursion/nrepeat.pd
index 4d26d68..2761460 100644
--- a/Gem/examples/13.recursion/nrepeat.pd
+++ b/Gem/examples/13.recursion/nrepeat.pd
@@ -1,4 +1,5 @@
-#N canvas 0 0 413 451 10;
+#N canvas 6 61 413 451 10;
+#X declare -path zexy -lib zexy;
#X obj 78 26 inlet;
#X obj 78 60 t b a b;
#X obj 131 121 repeat \$1;
@@ -24,6 +25,7 @@
#X text 8 225 repeated;
#X text 119 381 counter;
#X text 30 419 nrepeat.pd (GPL) <claude@mathr.co.uk>;
+#X obj 227 386 declare -path zexy -lib zexy;
#X connect 0 0 1 0;
#X connect 1 0 7 0;
#X connect 1 1 2 0;