Getting equivalent elements in a range/array
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 = arr[equals.length-1..$]; Nope. I need this for some buffered output, where the requirement is the elements of the buffer all need to have the same properties so a function can output a buffer of elements in one call instead of calling the function for each element (the function call is expensive).
Removing an object from a range
I can't seem to find an easy remove method in std.algorithm that takes an object and a range (an array in this case) and removes any matches from the range. I'm using this snippet for now: private DrawingElement[] elements; public override void Remove(DrawingElement d) { foreach (i, child; elements) { if (child == d) { elements = remove(elements, i); break; } } } Ugly! :) It's a direct port from some C# code so don't mind the silly variable names.
Stoping VS2005 from closing the damn console window
I'm trying to get VS 2005 to stop closing the command window when I'm running examples from the Learn to tango with D book. (I'm using that VS plugin from Dsource.org) I've tried running the examples with and without debugging, but the command window still closes down rapidly. I've even tried using a function to wait for user input.. but that won't work either. I've no idea what's going on. Here's a peace of code I've tried: [code] import tango.io.Console; void main() { Cout (What is your name? ) (); auto name = Cin.get(); Cout (Hello ) (name).newline; } [/code]