500, apparently I misunderstood your question, so please disregard my answers for the time being. I'll leave them for reference. I am too tired to fix it now.
–
Mr.Wizard♦Feb 25 '12 at 3:14

500, just FYI, you're getting you've been using backquotes () instead of an apostrophe (') in contractions. For example "dont" instead of "don't", which causes problems with the formatting of your posts.
–
Brett ChampionFeb 25 '12 at 5:36

This reminds me of things like KagiChart and RenkoChart which have similar behavior. It's not easy to clearly and concisely describe them either.
–
Brett ChampionFeb 25 '12 at 5:38

6 Answers
6

In contrast to the very fast methods presented, let me give you a maybe more easy to understand solution (while this in the eye of the beholder). Basically it's sort of the way I would implement it in Haskell.

Assume you want to solve your problem step by step and in each step you have your data in the form {res, in} where res is your current solution and in is the rest of the input which needs to be processed. The initial situation is that the list res contains your first element and in contains the rest of the input. Let's go through the two possible situations:

Since res is your current output, you always want to compare the last element of this with the first element of your in list. When the absolute difference is larger then 5, you want to append this first element of in to your res list.

In all other cases, you just want to throw away the first element of in and leave res untouched.

You want to iterate this as long as there are elements in your input. Thats all, and you can write it directly down:

How could I now store as a sublist every element skipped in between
the z points in addition to the the z point themselves. I would like
to have the list of the coordinates that do not pass the test, but
sublists for each group of point skipped in between two Sow[].

@Brett Since two notes of incorrect output have been made I perhaps didn't understand the question. What output do you expect for that list?
–
Mr.Wizard♦Feb 25 '12 at 2:51

Btw, I had written a similar solution and deleted it in a panick attack. It had a bug however not sowing the first element, that you neatly dealt with with that Infinity. +1 for the Infinity, hehe
–
RojoFeb 25 '12 at 4:59

I think your first function works not correctly. Can you test the input {20, 56, 57, 62, 20}?
–
halirutanFeb 25 '12 at 1:58

@halirutan Since two notes of incorrect output have been made I perhaps didn't understand the question. What output do you expect for that list?
–
Mr.Wizard♦Feb 25 '12 at 2:51

2

@MrWizard I expect {20, 56, 62, 20}. You misunderstood maybe, that after the test for (56,57) fails, 56 is kept as *reference element` until a test succeeds.
–
halirutanFeb 25 '12 at 3:08

1

@Mr.Wizard, this one yes shows you misunderstood. It doesn't do the same as your previous answer. This one only collects those contiguous jumps above delta, but he wants to go dropping values until you get to the delta difference. So if delta=3, {0, 1, 2, 3, 4, 5, 6,7,8} should give {0, 4, 8} if I understood
–
RojoFeb 25 '12 at 5:02

@Mr.Wizard yeah, they seem to work well if I understood the problem. I was wrong with my comment on the other post the other day, I had a blank and thought Sow as something that returned Null. +1 on this one now
–
RojoFeb 27 '12 at 0:19

Mathematica is a registered trademark of Wolfram Research, Inc. While the mark is used herein with the limited permission of Wolfram Research, Stack Exchange and this site disclaim all affiliation therewith.