Re: [julia-users] map and map! on Sets

2014-05-13 Thread Milan Bouchet-Valat
Le mardi 13 mai 2014 à 00:39 -0400, Stefan Karpinski a écrit : I'm not sure that map! on a Set makes sense. The behavior of map! is that it replaces each element of a collection with a transformed value of that element. Implicit in that is that there is a notion of position – a place where the

Re: [julia-users] map and map! on Sets

2014-05-13 Thread Stefan Karpinski
On Tue, May 13, 2014 at 5:38 AM, Milan Bouchet-Valat nalimi...@club.frwrote: IMHO map! isn't very helpful for Sets not because there's no order, but because it doesn't replace elements in the same memory slot, like it would in an array. I didn't actually say anything about order, but rather

Re: [julia-users] map and map! on Sets

2014-05-13 Thread Milan Bouchet-Valat
Le mardi 13 mai 2014 à 09:34 -0400, Stefan Karpinski a écrit : On Tue, May 13, 2014 at 5:38 AM, Milan Bouchet-Valat nalimi...@club.fr wrote: IMHO map! isn't very helpful for Sets not because there's no order, but because it doesn't replace elements in the same memory

Re: [julia-users] map and map! on Sets

2014-05-13 Thread Kevin Squire
Thinking about it, map! could be implemented by creating and filling in a new Set, then moving the underlying members back to the original Set. It's kinda kludgy, and wouldn't be any more efficient, but it would allow for a convenient and uniform interface. Thoughts? Andrew, I'll reiterate that

Re: [julia-users] map and map! on Sets

2014-05-13 Thread Ivar Nesje
Wouldn't it be faster to copy all the elements of the set into an array, empty the set, and then fill the modified values back? kl. 21:03:47 UTC+2 tirsdag 13. mai 2014 skrev Kevin Squire følgende: Thinking about it, map! could be implemented by creating and filling in a new Set, then moving

Re: [julia-users] map and map! on Sets

2014-05-13 Thread Stefan Karpinski
Yes, that seems better. On Tue, May 13, 2014 at 3:16 PM, Ivar Nesje iva...@gmail.com wrote: Wouldn't it be faster to copy all the elements of the set into an array, empty the set, and then fill the modified values back? kl. 21:03:47 UTC+2 tirsdag 13. mai 2014 skrev Kevin Squire følgende:

Re: [julia-users] map and map! on Sets

2014-05-13 Thread Andrew Dabrowski
So this would involve adding a map method to base/set.jl? On Tuesday, May 13, 2014 3:03:47 PM UTC-4, Kevin Squire wrote: Andrew, I'll reiterate that a pull request would be very welcome. I think you would find the Set functionality rather self contained, and the map function implementation

Re: [julia-users] map and map! on Sets

2014-05-13 Thread Stefan Karpinski
Yes, that's right. On Tue, May 13, 2014 at 3:31 PM, Andrew Dabrowski unhandya...@gmail.comwrote: So this would involve adding a map method to base/set.jl? On Tuesday, May 13, 2014 3:03:47 PM UTC-4, Kevin Squire wrote: Andrew, I'll reiterate that a pull request would be very welcome. I

Re: [julia-users] map and map! on Sets

2014-05-13 Thread Kevin Squire
I'm not sure that would be better. rehash() will be called as soon as you start inserting elements, because more than 3/4 of the elements will have been deleted. On Tue, May 13, 2014 at 12:20 PM, Stefan Karpinski ste...@karpinski.orgwrote: Yes, that seems better. On Tue, May 13, 2014 at

[julia-users] map and map! on Sets

2014-05-12 Thread Andrew Dabrowski
I see that map and map! do not play nice with Sets. Are there plans to improve the situation, or should I learn to live with it?

Re: [julia-users] map and map! on Sets

2014-05-12 Thread Kevin Squire
`map` seems to work for me: julia a = Set([1,2,3]) Set{Int64}({2,3,1}) julia map(x-2x, a) 3-element Array{Any,1}: 4 6 2 Can you give an example where it doesn't? `map!` wouldn't give you any benefit in working with Sets in Julia. The values in sets are inserted into a hash table, and since

Re: [julia-users] map and map! on Sets

2014-05-12 Thread Stefan Karpinski
I'm not sure that map! on a Set makes sense. The behavior of map! is that it replaces each element of a collection with a transformed value of that element. Implicit in that is that there is a notion of position – a place where the original element was and where the transformed value can go. In a