Merhaba,
Dertliyim dostlar 2 saattir dizimden toplu bir şekilde eleman çıkarmaya çalışıyorum:
import std.stdio;
import std.math;
import std.range;
import std.algorithm;
import std.typecons;
int[][4] tempMap;
void main()
{
int[] temp = [ 1, 2, 3 , 4 ,5 ];
tempMap[0] = temp.dup;
tempMap[1] = temp.dup;
tempMap[2] = temp.dup;
tempMap[3] = temp.dup;
int[] removeList;
for ( int i = 0; i < tempMap[0].length; i++ )
{
if ( i%2 == 0 )
removeList ~=i;
}
writeln(removeList);
tempMap[1].remove(0,2,4);
tempMap[2].remove(removeList);
tempMap[3].remove(tuple(0,1),tuple(2,3),tuple(4,5) );
//tempMap[1].length -= 2;
writeln(tempMap);
}
writeln(removeList); [0, 2, 4] yazdırıyor.
tempMap[1].remove(0,2,4); --> Tam istediğimi yapıyor. [2, 4, 3, 4, 5]
tempMap[2].remove(removeList); ---> Bambaşka bir sonuç veriyor. [3, 4, 5, 4, 5]
tempMap[3].remove(tuple(0,1),tuple(2,3),tuple(4,5) ); --> Buda oluyor
Ben 'removeList' 'i nasıl "0,2,4" şeklinde bir sequence 'a çevirebilirim a dostlar.
Erdem .
--
[ Bu gönderi, http://ddili.org/forum'dan dönüştürülmüştür. ]