Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

Questions tagged [arrays]

An array is an ordered data structure consisting of a collection of elements (values, variables or references), each identified by one or more indexes. When asking about specific variants of arrays, use these related tags instead: [vector], [arraylist], [matrix]. When using this tag, in a question which is specific to a programming language, tag the question with the programming language being used.

Filter by
Sorted by
Tagged with
0
votes
0answers
9 views

I had javascript code i need to make it a variable with each post in wordpress loop

i need to make javascript variable with wordpress loops use ID but all loops take the first start loop start time <script> var startDateTime = new Date(2014,0,1,23,50,59,0); // YYYY (M-1) D H m ...
0
votes
0answers
7 views

How to assign cell arrays to field in nested structure?

Suppose I have a cell array that I want to assign to a nested field. myArray = {{ 1 2 3 4 5}; { 7 8 9 10 11 12 13}} I want the endresult to be ...
-2
votes
0answers
30 views

How to merge 3 array using javascript

need help on how can I join these 3 set of arrays in Javascript. TIA var array1 = [5,6]; var array2 = ['x','y']; var array3 = [['a','b','c'],['d','e','f']]; expected result [5, 'x', 'a'] ['', '', '...
0
votes
1answer
20 views

How to add java.util.Scanner class to read two-dimensional array of float entries input?

I have a question about using java.util.Scanner class to read two-dimensional array of float entries input, I've tried to find on internet, but still can't work. The code show me errors. Anyone can ...
0
votes
1answer
17 views

Player position in array

Why is my Security ('S') in the same position as Donald ('D'). The map should be printing out like this [D - - - -] [- - - - -] [- - - - -] [- - S - -] [- - P - -] But instead it shows up like ...
0
votes
0answers
16 views

How do I use a loop to find the min and max values of an array in Assembly?

I'm trying to find and print the minimum and maximum values of an array in Assembly. My main issue right now is incrementing the value of the index for the array. I keep getting syntax errors when I ...
0
votes
1answer
13 views

Accessing array of floats inside an array of class objects in VBA

I have some probably simple to solve issue with accessing array of floats inside an array of class objects. Inside my Excel document I declare a class TData with some properties like Public weight As ...
0
votes
1answer
17 views

In _.invoke source code, what is the args' role?

I just started to learn JS few months ago and I tried to understand what the "args" doing in "_.invoke" source code. Is there anyone who can answer this, please? I read mdn .apply and read other _....
1
vote
1answer
29 views

Segmentation fault on 2D arrays of certain size

I'm creating a program with multiple threads where one of threads creates 2 matrices based on input. These inputs are n and seed. Input specifies the square size of the matrix (n x n size) while seed ...
-1
votes
0answers
11 views

fetch all rows on multidimensional array database [duplicate]

i have a database like this budget | need | processorName | motherboardName | ramName low | office | AMD Touring | Compaq 354 | Touring 4x1Gb low | gaming | Intel Gaming | Kwak 447 ...
0
votes
1answer
20 views

React Render Another Component that Matches Current Component

I have a component Card.js that renders in a card format that comes from a data array. I want to achieve clicking on the card and then opening up another component called Suggestion.js, but I only ...
0
votes
0answers
5 views

Is there a way to apply self.basename to an array of inputs in CWL. Getting Key Error

I am trying to get the basenames for an array of input files in CWL, but get a Key Error when I try the code below. I cannot seem to find a way to have $(self.basename) be applied to an array of input ...
0
votes
1answer
18 views

Returning a 2-Dimensional Array from a method

I'm trying to return a 2-dimensional array from a function inside of a class. I don't want to create a new array inside the function because I want to return the same one I've passed into the function....
1
vote
3answers
54 views

Why am I able to re-assign a new string to a char pointer in C like so ( ch *string = “hello”; string = “assign”;)

I would like to know why the following code is legal char *string = "hello"; string = "changed"; string = "changed again"; This does not cause any problem with the compiler. But I was under the ...
0
votes
0answers
10 views

How to clone a 2D array of float entries using java languages?

I have a question about clone a two-dimensional array of float entries to another two-dimensional array of similar type and size. I try to us java.util.Scanner class to read input, but the code show ...
2
votes
1answer
35 views

Java - How can I display a letter grade for each of my grades in my program rather than just my last one?

In my assignment for college, I have to prompt for a grade and get user input 6 times, then display each mark with a letter grade alongside it, and then display the average. I was finally able to get ...
-2
votes
1answer
17 views

Error in an array, java.lang.NullPointerException [duplicate]

So, i'm using an array in my program, and it gives me this error: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException The error is in fourth line of this code: int n = numbers....
1
vote
1answer
27 views

merge arrays in bigquery that have one common value

In big query I have a table with one column with is an array of strings. The data will look like this : ['a','b'] ['b','c'] ['c', 'd'] ['e'] Now my desired output is : ['a','b','c','d'] ['e'] ...
2
votes
1answer
33 views

convert pandas series AND dataframe objects to a numpy array

Series to Numpy Array: I have a pandas series object that looks like the following: s1 = pd.Series([0,1,2,3,4,5,6,7,8], index=['AB', 'AC','AD', 'BA','BB','BC','CA','CB','CC']) I want to convert ...
0
votes
1answer
14 views

Capture data from editable Bootstrap table into array

I have a bootstrap table set up (using react-bootstrap-table-next) that will allow a user to edit the cells and input desired values. Once they are finished, I would like for them to click a "Submit" ...
0
votes
3answers
35 views

How to do element-wise rounding of NumPy array to first non-zero digit?

I would like to "round" (not exact a mathematical rounding) the elements of a numpy array in the following way: Given a numpy NxN or NxM 2D array with digit between 0.00001 to 9.99999 like a=np....
0
votes
1answer
24 views

Javascript merge rows with conditions

I need to merge rows with specific conditions like so: If rows have the same values in col: 0, 1, 3, 4, 5 AND col 3 equals specific value (e.g. 17007) -> merge and the merged row has the sum of col 2....
0
votes
0answers
10 views

Why does the for-loop stops abruptly when dealing with last element comparisons

EDIT: Problem solved, read comments :) In this problem, I am counting the frequency of the letter and adding them with just the letter and the number occurrences of the letter into a new string. I ...
1
vote
1answer
22 views

