Re: [racket-users] Cleanest way to locate contiguous sequences? (as part of reuniting segments of a file)

2016-12-02 Thread David Storrs
Hi Jon, That sounds excellent. Always preferable to find a better algorithm, and I wasn't familiar with interval trees. Thanks for the pointer. Dave On Fri, Dec 2, 2016 at 3:18 PM, Jon Zeppieri wrote: > You could use an interval tree instead of a list. Before inserting

Re: [racket-users] Cleanest way to locate contiguous sequences? (as part of reuniting segments of a file)

2016-12-02 Thread Jon Zeppieri
You could use an interval tree instead of a list. Before inserting into it, you could check to see if your current chunk number is contiguous with an existing interval in the tree. If so, merge the chunks and expand the existing interval. Otherwise, insert an interval of size 1 into the tree.

Re: [racket-users] Cleanest way to locate contiguous sequences? (as part of reuniting segments of a file)

2016-12-02 Thread David Storrs
Thanks, Dan. Working with shifted lists is an interesting technique that I'll keep in my quiver. I appreciate you taking the time. On Fri, Dec 2, 2016 at 1:56 PM, Daniel Prager wrote: > Perhaps this is a more elegant approach to the tactical problem: >

Re: [racket-users] Cleanest way to locate contiguous sequences? (as part of reuniting segments of a file)

2016-12-02 Thread Daniel Prager
Perhaps this is a more elegant approach to the tactical problem: simultaneously iterating over displaced versions of the original list. E.g. _x '(1 1 2 3 5 7 200 201 202) ; shifted right x '(1 2 3 5 7 200 201 202 203) ; original list x_ '(2 3 5 7 200 201 202 203 203) ; shifted left When

[racket-users] Cleanest way to locate contiguous sequences? (as part of reuniting segments of a file)

2016-12-02 Thread David Storrs
This is a more business-logic as opposed to syntax/technique question than usually shows up on this list, but hopefully folks won't mind. I started off to ask "what's the best way to find contiguous sequences of numbers in a list?" and then realized that maybe I should answer the "What are you