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
10 views

remove unwanted information from entries in a list of numpy arrays [duplicate]

I have this list of arrays and I don't want my end result to contain stuff like "dtype" etc. My question is: how do I acquire the desired result? Desired result: [[0, 1, 3], [2, 4, 5], [6, 7]] ...
0
votes
0answers
11 views

Simple question on pointers and how to initialize an array in C

I have a question on a simple program that i wrote to initialize an array one element at a time, the few lines of code are below: #include <stdio.h> int main(void) { int *ptr; int index; for (...
0
votes
0answers
8 views

How to work with nested array in .ts file

I have the below json array which my service.ts get request returned. I will like to know how I can grab the value of "university" and "course" from all the objects and store it in a new array. ...
0
votes
3answers
31 views

Does specifying array size for a user input string in C matter?

I am writing a code to take a users input from the terminal as a string. I've read online that the correct way to instantiate a string in C is to use an array of characters. My question is if I ...
0
votes
1answer
16 views

How to merge object of array and only increase amount property? Javascript array of objects

I am creating a recipe book application in Angular 7 which has shopping list feature. What I want: When a person adds recipe ingredients to shopping list twice it increases only the amount of the ...
-1
votes
0answers
39 views

How to attach values to the array via a for loop?

I want to attach the values to the array.Like this,a[0]=0, a[1]=10 and a[2]=20; I stick the code before. #include<iostream> #include<cmath> using namespace std; int main() { const ...
0
votes
1answer
43 views

why does sizeof vector and array gives different output [duplicate]

when I try to take the element by sizeof , then I am getting different answers in array and vector #include<iostream> #include<vector> using namespace std; int main(){ vector<...
0
votes
0answers
6 views

2d array in react. infinite grid component with zoom

I have problem with 2d array in react. i'm trying to build infinite grid component with zoom in react like this one http://jsfiddle.net/L3075pd4/2/. how can i print an 2d array in react and how i can ...
0
votes
0answers
4 views

How to save routes and methods of a Swagger object in array of objects

