True, so now it should be OK (patch attached).
I didn't think of this eventuality.
++

Jack



Le mardi 27 avril 2010 à 20:50 -0400, Matt Barber a écrit :
> One thing to watch out for;  if you get two items in the list that are
> equally as far as the test value, mine outputs one list with the value
> replacement at each appropriate index, while Jack's outputs several
> lists with the value replacement at only one index, but each
> replacement sequentially, if that makes any sense.
> 
> So if the test value is 2.02, and the input list is <1 0 3 2 4 3 3 2 0
> 4>, mine will output:
> 
> <1 0 3 2.02 4 3 3 2.02 0 4> as one list, while Jack's gives two lists:
> 
> <1 0 3 2.02 4 3 3 2 0 4>
> <1 0 3 2 4 3 3 2.02 0 4>
> 
> Matt
> 
> On Tue, Apr 27, 2010 at 8:16 PM, Jack <[email protected]> wrote:
> > 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>
> >> _______________________________________________
> >> [email protected] mailing list
> >> UNSUBSCRIBE and account-management -> 
> >> http://lists.puredata.info/listinfo/pd-list
> >
> >

#N canvas 539 25 450 440 10;
#X obj 136 89 list-drip;
#X obj 136 112 -;
#X obj 136 132 abs;
#X obj 119 204 list-minmax;
#X obj 119 227 list-find;
#X obj 119 182 t l l;
#X obj 119 297 list-replace;
#X obj 119 274 f;
#X obj 119 250 t b f;
#X obj 219 37 inlet;
#X obj 102 37 inlet;
#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 1.02 2.02 0.98 0.02 1.98 0.98 0.98 0.02 2.02 1.98;
#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 119 159 pd list;
#X text 262 322 Jack/RYBN 2010;
#X obj 205 297 t l;
#X obj 102 322 list;
#X obj 102 346 outlet;
#X obj 102 61 t b b l b;
#X connect 0 0 1 0;
#X connect 1 0 2 0;
#X connect 2 0 11 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 13 0;
#X connect 6 0 14 1;
#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 16 0;
#X connect 11 0 5 0;
#X connect 13 0 6 2;
#X connect 14 0 15 0;
#X connect 16 0 14 0;
#X connect 16 1 11 0;
#X connect 16 2 0 0;
#X connect 16 2 6 2;
#X connect 16 3 11 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 obj 118 121 list trim;
#X obj 91 301 list prepend set;
#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 msg 91 162 1 0 3 2 4 3 3 2 0 4;
#X obj 91 232 list-replace-closest;
#X msg 91 343 1 0 3 2.02 4 3 3 2.02 0 4;
#X connect 0 0 11 1;
#X connect 1 0 3 0;
#X connect 2 0 1 0;
#X connect 3 0 10 0;
#X connect 3 1 4 0;
#X connect 4 0 5 0;
#X connect 5 0 10 0;
#X connect 6 0 7 0;
#X connect 7 0 12 0;
#X connect 10 0 11 0;
#X connect 11 0 6 0;
_______________________________________________
[email protected] mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list

Reply via email to