Receive Data from two List and print out the difference in each list

I have two list that shows the output onto a text file. I would like to compare both list to tell me the data that is not in each of them with the file that does not have the data. I have the list ...
-1
votes
0answers
25 views

I have made a class that generates a “tray of lithium” (random numbers), I now have to add these numbers to two different ArrayLists

I have one class that generates random numbers and I need to somehow use the array from one class and add each number to different ArrayLists, depending on the size of the number. If the number is ...
0
votes
0answers
7 views

Create time series plots from a multidimensional array for one unique index value

I have a .nc file with dimensions (1461, 257, 512) corresponding to (time, latitude, longitude). The data is mostly 0's, but there are occasional integer entries that are essentially indices for ...
4
votes
1answer
55 views

Split a list into equal parts?

I have an array of size elements, and I have a function that will split it into roughly equal sections. It does this by setting the size of the first size-1 sections with size/num_of_sections, and ...
0
votes
2answers
28 views

Create two arrays to count the occurence of random numbers between 1 and 25 in JavaScript

I am currently attempting to write a script where I want to use both a number and a counter array that use for loops to output a list of random numbers, and how often these numbers occur in the output ...
0
votes
3answers
30 views

How to grab a key value no matter where it's located in the array

Grab this slice_type: section. No matter where it's in the array, so here its [1], but it could be [0] or [2]. in the end I need to grab the items key that are in the object that has slice_type: '...
0
votes
0answers
21 views

Is there a more effective way to find the cartesian product of several arrays? [duplicate]

I am combining a relatively large set of double arrays (right now around 80) that are not of equal length to receive the possible combination of the parameters saved in those arrays. The results are ...
0
votes
0answers
22 views

What do i need to use for sorting data for my economy system's leaderboard command

What I'm trying to achieve is a leaderboard command for my economy system on my discord bot. I use quick.db for my database. The problem is in the array sort thing where I need the balances to go from ...
0
votes
0answers
8 views

Python String or boolean in Crystal Reports - How to format headings in report

I am not very good at python but it seems I need to alter a python string to get the results I need but I am not sure how to do it. In crystal reports I can color this section using the section expert ...
0
votes
0answers
10 views

Array Update in Mongo Db using Pentaho PDI

