# Select elements of a list based on a condition and order position?

Posted 9 months ago
779 Views
|
2 Replies
|
1 Total Likes
|
 I encounter a common problem in data science that is difficult to solve in some languages and easier in others, and I'm wondering how Wolfram language can solve it. In ordered lists, there is an implicit "before" and "after" relationship. Often I need to select or operate on this element after a conditional. For instance, in the english word list, return the letters (and perhaps make a histogram) that follow the letter "i", to prove or disprove "i before e, except after c". Another example, given a list of dates with an associated measure for each, calculate the difference of the measures between any two dates. The most needed calculation is "now" from "last".Trigger events are another variation of this problem, i.e. capture all elements that meet "this" criteria, after "that" condition has been set. I've used this extensively in digital signal processing and other pattern recognition programs. Thanks.
2 Replies
Sort By:
Posted 9 months ago
 The first type of problem can be handled by Select with a string pattern. The second could be done with Outer or Table, depending on how important it is to avoid comparing with previous elements. The third might be best done programmatically using Table though in some cases careful use of Select should work (I am not sure offhand that Select is actually guaranteed to work sequentially, but it does).Much easier to respond with actual code if you provide concrete examples (input code, that is) and concrete criteria.