Questions tagged [indices]

Use this tag for questions about specifying or selecting the correct information from a structure using indices.

For any set of records, indices are identifiers of which specify information of the address of each record.

Check the Wikipedia page for arrays to know more.

882 questions
-2
votes
2 answers

R: Select multiple values from vector of sequences

In R I'm trying to figure out how to select multiple values from a predefined vector of sequences (e.g. indices = c(1:3, 4:6, 10:12, ...)). In other words, if I want a new vector with the 3rd, 5th, and 7th entries in "indices", what syntax should I…
ksed
  • 335
  • 1
  • 4
  • 13
-2
votes
1 answer

MS SQL: Do you only index tables with many columns?

I have local temp tables and they generally have only two to three columns, can these be indexed?
KOddo
  • 107
  • 1
  • 8
-2
votes
2 answers

Matlab: changing zero-one index vector to proper index vector

Suppose an index vector in binary like below Input 1 1 0 0 1 0 1 1 2 3 4 5 6 7 Intended output 1 2 5 7 which denotes nth number to be chosen. So I want to change 1 1 0 0 1 0 1 to 1 2 5 7, is there some easy way for this?
hhh
  • 50,788
  • 62
  • 179
  • 282
-3
votes
2 answers

How can I obtain the elements in a single list with specified indices?

Suppose I have a list li = ['a0','b0','c0','a1','b1','c1',...,'an','bn','cn'] I want to obtain ['a0',...,'an'], ['b0',...,'bn'], ['c0',...,'cn'] using a for loop. I'm trying to do something like for i in range(3): # for a,b,c lis = [li[i][k]…
IGY
  • 199
  • 1
  • 4
-3
votes
3 answers

Running through a list of Strings with a for loop

I want all the contents of subplot_list to be printed one by one however I am getting a type error of list indices must be integers or slices, not str. Is there a way I could bypass this. subplot_list = ['a1', 'a2', 'a3','c1','c2','c3'] for i in…
-3
votes
2 answers

Translate numpy digitize function into c#

Digitize function return the indices of the bins to which each value in input array belongs. Below code is from python - x = np.array([0.8, 6.9, 3.5, 1.9]) bins = np.array([0.0, 1.0, 2.5, 4.0, 10.0]) inds = np.digitize(x, bins) print(inds) array([1,…
-3
votes
1 answer

How is the negative index in this C code producing the given output?

Here is a C code: #include void fun(char**); int main() { char*argv[] = {"ab","cd","ef","gh"}; fun(argv); return 0; } void fun(char**p) { char* t; t = (p+=sizeof(int))[-1]; //negative index printf("%s\n",t); } I executed…
Midhun
  • 744
  • 2
  • 15
  • 31
-3
votes
2 answers

Find starting and ending indices of list chunks satisfying given condition

I am trying to find the start and stop indices of chunks of positive numbers in a list. cross = [7,5,8,0,0,0,0,2,5,8,0,0,0,0,8,7,9,3,0,0,0,3,2,1,4,5,0,0,0,7,5] For the given example input, the desired output is: [(0, 2), (7, 9), (14, 17), (21,…
-3
votes
1 answer

In C# is it possible to have an custom Indexer property of a type that is NOT a string or an int?

In C# is it possible to have an Indexer property of a type that is not a string or an int? For example I have a custom object that is a map of 2D vector coordinates. Taking the basics of my map class to be... public class TileMap { ///…
Dib
  • 2,001
  • 2
  • 29
  • 45
-3
votes
2 answers

Perl - searching for partial matches in string array and returning matching indices

Suppose I have a string array @file_paths which contains @file_paths= ["C:\Lazy\FolderA\test.cpp", "C:\Lazy\FolderA\test2.cpp", "C:\Lazy\FolderB\test.cpp", "C:\Lazy\FolderB\test2.cpp", ... etc] I want to be able to find the array…
Mark Kennedy
  • 1,751
  • 6
  • 30
  • 53
-4
votes
1 answer

Finding indices of matrices while traversing

I have a matrix: 1|2|3|4 4|5|6|7 7|8|9|10 10|11|12|13 I want to multiply the indices of this matrix with indices of another matrix of different size: 7|8|9 9|10|10 10|11|11 for these two matrices I have used the following for loops: for x=1:4 …
Ajax
  • 17
  • 3
-5
votes
1 answer

matlab indices not in range?

I'm trying to write the optimal quantization for IP. I'm new to matlab and in this code, i'm trying to go over every pixel in every interval of Z, multiply it with it's histogram and sum it , so I can calculate the optimal Q. problem : Attempted to…
Maroun Sassine
  • 319
  • 5
  • 14
1 2 3
58
59