digitalmars.D - (St)Range behavior
- Chris (14/14) Oct 25 2013 I have three lazy ranges tied together in a foreach loop like so:
- Meta (2/17) Oct 25 2013 Can you post some code?
- Chris (10/32) Oct 25 2013 And it is also circular. range3 sends it to range 1 again I must
- John Colvin (3/36) Oct 25 2013 How strange. Sorry, without seeing some code I doubt it's
- Chris (3/42) Oct 26 2013 I'll try to extract some code I can post next week, or if I fix
I have three lazy ranges tied together in a foreach loop like so: Item[] items; // An array of Item-struct foreach (item; items.range1.range2.range3) { // ... } The funny thing is that when I run the foreach loop it does everything in reverse. So I changed it to foreach (item; items.range3.range2.range1) { // ... } And now it works as expected. I've never had such strange behavior and have no clue what could have caused it. In all my other ranges it works from left to right 1. step, 2. step, 3. step and not from right to left.
Oct 25 2013
On Friday, 25 October 2013 at 11:06:18 UTC, Chris wrote:I have three lazy ranges tied together in a foreach loop like so: Item[] items; // An array of Item-struct foreach (item; items.range1.range2.range3) { // ... } The funny thing is that when I run the foreach loop it does everything in reverse. So I changed it to foreach (item; items.range3.range2.range1) { // ... } And now it works as expected. I've never had such strange behavior and have no clue what could have caused it. In all my other ranges it works from left to right 1. step, 2. step, 3. step and not from right to left.Can you post some code?
Oct 25 2013
On Friday, 25 October 2013 at 12:57:51 UTC, Meta wrote:On Friday, 25 October 2013 at 11:06:18 UTC, Chris wrote:And it is also circular. range3 sends it to range 1 again I must have screwed it up somewhere. Everything is ok, if I do it step by step: foreach (item; items.range1) {} foreach (item; items.range2) {} foreach (item; items.range3) {} Has anyone ever come across a bug like this? Each range works fine on its own. When I tie them together, they go upside down and in circles. Weird. Maybe I can extract some test code.I have three lazy ranges tied together in a foreach loop like so: Item[] items; // An array of Item-struct foreach (item; items.range1.range2.range3) { // ... } The funny thing is that when I run the foreach loop it does everything in reverse. So I changed it to foreach (item; items.range3.range2.range1) { // ... } And now it works as expected. I've never had such strange behavior and have no clue what could have caused it. In all my other ranges it works from left to right 1. step, 2. step, 3. step and not from right to left.Can you post some code?
Oct 25 2013
On Friday, 25 October 2013 at 14:02:54 UTC, Chris wrote:On Friday, 25 October 2013 at 12:57:51 UTC, Meta wrote:How strange. Sorry, without seeing some code I doubt it's possible to understand what's happening.On Friday, 25 October 2013 at 11:06:18 UTC, Chris wrote:And it is also circular. range3 sends it to range 1 again I must have screwed it up somewhere. Everything is ok, if I do it step by step: foreach (item; items.range1) {} foreach (item; items.range2) {} foreach (item; items.range3) {} Has anyone ever come across a bug like this? Each range works fine on its own. When I tie them together, they go upside down and in circles. Weird. Maybe I can extract some test code.I have three lazy ranges tied together in a foreach loop like so: Item[] items; // An array of Item-struct foreach (item; items.range1.range2.range3) { // ... } The funny thing is that when I run the foreach loop it does everything in reverse. So I changed it to foreach (item; items.range3.range2.range1) { // ... } And now it works as expected. I've never had such strange behavior and have no clue what could have caused it. In all my other ranges it works from left to right 1. step, 2. step, 3. step and not from right to left.Can you post some code?
Oct 25 2013
On Friday, 25 October 2013 at 16:17:24 UTC, John Colvin wrote:On Friday, 25 October 2013 at 14:02:54 UTC, Chris wrote:I'll try to extract some code I can post next week, or if I fix it, will let you know what it was.On Friday, 25 October 2013 at 12:57:51 UTC, Meta wrote:How strange. Sorry, without seeing some code I doubt it's possible to understand what's happening.On Friday, 25 October 2013 at 11:06:18 UTC, Chris wrote:And it is also circular. range3 sends it to range 1 again I must have screwed it up somewhere. Everything is ok, if I do it step by step: foreach (item; items.range1) {} foreach (item; items.range2) {} foreach (item; items.range3) {} Has anyone ever come across a bug like this? Each range works fine on its own. When I tie them together, they go upside down and in circles. Weird. Maybe I can extract some test code.I have three lazy ranges tied together in a foreach loop like so: Item[] items; // An array of Item-struct foreach (item; items.range1.range2.range3) { // ... } The funny thing is that when I run the foreach loop it does everything in reverse. So I changed it to foreach (item; items.range3.range2.range1) { // ... } And now it works as expected. I've never had such strange behavior and have no clue what could have caused it. In all my other ranges it works from left to right 1. step, 2. step, 3. step and not from right to left.Can you post some code?
Oct 26 2013