Re: [julia-users] Re: Iteration over a Set where elements may be deleted in the process -- bug?

2014-02-28 Thread David P. Sanders
El jueves, 27 de febrero de 2014 18:45:35 UTC-6, Kevin Squire escribió: So, no one has really explained why this is happening. Sets are built on top of hash tables. The hash table itself is just an array, many entries of which are not being used. As with all iteration in Julia, for

[julia-users] Re: Iteration over a Set where elements may be deleted in the process -- bug?

2014-02-28 Thread Pierre-Yves Gérardy
To realize what you want to do, you can add the elements to be removed to another set. On each iteration, verify that the current element isn't already in the set of elements to be removed, and after the loop, clean the first set using the elements of the second one. —Pierre-Yves On

[julia-users] Re: Iteration over a Set where elements may be deleted in the process -- bug?

2014-02-28 Thread David P. Sanders
El viernes, 28 de febrero de 2014 16:41:20 UTC-6, Pierre-Yves Gérardy escribió: To realize what you want to do, you can add the elements to be removed to another set. On each iteration, verify that the current element isn't already in the set of elements to be removed, and after the

[julia-users] Re: Iteration over a Set where elements may be deleted in the process -- bug?

2014-02-27 Thread David P. Sanders
El jueves, 27 de febrero de 2014 09:54:58 UTC-6, David P. Sanders escribió: I need to iterate over a Set whose elements will be deleted in the process. However, some deleted elements are included in the iteration, e.g. the element 4 in the code below. According to the following, it is

Re: [julia-users] Re: Iteration over a Set where elements may be deleted in the process -- bug?

2014-02-27 Thread Stefan Karpinski
Modifying a collection while iterating over it is likely to cause strange things to happen. I have worried about this from time to time but I'm not sure how to fix it. One approach is to advance the state in next before returning the element, then always return an element that you know must be in

Re: [julia-users] Re: Iteration over a Set where elements may be deleted in the process -- bug?

2014-02-27 Thread Mauro
In Python it's bad to insert/delete items as well. And people do get bitten. That doesn't mean it shouldn't be fixed though. On Thu, 2014-02-27 at 16:23, ste...@karpinski.org wrote: Modifying a collection while iterating over it is likely to cause strange things to happen. I have worried

Re: [julia-users] Re: Iteration over a Set where elements may be deleted in the process -- bug?

2014-02-27 Thread andrew cooke
true; but in python you get an exception. julia is silently trashing the data... andrew On Thursday, 27 February 2014 13:43:56 UTC-3, Mauro wrote: In Python it's bad to insert/delete items as well. And people do get bitten. That doesn't mean it shouldn't be fixed though. On Thu,

Re: [julia-users] Re: Iteration over a Set where elements may be deleted in the process -- bug?

2014-02-27 Thread Kevin Squire
So, no one has really explained why this is happening. Sets are built on top of hash tables. The hash table itself is just an array, many entries of which are not being used. As with all iteration in Julia, for iteration over a Set, start, next, and done functions are defined (see

Re: [julia-users] Re: Iteration over a Set where elements may be deleted in the process -- bug?

2014-02-27 Thread andrew cooke
eh? the code tries to delete all entries and, instead of an exception, data remains. are you saying that's not trashing because the remaining value was there initially? [big lebowski springs to mind] i guess what i meant was something more along the lines of - the output from the routine

Re: [julia-users] Re: Iteration over a Set where elements may be deleted in the process -- bug?

2014-02-27 Thread andrew cooke
oh, i'm sorry. no, i;m wrong. i missed the -1. ive completely misunderstood the thread. :o( sorry again, andrew On Thursday, 27 February 2014 22:18:49 UTC-3, andrew cooke wrote: eh? the code tries to delete all entries and, instead of an exception, data remains. are you saying