I made a personalised abstraction a while ago that does exactly that (as far as i understood your problem). It splits lists according to specific symbols, floats and has also a flag to include the "split" element or not.

plus it has a practical "split at anything that is a symbol" mode.

The output happens all in the same [outlet] in my approach, but this can easily be changed

See attachment

Best

Oliver

Peter P. wrote:
Hi list,

I am having lists with a variable number of items and I want to break them
up two lists dependent on the presence of a specific item. I can't seem to
understand how to do it though. Here's a quick example of what I mean:

1 2 3 4 5 6
look for the number 4 and output two lists (at separate outlets) which
are before and after that number 4, giving:
1 2 3
and
5 6
respectively

I'd need the solution to work for lists of other lengths as well, i.e.
55 66 77 88 4 102 -33
should be broken up into
55 66 77 88
and 102 -33
alike.

I tried [route] and [list] objects but can't get them to do what I want.

thanks!
P

---
pd-list@lists.iem.at - the Pure Data mailinglist
https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/message/7EF2SASANM67WTX766GIKCN5OIR64PXN/

To unsubscribe send an email to pd-list-le...@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> https://lists.iem.at/



--
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
/////////////// http://oliver.klingt.org ///////////////
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

#N canvas 850 80 570 719 10;
#X obj 259 15 loadbang;
#X obj 41 17 inlet;
#X obj 35 17 cnv 5 5 17 empty empty empty 20 12 0 14 #70fc74 #404040 0;
#X obj 385 18 inlet;
#X obj 379 18 cnv 5 5 17 empty empty empty 20 12 0 14 #70fc74 #404040 0;
#X obj 41 166 list store, f 12;
#X obj 41 89 until;
#X obj 41 118 f;
#X obj 71 118 + 1;
#X msg 41 142 get \$1 1;
#X obj 84 89 0;
#X obj 41 65 t b b a, f 12;
#X obj 41 42 t a b, f 22;
#X obj 424 154 list split 1;
#X obj 424 180 route float;
#X obj 424 203 clip 0 1;
#X obj 145 663 outlet;
#X text 191 662 list items;
#X obj 139 663 cnv 5 5 17 empty empty empty 20 12 0 14 #60f8fc #404040 0;
#X obj 42 635 list store, f 14;
#X obj 42 576 list prepend append;
#X obj 42 604 list trim;
#X obj 145 636 list trim;
#X obj 42 662 route bang;
#X obj 69 418 select;
#X obj 69 326 route float symbol;
#X obj 69 452 t b b;
#X obj 42 522 spigot, f 16;
#X msg 113 468 0;
#X msg 153 468 1;
#X obj 41 301 t a a b, f 10;
#X obj 121 418 select symbol;
#X obj 118 301 t b b;
#X obj 69 388 spigot;
#X obj 121 388 spigot;
#X obj 259 57 pdcontrol;
#X msg 259 36 args 0;
#X obj 259 129 t b;
#X obj 259 108 route bang float symbol list;
#X obj 390 130 list split 1;
#X obj 390 153 t a;
#X msg 305 196 1;
#X msg 334 196 0;
#X obj 196 325 t f f;
#X obj 223 349 == 0;
#X obj 166 387 tgl 16 0 empty empty empty 0 -8 0 10 #fcfcfc #000000 #000000 0 1;
#X obj 102 367 tgl 16 0 empty empty empty 0 -8 0 10 #fcfcfc #000000 #000000 0 1;
#X obj 135 494 clip 0 1, f 18;
#X obj 155 521 tgl 16 0 empty empty empty 0 -8 0 10 #fcfcfc #000000 #000000 0 1;
#X floatatom 187 468 5 0 0 0 - - - 0;
#X obj 300 130 t b f;
#X obj 345 130 t b s;
#X obj 372 240 t s s;
#X obj 399 263 list fromsymbol;
#X obj 399 284 route bang;
#X msg 202 160 0;
#X obj 41 200 spigot;
#X obj 196 246 spigot;
#X obj 202 185 t f f;
#X obj 229 215 == 0;
#X obj 259 83 t a b;
#X msg 231 160 1;
#X obj 248 245 tgl 16 0 empty empty empty 0 -8 0 10 #fcfcfc #000000 #000000 0 1;
#X obj 301 409 t a a, f 10;
#X obj 358 430 route symbol;
#X obj 358 451 t b b;
#X text 311 387 "any symbol splits" - mode;
#X connect 0 0 36 0;
#X connect 1 0 12 0;
#X connect 3 0 60 0;
#X connect 5 0 56 0;
#X connect 5 0 57 0;
#X connect 5 1 32 0;
#X connect 6 0 7 0;
#X connect 7 0 9 0;
#X connect 7 0 8 0;
#X connect 8 0 7 1;
#X connect 9 0 5 0;
#X connect 10 0 7 1;
#X connect 11 0 6 0;
#X connect 11 1 10 0;
#X connect 11 2 5 1;
#X connect 12 0 11 0;
#X connect 12 1 5 1;
#X connect 12 1 19 1;
#X connect 13 0 14 0;
#X connect 14 0 15 0;
#X connect 15 0 49 0;
#X connect 19 0 23 0;
#X connect 20 0 21 0;
#X connect 21 0 19 0;
#X connect 22 0 16 0;
#X connect 23 1 22 0;
#X connect 24 0 26 0;
#X connect 25 0 33 0;
#X connect 25 1 34 0;
#X connect 26 0 19 1;
#X connect 26 1 19 0;
#X connect 26 1 28 0;
#X connect 27 0 20 0;
#X connect 28 0 47 0;
#X connect 29 0 47 0;
#X connect 30 0 27 0;
#X connect 30 1 25 0;
#X connect 30 2 29 0;
#X connect 31 0 26 0;
#X connect 32 0 19 0;
#X connect 32 1 6 1;
#X connect 33 0 24 0;
#X connect 34 0 31 0;
#X connect 35 0 60 0;
#X connect 36 0 35 0;
#X connect 37 0 55 0;
#X connect 38 0 37 0;
#X connect 38 1 50 0;
#X connect 38 2 51 0;
#X connect 38 3 39 0;
#X connect 39 0 40 0;
#X connect 39 1 13 0;
#X connect 40 0 38 0;
#X connect 41 0 43 0;
#X connect 42 0 43 0;
#X connect 43 0 46 0;
#X connect 43 1 44 0;
#X connect 44 0 45 0;
#X connect 45 0 34 1;
#X connect 46 0 33 1;
#X connect 47 0 27 1;
#X connect 47 0 48 0;
#X connect 49 0 47 1;
#X connect 50 0 41 0;
#X connect 50 1 24 1;
#X connect 51 0 42 0;
#X connect 51 1 52 0;
#X connect 52 0 31 1;
#X connect 52 1 53 0;
#X connect 53 0 54 0;
#X connect 54 0 55 0;
#X connect 55 0 58 0;
#X connect 56 0 30 0;
#X connect 57 0 63 0;
#X connect 58 0 56 1;
#X connect 58 1 59 0;
#X connect 59 0 57 1;
#X connect 59 0 62 0;
#X connect 60 0 38 0;
#X connect 60 1 61 0;
#X connect 61 0 58 0;
#X connect 63 0 20 0;
#X connect 63 1 64 0;
#X connect 64 0 65 0;
#X connect 65 0 19 1;
#X connect 65 1 19 0;
#N canvas 122 107 631 497 10;
#X obj 464 44 namecanvas \$0-ol_help;
#N canvas 1181 46 626 800 init 0;
#X obj 470 388 cnv 8 120 25 empty empty empty 20 12 0 14 #c4fcc4 #404040 0;
#X obj 97 553 cnv 8 300 80 empty empty empty 20 12 0 14 #c4fcc4 #404040 0;
#X obj 461 76 cnv 8 120 26 empty empty empty 20 12 0 14 #c4fcc4 #404040 0;
#X obj 60 287 cnv 8 200 25 empty empty empty 20 12 0 14 #c4fcc4 #404040 0;
#X msg 245 33 vis 0 \, relocate \$3x\$4+0+0 0x0+\$1+\$2 \, vis 1 \, editmode 0;
#X obj 245 55 s \$0-ol_help;
#X msg 118 64 520 50 600 400;
#X obj 118 219 s \$0-frame-r;
#X floatatom 118 176 5 0 0 0 - - - 0;
#X obj 28 450 s \$0-title-r;
#X msg 98 406 label \$1;
#X floatatom 263 143 5 0 0 0 - - - 0;
#X obj 263 183 s \$0-bgnd-r;
#X obj 56 119 del 10;
#X obj 56 99 t b b;
#X text 244 80 1.) set pos and size of main window;
#X msg 172 115 \$3;
#X obj 118 132 f;
#X text 151 143 minus frame sizes, f 11;
#X text 124 266 2.) set name of title;
#X obj 56 141 s \$0-lb;
#X obj 118 107 r \$0-lb;
#X obj 29 244 r \$0-lb;
#X obj 29 406 unpack 0 s;
#X text 175 530 3.) set description;
#X obj 263 262 s \$0-frame2-r;
#X obj 182 463 s \$0-text1-r;
#X obj 29 626 cnv 3 68 15 empty empty empty 2 7 0 10 #f8fc00 #404040 0;
#N canvas 341 335 425 542 tosymbol 0;
#X obj 67 94 list length;
#X obj 67 42 list;
#X obj 101 226 list, f 7;
#X obj 67 175 f, f 10;
#X obj 154 175 + 1;
#X obj 67 150 until;
#X obj 101 251 list split;
#X msg 157 94 0;
#X obj 139 276 list split 1;
#X obj 139 361 list fromsymbol;
#X obj 139 302 route symbol float;
#X obj 191 329 makefilename %s;
#X obj 139 435 textfile;
#X msg 202 94 clear;
#X obj 139 387 list prepend add2;
#X obj 67 201 t b b b f;
#X obj 79 276 + 1;
#X obj 67 122 t f f;
#X obj 78 300 <;
#X obj 20 335 spigot;
#X msg 20 394 add2 160;
#X obj 139 411 list trim;
#X obj 67 335 f;
#X obj 67 361 sel 0;
#X obj 139 463 list tosymbol;
#X obj 67 68 t l l b b, f 23;
#X text 184 486 symbol out with correct spaces;
#X text 57 2 string in;
#X msg 136 25 #/zi 3 4 oo ä;
#X msg 229 25 1.23457e+19;
#X floatatom 315 28 5 0 0 0 - - - 0;
#X obj 67 22 cnv 13 34 15 empty empty empty 2 2 0 9 #9cfc9c #404040 0;
#X obj 139 487 cnv 14 40 15 empty empty empty 2 2 0 9 #9cfcfc #404040 0;
#X obj 67 21 inlet;
#X obj 139 486 outlet;
#X connect 0 0 17 0;
#X connect 1 0 25 0;
#X connect 2 0 6 0;
#X connect 3 0 4 0;
#X connect 3 0 15 0;
#X connect 4 0 3 1;
#X connect 5 0 3 0;
#X connect 6 1 8 0;
#X connect 7 0 3 1;
#X connect 8 0 10 0;
#X connect 9 0 14 0;
#X connect 10 0 9 0;
#X connect 10 1 11 0;
#X connect 11 0 9 0;
#X connect 12 0 24 0;
#X connect 13 0 12 0;
#X connect 14 0 21 0;
#X connect 15 0 22 0;
#X connect 15 1 19 0;
#X connect 15 2 2 0;
#X connect 15 3 6 1;
#X connect 15 3 16 0;
#X connect 16 0 18 0;
#X connect 17 0 5 0;
#X connect 17 1 18 1;
#X connect 18 0 19 1;
#X connect 18 0 22 1;
#X connect 19 0 20 0;
#X connect 20 0 12 0;
#X connect 21 0 12 0;
#X connect 22 0 23 0;
#X connect 23 0 12 0;
#X connect 24 0 34 0;
#X connect 25 0 0 0;
#X connect 25 1 2 1;
#X connect 25 2 7 0;
#X connect 25 3 13 0;
#X connect 28 0 1 0;
#X connect 29 0 1 0;
#X connect 30 0 1 0;
#X connect 33 0 1 0;
#X restore 28 625 pd tosymbol;
#X obj 199 390 r \$0-lb;
#X obj 199 413 t b b;
#X obj 268 463 s \$0-text2-r;
#X obj 354 463 s \$0-text3-r;
#X msg 28 488 bang;
#X msg 118 195 vis_size \$1 45;
#X msg 263 240 vis_size \$1 43;
#X text 349 389 init text labels;
#X obj 28 719 pack s 0 0;
#X msg 28 740 label \$1 \, label_pos \$2 \$3;
#X obj 531 524 unpack;
#X msg 531 500 33 -33;
#X floatatom 493 391 5 0 0 0 - - - 0;
#X floatatom 531 391 5 0 0 0 - - - 0;
#X obj 531 421 t b f;
#X msg 545 471 set \$1 \$2;
#X obj 493 471 t b b l;
#X text 503 370 x;
#X text 540 370 y;
#X text 466 352 4.) set label position;
#X obj 564 545 f;
#X msg 321 367 color \$1 \$1 \$1;
#X msg 263 161 vis_size \$1 55;
#X msg 260 413 size 1 \, pos 300 65 \, vis_size 1 1 \, color \$1 \$1 2 \, 
label_font 1 11 \, label, f 26;
#X floatatom 79 174 5 0 0 0 - - - 0;
#X obj 118 153 - 13;
#X obj 263 122 + 10;
#X obj 263 219 - 254;
#X obj 56 56 t b f;
#X msg 260 390 -1.47533e+06;
#X msg 260 368 set \$1;
#X obj 56 11 loadbang;
#N canvas 36 456 791 300 better_colors 0;
#X obj 89 19 inlet;
#X obj 320 262 outlet;
#X obj 89 40 random 10;
#X obj 89 61 sel 0 1 2 3 4 5 6 7 8 9, f 83;
#X obj 320 239 expr ($f1*(-65536)+$f2*(-256)+$f3*(-1))-1;
#X msg 16 162 140 0 0;
#X msg 69 162 0 156 144;
#X msg 136 162 0 140 0;
#X msg 252 162 231 112 0;
#X msg 191 162 100 0 255;
#X msg 317 162 100 100 100;
#X msg 397 162 255 255 0;
#X msg 541 162 123 33 5;
#X msg 464 162 22 131 5;
#X msg 607 163 147 0 163;
#X connect 0 0 2 0;
#X connect 2 0 3 0;
#X connect 3 0 5 0;
#X connect 3 1 6 0;
#X connect 3 2 7 0;
#X connect 3 3 9 0;
#X connect 3 4 8 0;
#X connect 3 5 10 0;
#X connect 3 6 11 0;
#X connect 3 7 13 0;
#X connect 3 8 12 0;
#X connect 3 9 14 0;
#X connect 4 0 1 0;
#X connect 5 0 4 0;
#X connect 6 0 4 0;
#X connect 7 0 4 0;
#X connect 8 0 4 0;
#X connect 9 0 4 0;
#X connect 10 0 4 0;
#X connect 11 0 4 0;
#X connect 12 0 4 0;
#X connect 13 0 4 0;
#X connect 14 0 4 0;
#X restore 56 34 pd better_colors;
#X obj 56 78 del 50;
#X msg 170 17 bang;
#X text 200 114 width;
#X msg 29 428 label_pos \$1 21;
#X obj 479 124 list prepend set;
#X obj 479 146 list trim;
#X text 246 10 probably dangerous when initialized with loadbang!;
#X msg 29 383 66 ol_listsplit;
#X obj 28 775 s \$0-text1-r;
#X obj 195 719 pack s 0 0;
#X obj 195 775 s \$0-text2-r;
#X obj 351 719 pack s 0 0;
#X msg 351 740 label \$1 \, label_pos \$2 \$3;
#X obj 351 775 s \$0-text3-r;
#X obj 28 648 list prepend 0;
#X obj 564 567 + 14;
#X obj 564 590 + 14;
#X obj 28 510 t b b b b b b b, f 20;
#X obj 28 672 route 1 2 3, f 66;
#X msg 86 532 2, f 1;
#X msg 125 531 1, f 1;
#X msg 47 532 3, f 1;
#X msg 153 608 empty;
#X obj 531 272 loadbang;
#X msg 531 293 set -26;
#X floatatom 73 292 5 0 0 0 - - - 0;
#X symbolatom 108 292 20 0 0 0 - - - 0;
#X obj 73 333 pack 0 s;
#X obj 108 310 t b s;
#X obj 73 354 t b l;
#X msg 113 354 set \$1 \$2;
#X msg 73 261 set 66;
#X msg 479 80 520 50 600 400;
#X obj 493 448 pack 0 -26;
#X msg 135 584 (like a parsing mechanism);
#X msg 195 740 label \$1 \, label_pos \$2 \$3 \, label_font 1 10, f 23;
#X msg 106 560 split list into slices at specific symbol;
#X connect 4 0 5 0;
#X connect 6 0 16 0;
#X connect 8 0 34 0;
#X connect 8 0 55 0;
#X connect 8 0 56 0;
#X connect 10 0 9 0;
#X connect 11 0 51 0;
#X connect 13 0 20 0;
#X connect 14 0 13 0;
#X connect 14 1 6 0;
#X connect 16 0 17 1;
#X connect 17 0 54 0;
#X connect 21 0 17 0;
#X connect 22 0 69 0;
#X connect 22 0 93 0;
#X connect 23 0 65 0;
#X connect 23 1 10 0;
#X connect 28 0 76 0;
#X connect 29 0 30 0;
#X connect 30 0 79 0;
#X connect 30 1 40 0;
#X connect 30 1 58 0;
#X connect 33 0 79 0;
#X connect 34 0 7 0;
#X connect 35 0 25 0;
#X connect 37 0 38 0;
#X connect 38 0 70 0;
#X connect 39 0 37 1;
#X connect 39 0 71 1;
#X connect 39 0 73 1;
#X connect 39 1 49 0;
#X connect 40 0 39 0;
#X connect 41 0 95 0;
#X connect 42 0 43 0;
#X connect 43 0 95 0;
#X connect 43 1 95 1;
#X connect 44 0 40 0;
#X connect 45 0 33 0;
#X connect 45 1 40 0;
#X connect 45 2 44 0;
#X connect 49 0 37 2;
#X connect 49 0 77 0;
#X connect 50 0 12 0;
#X connect 51 0 12 0;
#X connect 52 0 26 0;
#X connect 52 0 31 0;
#X connect 52 0 32 0;
#X connect 53 0 34 0;
#X connect 54 0 8 0;
#X connect 55 0 11 0;
#X connect 56 0 35 0;
#X connect 57 0 62 0;
#X connect 57 1 59 0;
#X connect 58 0 52 0;
#X connect 58 0 50 0;
#X connect 59 0 58 0;
#X connect 60 0 61 0;
#X connect 61 0 57 0;
#X connect 62 0 14 0;
#X connect 63 0 61 0;
#X connect 65 0 9 0;
#X connect 66 0 67 0;
#X connect 67 0 6 0;
#X connect 69 0 23 0;
#X connect 71 0 97 0;
#X connect 73 0 74 0;
#X connect 74 0 75 0;
#X connect 76 0 80 0;
#X connect 77 0 71 2;
#X connect 77 0 78 0;
#X connect 78 0 73 2;
#X connect 79 0 84 0;
#X connect 79 1 83 0;
#X connect 79 2 96 0;
#X connect 79 3 81 0;
#X connect 79 4 98 0;
#X connect 79 5 82 0;
#X connect 80 0 37 0;
#X connect 80 1 71 0;
#X connect 80 2 73 0;
#X connect 81 0 76 1;
#X connect 82 0 76 1;
#X connect 83 0 76 1;
#X connect 84 0 28 0;
#X connect 85 0 86 0;
#X connect 86 0 42 0;
#X connect 87 0 89 0;
#X connect 88 0 90 0;
#X connect 89 0 91 0;
#X connect 90 0 87 0;
#X connect 90 1 89 1;
#X connect 91 0 69 0;
#X connect 91 1 92 0;
#X connect 92 0 69 0;
#X connect 93 0 87 0;
#X connect 94 0 4 0;
#X connect 94 0 66 0;
#X connect 95 0 45 0;
#X connect 96 0 28 0;
#X connect 97 0 72 0;
#X connect 98 0 28 0;
#X restore 19 48 pd init;
#X obj 11 11 cnv 8 597 55 \$0-bgnd \$0-bgnd-r empty 0 20 0 4 #168305 #168305 0;
#X obj 15 16 cnv 8 587 45 \$0-frame \$0-frame-r empty 20 20 0 14 #000000 
#fcfcfc 0;
#X obj 16 17 cnv 15 250 43 \$0-title \$0-title-r ol_listsplit 66 21 1 24 
#e4d0fc #0000fc 0;
#X obj 268 17 cnv 15 333 43 \$0-frame2 \$0-frame2-r empty 25 18 1 24 #d0d0fc 
#0400fc 0;
#X obj 300 65 cnv 1 1 1 \$0-text1 \$0-text1-r split list into slices at 
specific symbol 33 -33 1 11 #168305 #404040 0;
#X obj 300 65 cnv 1 1 1 \$0-text2 \$0-text2-r (like a parsing mechanism) 33 -19 
1 10 #168305 #404040 0;
#X obj 300 65 cnv 1 1 1 \$0-text3 \$0-text3-r empty 33 -5 1 11 #168305 #404040 
0;
#X obj 54 111 cnv 1 146 1 empty empty ARGUMENTS: (defaults) 1 -7 0 12 #404040 
#404040 0;
#X text 53 120 1.) split symbol (0) (if empty \, any symbol will do the split), 
f 64;
#X msg 53 171 a list with | an upright bar | (ascii 124) | as seperator | 0.5 
0.7 2 9, f 73;
#X obj 53 224 print OUTPUT_1;
#X msg 53 268 volume 0.5 pan 0.2 speed 1.4;
#X obj 53 451 print OUTPUT_2;
#X text 53 137 2.) flag: keep split symbol in result (0);
#X msg 367 237 _ maybe _ of no _ real use;
#X obj 367 290 print OUTPUT_3;
#X text 365 212 keep split symbol in results:;
#X obj 53 197 ol_listsplit |;
#X obj 367 263 ol_listsplit _ 1;
#X text 192 366 ("keep split symbol" flag is ignored in this mode);
#X text 173 352 --> any symbol will split (and is included in the result);
#X msg 132 395 symbol CUT;
#X text 238 395 split at specific symbol (also accepts float and "anything");
#X msg 53 293 just CUT 0.4 0.6 an CUT example;
#X msg 204 395 4;
#X msg 53 317 55 66 77 88 4 102 -33 4 88 99 33;
#X msg 122 353 symbol;
#X obj 53 424 ol_listsplit;
#X msg 72 353 bang;
#X text 107 354 =;
#X obj 368 437 ol_listsplit 4;
#X text 467 437 also possible;
#X connect 11 0 19 0;
#X connect 13 0 29 0;
#X connect 16 0 20 0;
#X connect 19 0 12 0;
#X connect 20 0 17 0;
#X connect 23 0 29 1;
#X connect 25 0 29 0;
#X connect 26 0 29 1;
#X connect 27 0 29 0;
#X connect 28 0 29 1;
#X connect 29 0 14 0;
#X connect 30 0 29 1;
#X coords 0 0 1 1 50 50 0;
---
pd-list@lists.iem.at - the Pure Data mailinglist
https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/message/DICO7JDAOU2N6HKHJ73P2EFM734EJDGH/

To unsubscribe send an email to pd-list-le...@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> https://lists.iem.at/

Reply via email to