I have this swagger object that contains the following data. how can I save them in an array of objects? { swagger: '2.0', info: { version: '0.0.1', title: 'My API' }, host: 'localhost:3000', ...
0
votes
0answers
19 views

Java ArrayIndexOutOfBoundsException thrown when writing to an array within bounds [duplicate]

I'm experiencing an index out of bounds error while reading/writing to an array. My code is designed to fetch the source code for quizlet sets and extract terms and definitions. It's not finished, ...
-1
votes
0answers
5 views

return zero length (empty) array in free pascal

The problem involves returning an array of unique items from a list of non-unique items without knowing beforehand how many such items there may be. I can successfully handle the case of there ...
0
votes
1answer
23 views

How to pass an array to a type parameter bounded by the Comparable interface

I have an interface: public interface Comparable<T> { public int compareTo(T o); } that bounds a type parameter in the method public static <T extends Comparable<T>> int ...
0
votes
6answers
42 views

Loop through json and fetch specific values in nodejs

I have a scenario where I am trying to parse through this below json and get all the value of key "name" and key "id" , which I would further store in a variable or array. [ { "...
-4
votes
3answers
27 views

Array not printing?

I'm trying to print an array of 100 numbers in 10 rows and 10 columns, each number is randomly generated by a random number generator within a certain range. However, either nothing is printed or a ...
0
votes
0answers
20 views

Generating a series of slightly random integers in a numpy array

I want to create composite audio test signals in a numpy array. I need the values to be integers rounded to the nearest whole number. Secondly I want to add random noise or dither. You can see below ...
-2
votes
1answer
26 views

JAVA How do I write code for a 2D array storing four integers in a 2x2 matrix?

Array Problem 3: 2D array -Ask the user for 4 integers -Store them as a 2x2 matrix -Find the determinant Matrix: input1 input2 input3 input4
-1
votes
0answers
13 views

Reading a signed integer from a file in C

I have to read " -10899 "(and many more integers) from a text file into an integer variable in C. This is what I have so far: int i = 0; // get data from file and convert to int for(; i < ...
0
votes
1answer
27 views

Add a new key in the dictionary?

I want to add multiple keys to the dictionary via loop. For example, when I create a key, that key already has its value. I have the following scenario: var keys = ['key1', 'key2', 'key3', 'key4'] ...
2
votes
1answer
17 views

numpy array: efficient way to compute argmax within a fixed window at a set of rows and columns given as input

Lets assume we have a 2D array arr, a set of positions defined by rows and cols, and a window of shape (5, 1). For (i, j), we need the index of the max value within arr[i-2:i+2, j]. We want to repeat ...
0
votes
0answers
5 views

LDASequential trying to get What is the Dominant topic and its percentage contribution in each document

Hi I am doing analysis of game reviews and I have found this tutorial online: https://www.machinelearningplus.com/nlp/topic-modeling-gensim-python/ And I am trying to do number 18 on the LDASeq. It ...
1
vote
3answers
25 views

Filter and combine two arrays, matching two fields/columns : Javascript

Using childcare schools - I have two arrays that I need to match on 2 columns of each array: Attendance by Department: [date, dept, attended] 0: (3) ["09-30-2019", "00_Infants", 22] 1: (3) ["...
0
votes
2answers
13 views

I want an output that looks like: “Paste R2 has the most files with 32 files.” using a function

Question 1) I want an output that looks like: "Paste R2 has the most files with 32 files." I created a funtion but only got the maximum value and a also want the corresponding paste data = [['R1', ...
0
votes
0answers
30 views

Using sort function on array of dynamic ranges in VBA?

Have an array of dynamic ranges that need to be sorted by the B1 position in each. I wrote some very long an inefficient code for a bubble sort that breaks occasionally and was wondering if the .Sort ...
0
votes
2answers
18 views

How to print and load an array with random numbers

I need to display a list of 10 random double numbers in order and spaced out in a row. This is what I have so far: double [] array; array = new double [10]; for (int i = 0 ; i <array....
1
vote
1answer
28 views

Array made with malloc function goes beyond desired size [duplicate]

I'm making a program capable to use some statistics functions. For that, I used malloc for the array that the numbers of the sample to operate on, as I want it's size to be based on users' input. It's ...
0
votes
1answer
40 views

Get an EXACT value in $_POST array

I'm studying php and I'm trying to figure out how to get the string "Juve_Milan" from this var_dump($_POST) : array(5) { ["Juve_Milan"] => array(2) { [0] => string(1) "5"...
0
votes
1answer
12 views

React - map over nested json not in an array

I am trying to map over some json data which looks like this... "array": [ { "controlPanel": "00000000-0000-0000-0000-000000000000", "lastArmed": "2016-10-31T19:36:19....
0
votes
1answer
53 views

Which one is faster? `array.findIndex` vs `array.reduce` + `object[index]` [on hold]

I have client side application in React Native. This app consume server REST API. This is example of data from API: Groups: [ { "id":1, "name":"example1", "items":[ { ...
0
votes
1answer
24 views

How to update the 'sortNotes' function with the new input data?

I am doing a note app: I created in javascript a const 'notes' that assigs an array of objects inside. Each object has a title and description with respective values. Created a function assigned to a ...
1
vote
2answers
45 views

refactoring conditional logic in react

I have a react component which renders a 10-punch punchcard. It receives a "punched" prop to determine how many of the punches should be filled in. My current code works as expected, but I would ...
1
vote
3answers
48 views

How do I list only the numbers that have '3' in them from an array?

The exercise says that I have to use a loop to check the array for numbers that contain the number '3'. The program must keep looping until all the numbers are listed. Currently it wont stop looping. ...
0
votes
1answer
22 views

Concatenating multiple dataframe columns into a single array under a dataframe column

I am trying to concatenate multiple columns(all are numeric number) in a dataframe into an array under one single column of a dataframe. Caveat is if the concatenating columns have NAN, then should ...
0
votes
0answers
29 views

Static method creating 2d array in C# [duplicate]

I have a static method that creates a 3x3 2d array of integers but when I use it to generate new arrays, it always returns the same values. Here is the method: public static int[,] Create(int ...
0
votes
1answer
19 views

Better way of limiting the number of indexes in a PHP array? [duplicate]

If I have an array that contains 20 indexes and I only want to return the first 10 indexes is there a better way of doing it other than creating a new array with a loop? $i=0; $newArray =[]; foreach($...
3
votes
2answers
35 views

How to extract the upper values from the whole 3D array in python

Is it possible to extract the upper values from the whole 3D array? A simple example of a 3D array is below: import numpy as np a = np.array([[[7, 4, 2], [5, 0, 4], [0, 0, 5]], [[7, ...
0
votes
0answers
29 views

Why my strings concatenation in a vector does not work? [duplicate]

I am trying to write code in C++ that concatenate an array of strings to another array of strings and store the result into a vector. But it does not compile (I get multiple errors) std::vector<...
0
votes
2answers
39 views

Understanding syntax in a forEach function statement in javascript

I am working with forEach statements right now and I have a block of code here that successfully executes what I am working on but I don't understand one particular statement. I did not write this ...
0
votes
2answers
17 views

Sort value intoarray

I have a question in PLSQL ORACLE I got an table of object and in this table I collect these type of object: OBJECTS_TABLE object1 -> ID: 1 VALUE: a object2 -> ID: 2 VALUE: b object3 -> ...
0
votes
1answer
24 views

How can I call onchange function in checkboxes using a user array and axio get in react js?

I am trying to get a user array in checkboxes this user array is having its elements from JSON placeholder. I want to display these values in checkboxes with onchange property, but somehow it displays ...
0
votes
1answer
27 views

Invert non-zero submatrix in numpy, returning a matrix of original shape

I have a matrix, with some rows and columns equal to zero, so it is not invertible. I need to get an iverse of non-zero submatrix, so that the inverse then has the same structure as the original ...
2
votes
4answers
75 views

comparing array elements with a return value from a method

I have a method that calculates the minimum and maximum amount of rainfall from a user input array of months. My problem is that my method returns the quantity of min and max and I need it to return ...
1
vote
1answer
48 views

parseInt() = undefined

I need the datas of my array which are delivered as a string np, i programmed a while loop to get all my datas (120) rows after that i parsed them into an integer on the Browser Console i can see my ...
0
votes
3answers
40 views

Adding integer array as the variable for class

I'm writing a simple Java code for competitors of some random competition. I am adding variables such as age, category, and scores. If I add integers or Strings, there is no problem, but when wanting ...
-1
votes
5answers
61 views

How do I compare single array of objects with it key values

I have an array of objects, Where I need to compare "taskId" & "resourceId" of its own array of objects and push the result in a new array. Here is my array data = [{ "resourceId":1234 "...
-1
votes
0answers
21 views

Easy way to echo php array with Blob [duplicate]

I need a response from php that contains a blob from database and is filename. I m using this code , but in javascript cannot access array indexes. Cannot also json encode a blob. print_r([$filename,...
0
votes
2answers
36 views

There is a condition where i need to convert Array of objects into Array of Arrays

There is a condition where i need to convert Array of objects into Array of Arrays. An array is given below as data convert this array as formatedArray. data = [ { "total": 1, "...
0
votes
0answers
27 views

Iterating Through API Call In Array (GAS/Javascript)

I'm still very new to JS and GAS. I have an API call to get certain data from a gov.uk API system. I've got to the point where I can call one variable (in this case a VRM) and get certain parts of ...
3
votes
3answers
93 views

Splitting a string into a List of string array in C#

I am trying to convert the following string: "CN=Test,OU=ABC,OU=Company,DC=CFLA,DC=domain" into this form (a list of string arrays): [ {"CN" , "Test"}, {"OU" , "ABC"}, {"OU" , "Company"}, {"...
0
votes
1answer
16 views

Eloquent, PostgreSQL JSONB and nested arrays

I am in trouble with search nested JSON array in Laravel 6 app with PostgreSQL as DB. Migration: $table->bigIncrement('id'); $table->string('comment')->nullable(); $table->jsonb('result')...
-1
votes
2answers
43 views

Updating array item by index using Object.assign equivalent in spread syntax

I have stumbled upon this gem recently while trying to update an index of an array; What I tried is: const a = [1,2,3]; Object.assign([...a], {1: 10}) ); // [1, 10, 3] This allows me to ...