round values to next in list...
really simple problem i think, but i cant think of any simple solution - maybe you guys have an idea how to do this:
I have a list of variable length with floats. eg: [10. 34.5 50. 72.] and an input value from 0. to 100.. now what i want is a simple function wich outputs 10. for the input range of 0. to 10.; 34.5 for the input range of 10.000001 to 34.5; 50 .... ect. you get the idea.
whats the easiest and most efficient way to create such a function with a variable number of points?
best,
plinio
i thought about writing the values into a buffer and reading from that - but thats to much msp for me...
okay - for now i used the function object - looking for better ideas though.
With a handful of values like you have, [split] could work. The challenge might be assigning the min/max and output values as the input list changes
if the lists are short, say of 5 elements, something like split would be perfect.
if the lists contain 100 elements, you better try to iterate it and build the process around single elements.
I call this "quantize to list". Enjoy :)
here's my solution with an iterative process. Note, here I'm rounding to the nearest value in the list. So it's not always rounding up or down. So it's a bit different than the OP requested. However it's a 10 year old issue anyways. Just posting for documentation :), in case someone needs it. Or if anybody has a more elegant idea, I'd be curious.
@ak's solution is very elegant.
max 4 version. ;)
the stuff in the panel is [zl.sum]
