An alternative. Also full pure-pd.
++

Jack



Le mardi 27 avril 2010 à 18:49 -0400, Matt Barber a écrit :
> Try the attached (threw together using list-abs) -- right inlet is the
> value (12 in your example) and left inlet is the list of floats; I
> think this follows established list-abs syntax.
> 
> It's possible that I overlooked a list-abs that already does this, and
> there is probably a step or two you could skip.
> 
> You might get poor results if the list is a bang or contains symbols.
> 
> Matt
> 
> 
> > Hello everyone,
> >
> > I would like to compare all the values in a list with a value of input and
> > then decide which is the closest value and replace that value closer to the
> > amount of input.
> >
> > For example, I have a list <2, 10, 35> and have an input value of <12> I
> > would like the list as output <2, 12, 35>. I'm almost getting, but the patch
> > is so ugly that I will not show here, i'm sure there is a more elegant
> > solution. Does anyone have an idea?
> > tnx ;)
> > -------------- next part --------------
> > An HTML attachment was scrubbed...
> > URL: 
> > <http://lists.puredata.info/pipermail/pd-list/attachments/20100427/ac720c09/attachment-0001.htm>
> _______________________________________________
> Pd-list@iem.at mailing list
> UNSUBSCRIBE and account-management -> 
> http://lists.puredata.info/listinfo/pd-list

#N canvas 539 25 450 440 10;
#X obj 142 89 list-drip;
#X obj 142 112 -;
#X obj 142 132 abs;
#X obj 123 204 list-minmax;
#X obj 123 227 list-find;
#X obj 123 182 t l l;
#X obj 123 297 list-replace;
#X obj 123 274 f;
#X obj 123 250 t b f;
#X obj 219 37 inlet;
#X obj 123 37 inlet;
#X obj 123 321 outlet;
#N canvas 773 262 450 300 list 0;
#X obj 135 32 inlet;
#X obj 135 162 outlet;
#X obj 235 32 inlet;
#X msg 235 55 set;
#X msg 135 111 67 57 2 37 60 4 66 4 41 6;
#X msg 192 85 add2 \$1;
#X obj 135 61 route bang;
#X connect 0 0 6 0;
#X connect 2 0 3 0;
#X connect 3 0 4 0;
#X connect 4 0 1 0;
#X connect 5 0 4 0;
#X connect 6 0 4 0;
#X connect 6 1 5 0;
#X restore 123 159 pd list;
#X obj 123 62 t b l b;
#X text 262 322 Jack/RYBN 2010;
#X connect 0 0 1 0;
#X connect 1 0 2 0;
#X connect 2 0 12 0;
#X connect 3 0 4 0;
#X connect 4 0 8 0;
#X connect 5 0 3 0;
#X connect 5 1 4 1;
#X connect 6 0 11 0;
#X connect 7 0 6 0;
#X connect 8 0 7 0;
#X connect 8 1 6 1;
#X connect 9 0 1 1;
#X connect 9 0 7 1;
#X connect 10 0 13 0;
#X connect 12 0 5 0;
#X connect 13 0 12 0;
#X connect 13 1 0 0;
#X connect 13 1 6 2;
#X connect 13 2 12 1;
#N canvas 0 0 758 388 10;
#X floatatom 208 211 5 0 0 0 - - -;
#X obj 91 56 list-random 100 10;
#X msg 91 30 bang;
#X obj 91 81 t b a;
#X obj 118 101 list prepend set;
#X msg 91 162 4 56 90 62 50 17 2 40 82 17;
#X obj 118 121 list trim;
#X obj 91 301 list prepend set;
#X msg 91 343 4 56 168 62 50 17 2 40 82 17;
#X obj 91 321 list trim;
#X text 250 211 <- the closest number in the list will be replace by
this one;
#X text 129 29 <- generate a random list;
#X obj 91 232 list-replace-closest;
#X connect 0 0 12 1;
#X connect 1 0 3 0;
#X connect 2 0 1 0;
#X connect 3 0 5 0;
#X connect 3 1 4 0;
#X connect 4 0 6 0;
#X connect 5 0 12 0;
#X connect 6 0 5 0;
#X connect 7 0 9 0;
#X connect 9 0 8 0;
#X connect 12 0 7 0;
_______________________________________________
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list

Reply via email to