stupid list processing problem

Mar 9, 2013 at 7:23pm

stupid list processing problem

ok, this is embarrasing because i’m quite sure this is dead drop simple but somehow the solution keeps hiding from me…:

i have a stream of single numbers coming in, ranging from 0 to 50.000.
now i want to simply filter out any number where the difference to the last one is bigger than 100.
i get it almost to work with a bucket and a gate if there is only one false number but not if there are consecutive false ones because then the bucket fills up with false numbers…

the output should be like the following:
input — output
20 — 20
80 — 80
10 — 10
1000 — 10 (blocked because difference > 100)
500 — 10 (blocked because difference > 100)
300 — 10 (blocked because difference > 100)
109 — 109
60 — 60
150 — 150
10 — 150 (blocked because difference > 100)
etc.

how would i do that?
thanks for helping out…
k

#66979
Mar 9, 2013 at 10:30pm

Something like this?

– Pasted Max Patch, click to expand. –
#241070
Mar 10, 2013 at 1:03am

or this?
(basically the same concept)

– Pasted Max Patch, click to expand. –
#241071
Mar 10, 2013 at 1:55pm

yes, precisely like this. i was stuck with the idea of needing a bucket but this is much more elegant – comfys patch does exactly what i was trying to do!
once again, thank you so much for the help!
k

#241072
Mar 10, 2013 at 2:56pm

A compact 3 object version:

– Pasted Max Patch, click to expand. –
#241073
Mar 10, 2013 at 3:12pm

Hi,

2 objects ?

But not exactly what you asked (the 109 is skipped also, but it seems you get it only with comfy suggestion).

– Pasted Max Patch, click to expand. –
#241074
Mar 10, 2013 at 3:26pm

Nice one Nicolas! I had no idea about zl’s stream mode or that you could put the code I had in expr into ‘if’ – super useful.

#241075
Mar 10, 2013 at 4:28pm

@leafcutter: almost… ;-)

– Pasted Max Patch, click to expand. –

Personally I’m disappointed that nobody posted GEN solution…

#241076
Mar 12, 2013 at 5:25pm

Here’s one that checks against last input and another that checks against last output.

cheers

– Pasted Max Patch, click to expand. –
#241077

You must be logged in to reply to this topic.