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
-1
votes
2 answers

Adding indices to each character in a substring of a string

I was writing a Python program to generate all possible substrings of a given input string using itertools. def substring_generator(seq): substring_list = list(seq) return chain.from_iterable(combinations(substring_list, r) for r in…
user68472
  • 1
  • 1
-1
votes
2 answers

Why does not the negative indices in python strings result as expected?

I created a string in python : 'HelpA' and labeled it as word. >>>word='HelpA' >>>word 'HelpA' #expected string >>>word[0:4] 'Help' #expected string While calling the word with negative indices, I am getting the full string instead of partial…
Vikranth Inti
  • 125
  • 5
  • 13
-1
votes
2 answers

Converting Matlab to Python, errors with arrays and for loops

I am pretty new to programming so be patient with me lol. I am trying to convert an example code of matlab to python but I am having trouble with arrays in for loops and keep getting index errors. Here is the given MatLab Code: clear all close…
-1
votes
1 answer

Python: How do I find the first letter of a string?

For example, if I had the string thisisastring how could I find the first character? Is there an easy way to do this? Thank you!
Alex
  • 21
  • 1
  • 1
-1
votes
1 answer

Find the indicies of common tuples in two list of tuples without loop in Python

How can one find the indexes of the common tuples in two list of tuples? tuplelist1 = [("a","b"), ("c","d"), ("e","f"), ("g","h")] tuplelist2 = [("c","d"),("e","f")] So the indices in tuplelist1 that are common with tupplelist2 are indices 1 and…
Emmanuel Sunil
  • 243
  • 4
  • 16
-1
votes
1 answer

Array Indices vs Array Elements

This is a sort of meta-question related to this question: How do I write a branchless std::vector scan?. The question originally stated (emphasis mine): I have a std::vector data; and I want to find all the array indexes that are less than 9…
Marc.2377
  • 7,807
  • 7
  • 51
  • 95
-1
votes
1 answer

Keep getting type error python

I am doing a search query with jqGrid. My parameters are as…
grashopr
  • 3
  • 1
  • 4
-1
votes
1 answer

Matlab subscript error

I am writing a simple code in matlab which has the purpose of creating the histogram of a grayscale image without using the function hist. I am stuck at the point in which mathlab displays the error "Subscript indices must either be real positive…
Fabio96
  • 1
  • 1
-1
votes
1 answer

Rendering thousands of textred cubes

I just got stuck with texturing my cubes - i searched web and realized that the only way to give my cube 6 different textures (With glDrawElements) is to create about a 24 indices. It is still faster than just glDrawArrays, but it seems quite…
DaSH
  • 75
  • 1
  • 8
-1
votes
1 answer

Error with square root function and powers in Matlab R2014b

I am carrying out a series of calculations using the sqrt() function. My colleagues and I have noticed that we get different results when using the same inputs. Has anyone encountered this problem before? This is an example: input1 = 4; input2 =…
-1
votes
2 answers

How to reduce the use of indices in my code when working with arrays?

Situation: I have been thinking many ways to set this board without index gymnastics. I have read the documentation already and I almost drowned. Any ideas on how to work with arrays in general without abusing indices? I am currently reading about…
Schopenhauer
  • 1,132
  • 8
  • 8
-1
votes
2 answers

A function powers(n,k) that returns the list [1,n,n^2,n^3,...,n^k] where k is an integer

def powers(n, k): """Compute and returns the indices numbers of n, up to and including n^k""" b = range(k+1) print b a = [] for i in b: print a a.append(n**b) return a The above code is my attempt at the…
-2
votes
1 answer

Replacing set of elements in array with another one in JavaScript

I couldn't find here a solution here at Stackoverflow, in other case I am really sorry about duplicating similar problems. Let's say, there is an string array: let array = ["a", "b", "c", "d", "e", "f", "g"]; and some segments to be replaced: let…
toowren
  • 85
  • 7
-2
votes
1 answer

How to mask indices smaller than or bigger than certain index?

Is there a way to mask, using np.ma module, all indices in a specific array smaller or bigger than a given number? For example, if I have an array of 365 elements and I want to mask all of the ones between 170 and 200 and only take into…
-2
votes
1 answer

Swift Index and it's implementation

I'm new to programming. I was trying to understand how indices work in swift. This is the following code from swift documents. converted into function. func ind(){ var c = [10, 20, 30, 40, 50] //index = [0:5] var i = c.startIndex //i = [0] …