Re: Getting equivalent elements in a range/array

2011-05-08 Thread Ali Çehreli
On 05/07/2011 09:07 PM, Andrej M. wrote: I want to turn this: auto arr = [1, 1, 2, 3, 4, 4]; into this: auto arr2 = [[1, 1], [2], [3], [4, 4]]; I want an array of arrays of the same elements. Lazy or not, I don't care. I thought I could get away with this inside some while loop: auto equals =

Re: Getting equivalent elements in a range/array

2011-05-08 Thread bearophile
Andrej M.: I want to turn this: auto arr = [1, 1, 2, 3, 4, 4]; into this: auto arr2 = [[1, 1], [2], [3], [4, 4]]; I want an array of arrays of the same elements. Lazy or not, I don't care. Currently if you use group like this: writeln(arr.group()); You get: [Tuple!(int,uint)(1, 2),

Re: Getting equivalent elements in a range/array

2011-05-08 Thread Andrej Mitrovic
Thanks, group seems to work fine too.

Getting equivalent elements in a range/array

2011-05-07 Thread Andrej M.
I want to turn this: auto arr = [1, 1, 2, 3, 4, 4]; into this: auto arr2 = [[1, 1], [2], [3], [4, 4]]; I want an array of arrays of the same elements. Lazy or not, I don't care. I thought I could get away with this inside some while loop: auto equals = array(filter!a == b(arr)); arr =