#N canvas 0 31 619 643 10;
#X floatatom 128 286 5 0 0 0 - - -;
#X msg 137 126 bang;
#X obj 179 281 print TWO_ITEMS;
#X obj 107 311 print RESULT;
#X msg 144 150 1;
#X msg 152 196 1 2 3;
#X msg 149 172 1 2;
#X msg 155 219 1 2 3 4;
#X text 182 127 redo last list;
#X text 73 12 [list-reduce];
#X text 188 151 list with only one item will pass unchanged.;
#X symbolatom 101 416 15 0 0 0 - - -;
#X msg 196 385 \$2-\$1;
#X obj 102 584 list-reduce;
#X msg 102 557 1 2 3 4 5 6 7 8;
#X msg 197 583 \$2 \$1;
#N canvas 209 220 605 355 more-info 0;
#X msg 84 101 bang;
#X obj 126 236 print TWO_ITEMS;
#X obj 54 266 print RESULT;
#X msg 91 125 1;
#X msg 99 171 1 2 3;
#X msg 96 147 1 2;
#X text 36 42 If nothing is connected to the right inlet \, [list-reduce]
will act like the left and right outlets of [list split 2] reversed.
;
#X obj 54 203 list-reduce;
#X msg 342 100 bang;
#X obj 385 244 print TWO_ITEMS;
#X obj 312 265 print RESULT;
#X msg 349 124 1;
#X msg 357 170 1 2 3;
#X msg 354 146 1 2;
#X obj 312 202 list split 2;
#X text 178 202 equal to this:;
#X connect 0 0 7 0;
#X connect 3 0 7 0;
#X connect 4 0 7 0;
#X connect 5 0 7 0;
#X connect 7 0 2 0;
#X connect 7 1 1 0;
#X connect 8 0 14 0;
#X connect 11 0 14 0;
#X connect 12 0 14 0;
#X connect 13 0 14 0;
#X connect 14 0 9 0;
#X connect 14 2 10 0;
#X restore 101 457 pd more-info;
#X obj 102 612 print REVERSE?;
#X obj 101 386 list-reduce;
#X text 93 39 [list-reduce] returns a single value constructed by calling
the user-defined objects connected to the right outlet on the first
two items of the sequence \, then on the result (if it comes in through
the right inlet) and the next item of the original list \, and so on.
;
#X obj 107 248 list-reduce;
#X text 99 487 It's important \, that there will be only one element
coming back in through the right inlet. Lists with more than one item
will be shortened automatically to avoid stack overflows.;
#X text 251 582 <-- two items == bad idea;
#X msg 101 359 a b c d e;
#X obj 329 250 list-reduce;
#X obj 416 250 min;
#N canvas 0 0 450 300 randlist 0;
#X obj 254 138 random 100;
#X obj 254 116 until;
#X msg 366 138 set;
#X msg 232 61 10;
#X msg 254 160 add2 \$1;
#X obj 232 88 t b f b;
#X obj 255 236 outlet;
#X obj 232 38 inlet;
#X connect 0 0 4 0;
#X connect 1 0 0 0;
#X connect 2 0 6 0;
#X connect 3 0 5 0;
#X connect 4 0 6 0;
#X connect 5 0 6 0;
#X connect 5 1 1 0;
#X connect 5 2 2 0;
#X connect 7 0 3 0;
#X restore 329 197 pd randlist;
#X msg 329 223 27 92 42 82 48 52 74 33 52 71;
#X msg 329 177 bang;
#X obj 382 276 list-reduce;
#X floatatom 382 300 5 0 0 3 max - -;
#X obj 469 276 max;
#X floatatom 329 301 5 0 0 3 min - -;
#X obj 196 248 +;
#X obj 328 422 list-reduce;
#X floatatom 328 445 5 0 0 0 - - -;
#X msg 328 392 22 31 47 86;
#N canvas 0 0 701 458 compare-two 0;
#X obj 99 12 inlet;
#X obj 99 318 outlet;
#X obj 164 162 abs;
#X obj 99 161 abs;
#X obj 99 41 unpack f f;
#X obj 99 90 t a a;
#X obj 99 272 f;
#X obj 164 90 t a a;
#X obj 131 272 f;
#X obj 99 247 select 1 0;
#X text 178 276 send number with smaller distance back to reduce;
#X text 215 151 calculate distances;
#X obj 99 192 <;
#X obj 217 91 inlet;
#X obj 164 139 -;
#X obj 99 138 -;
#X connect 0 0 4 0;
#X connect 2 0 12 1;
#X connect 3 0 12 0;
#X connect 4 0 5 0;
#X connect 4 1 7 0;
#X connect 5 0 15 0;
#X connect 5 1 6 1;
#X connect 6 0 1 0;
#X connect 7 0 14 0;
#X connect 7 1 8 1;
#X connect 8 0 1 0;
#X connect 9 0 6 0;
#X connect 9 1 8 0;
#X connect 12 0 9 0;
#X connect 13 0 14 1;
#X connect 13 0 15 1;
#X connect 14 0 2 0;
#X connect 15 0 3 0;
#X restore 414 422 pd compare-two;
#X floatatom 507 403 5 0 0 0 - - -;
#X msg 507 380 45;
#X obj 507 357 loadbang;
#X text 325 355 Find closest element:;
#N canvas 506 181 494 396 META 0;
#X text 12 25 LICENSE SIBSD;
#X text 12 145 AUTHOR Frank Barknecht;
#X text 12 165 HELP_PATCH_AUTHORS Frank Barknecht. "pd meta" information
added by Jonathan Wilkes for Pd version 0.42.;
#X text 12 45 DESCRIPTION;
#X text 12 5 KEYWORDS control list_op;
#X text 12 65 INLET_0 bang float list;
#X text 12 105 OUTLET_0 float;
#X text 12 125 OUTLET_1 list;
#X text 12 85 INLET_1 float;
#X restore 557 611 pd META;
#X connect 1 0 20 0;
#X connect 4 0 20 0;
#X connect 5 0 20 0;
#X connect 6 0 20 0;
#X connect 7 0 20 0;
#X connect 12 0 18 1;
#X connect 13 0 17 0;
#X connect 13 1 15 0;
#X connect 14 0 13 0;
#X connect 15 0 13 1;
#X connect 18 0 11 0;
#X connect 18 1 12 0;
#X connect 20 0 0 0;
#X connect 20 0 3 0;
#X connect 20 1 2 0;
#X connect 20 1 33 0;
#X connect 23 0 18 0;
#X connect 24 0 32 0;
#X connect 24 1 25 0;
#X connect 25 0 24 1;
#X connect 26 0 27 0;
#X connect 27 0 24 0;
#X connect 27 0 29 0;
#X connect 28 0 26 0;
#X connect 29 0 30 0;
#X connect 29 1 31 0;
#X connect 31 0 29 1;
#X connect 33 0 20 1;
#X connect 34 0 35 0;
#X connect 34 1 37 0;
#X connect 36 0 34 0;
#X connect 37 0 34 1;
#X connect 38 0 37 1;
#X connect 39 0 38 0;
#X connect 40 0 39 0;