Im trying to update a field in all the elements of an array in mongo db output step pentaho. Going through the documentation i was able to update the first matching element of the array. And with ...
-1
votes
1answer
57 views

Parallel array copy in Java

I'm looking to copy an array into another in parallel, for example: int[] a = {1, 3, 5, 7, 9}; int[] b = new int[a.length]; for(int i = 0; i < a.length; i++) // parallel { b[i] = a[i]; } In ...
0
votes
1answer
29 views

Python code to create an array of arrays (8x8 with each being a 3x3)

I am attempting to create an array of arrays with the structure being an 8x8, where each cell in that is a 3x3 array. What I have created works, but when I want to change a specific value, I need to ...
0
votes
1answer
48 views

What's is this behavior of JavaScript Array?

I'm started to work with JavaScript/Firestore for a few days but i'm facing some issues with the behavior of the laguage in array's. I cannot run array's with a for loop inside a function and almost ...
-4
votes
0answers
19 views

What is the cause for java.lang.ArrayIndexOutOfBoundsException and how can i solve it? [duplicate]

It's giving me that error, but i can't quite find why or how it should be. I understand that this error means that is getting a value out of the array, but i don't know why. public class ...
0
votes
0answers
6 views

Find the Quantity of a Property value from a filtered nested array

I would like to find the quantity of characters that are in the group Marvel or DC Comics http://plnkr.co/edit/8YbRTd?p=preview this Plunker works perfectly However my Firebase Data is in a ...
0
votes
2answers
31 views

Calling an array

I can't seem to find out how to call two parts of an array in one go. Is this possible? Example $cars = array("Volvo", "BMW", "Toyota"); echo $cars[0,1]; Or do I need to call the array for each ...
0
votes
0answers
21 views

Remove datatypes from array which are different from integers in Python

I have got the following array: array([[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, ...
0
votes
1answer
19 views

how to assign the values to a string array directly taken from input using bufferedreader?

public static void main(String[] args) { BufferedReader br = new BufferedReader(new InputStreamReader(System.in); String[] a = new String[]{br.readLine().split("\\s")}; } I'm getting errors ...
0
votes
1answer
13 views

AppScript: 'number of columns in the data does not match the number of columns in the range.' setValues method not reading array correctly?

I'm trying to automate the collection of phone numbers from an API into a Google Sheet with app script. I can get the data and place it in an array with the following code: const options = { ...
1
vote
1answer
31 views

Why doesn't my comparison between two Integer-Values work?

Sometimes values that aren't the same as the value compared to aren't being set to null, even though they do contain different values. The values of the Array Values never changes, but the Value of ...
4
votes
2answers
49 views

How can i convert elements of an array in javascript into an independent array using forEach

I am trying to convert elements of an array to independent arrays and then adding these arrays to a new array. this is what i have tried. But cannot get it to work. splice method is not working ...
0
votes
0answers
19 views

Negative multi-dimensional array index Python

Im trying to code an A* algorithm, and let's suppose that I have three variables n(orth) s(outh) w(est) e(ast) and 3x3 grid = [[0,0,0],[0,0,0],[0,0,0]] and I want to start from [0][0], so in this ...
1
vote
1answer
33 views

Images onload in one function

I'm trying to learn JavaScript, making my first game. How I can make all images onload in one function and later draw it in the canvas making my code shorter? How can I put a lot of images in an ...
-1
votes
0answers
22 views

How to return an array of routes from a function in a Navigator task?

I am not a programmer by profession and myself learn php. I found the Navigator task template on the Internet (the author of the task writes that it can be solved both by recursion and using the ...
0
votes
3answers
35 views

Multiplying values in array by each other and checking the result against a number

I have an array of numbers const nums = [10, 7, 3, 47]; I am looking to check if I multiply each number by itself will it match my result number. I have tried a long shot by doing the following ...
0
votes
1answer
39 views

Finding max element which is to the right of column 'k'

I have a task where I am asked to find max element which is to the right of column 'k' (as I understand, I need to find the maximum in k+1 column). I am clearly doing something wrong because when I ...
0
votes
1answer
12 views

Google apps scripts: How to properly work with comma separated spreadsheet values converted to an array

I have a spreadsheet in which column 1 includes source file IDs; each cell contains only one ID. In column 2, there are destination file IDs where a single cell contains multiple IDs separated by a ...