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
1answer
6 views

Java: Array of Arraylist

I want to make an arraylist of an array of 2 elements. So, I have unknown rows and known columns (i.e. 2). E.g. [{name1, ID1}, {name2, ID2}, ...] I also have to return this arraylist. I tried ...
0
votes
0answers
10 views

Loop through json decoded array in PHP

I have data in Json format which i have decoded into a php array which when printed produces the following (just a snippet of the information). Array ( [Title] => Array([Heading] => Company ...
0
votes
0answers
13 views

How can I traverse a search tree and print the top 5 occuring strings

I have a program that prints the number of strings characters integers and identifiers from a file. I am also supposed to print the top 5 occurring strings characters integers and identifiers from the ...
0
votes
1answer
26 views

How can I return elements of my array in the given order?

My function is a password generator. It picks the amount of words in a sentence. And takes the firstLetter and the lastLetter alternately. Examples are in the void main method. My problem is I don't ...
0
votes
1answer
14 views

Count different non-zero values of two 2D arrays in Python numpy

I would like to find out how many values in 2D array array1 are different from values in array2 on same positions (x, y) and not equal 0 in array2 using Numpy. array1 = numpy.array([[1, 2], [3, 0]]) ...
0
votes
3answers
27 views

How to use a method to return a double array of user input values?

I want to create a method that returns a double array of user input values. I've figured out how to create a method to ask the user to pick how many elements an array should hold, then pass off the ...
1
vote
1answer
17 views

How to extract the hour, minute and second part of a bytearray string?

I have a bytearray --> bytearray(b'\x07\xe3\n\n\x04\n\x0f\x00\x00\x00<\x00'). It represents a date and time field. I am able to extract the date, but not able to extract the time with AM/PM ...
0
votes
1answer
29 views

add object directly in a array

I have written a object for a school assignment. now i'm trying to add it to an array so i can add multiple boxes. my main String name; double userInputLength; double userInputWidth;...
-1
votes
1answer
19 views

Setting values of a 2 dimensional array in java

I'm attempting to set up a 2 dimensional array of the alphabet in java. My first attempt (doesn't work): char[][] arr=new char[4][7]; for(int r=0; r<arr.length; r++){ for(int c=0; c<arr[r]....
0
votes
0answers
23 views

How to combine objects when looping an array or avoid duplicates?

I want to get a new list with children's events so that if there is two or more events in same date for same child, I would like to combine child's events in same object (CareDay). There is a list for ...
0
votes
9answers
41 views

How to see if an array has a value, and return true if it does. - JavaScript [duplicate]

Both arrays contain the string 'hello', but only the first logs true. Why? function containsHello(array){ for(let i = 0; i < array.length; i++){ if(array[i] === 'hello'){ return ...
0
votes
0answers
33 views

Double quotes in user input causes invalid JSON

I have an application that takes a JavaScript object, turns it into a string using JSON.stringify(), and passes this string in an ajax POST request. The JavaScript object contains various data, ...
1
vote
2answers
23 views

Formatting Some Data to Pass as Multi-Hyphenated String Names

I have some data formatting I need to do to create an array of elements I can pass. This is what I have: // First I use `map` to create an array of just the job names: jobList = dbJobs.map(job => ...
0
votes
2answers
32 views

Efficient 2d numpy array construction from 1d array and function with conditionals

I am creating a 2d numpy array from a function applied to a 1d numpy array (which contains a conditional) and would like to know a more efficient way of doing this. This is currently the slowest part ...
-3
votes
0answers
30 views

Searching a struct array and returning the index not actually returning value

I have a piece of code that is supposed to call upon a function sok to search an array for a match of what you typed. Then there is a function laggaTill that is supposed to search the struct array ...
0
votes
2answers
35 views

How can I keep adding on results obtained from each function call to the arrays?

John and his family went on a holiday and went to 3 different restaurants. The bills were $124, $48 and $268. To tip the waiter a fair amount, John created a simple tip calculator (as a function). ...
1
vote
1answer
13 views

adding to json file instead of adding changes data

I have a method that implements writing to a json file, public function setJsonContent(array $data): void { if (file_exists('data/db.json')) { $content = $this->getJsonContent(); ...
2
votes
2answers
32 views

How to do a multi-line array comprehension?

If I want to create an array with comprehension, but have the logic be multiple lines, how can I do that in Julia? E.g. [ ...logic... for x=1:10] Except the logic is more clearly written in ...
0
votes
0answers
9 views

Sequelize associate a array field to a model

I need to associate two tables one of them have a array field (the values is the id of that another one) and generating a query. Im using sequelize with postgres. (latest version of both). on table ...
0
votes
1answer
19 views

BigQuery - Group by and use an array field as a filter

Hello guys I saw that there are some questions about group by with arrays but none of them (as far as I searched) did not use an array field as a filter for a result! In my case I have an address ...
0
votes
1answer
35 views

angular: asynchronously fill an array

I have an array of elements, a big one, rendered in a dropdown with *ngFor. Whenever I click to open the dropdown, the UI is blocked for a certain amount of time. Finally the dropdown opens and the ...
0
votes
2answers
30 views

I want to print associative array values

Im doing homework that consist on a basic validation of user and password on php. I have an one-dimensional associative array. I can print the value when the condition is true, but i can not print ...
-1
votes
1answer
15 views

How do you handle/store byte array from an output using JavaScript?

How do you handle/store byte array from an output in JavaScript? So I am working with frida, and the result I got is byte array. This is not a js that you can import other class unfortunately. Inside ...
-5
votes
0answers
18 views

how to get the sum of maximum number in array? [on hold]

I am javascript biginner. first I want to ask the user to input 10 subjects , then i make an array to store that marks. after that I want to calculate the sum of 7 maximum subjects. please help me.
-1
votes
1answer
37 views

How can I use the values of array A as keys to address multidimensional array B in javascript? [duplicate]

EDIT: The supposed "duplicate" question "Convert JavaScript string in dot notation into an object reference" is completely different than my question as explained using the example I provided. Aside ...
-2
votes
1answer
22 views

How I can define and appended an element to an array of dictionaries

I am working on a project which it reads a plist contains rows of dictionaries and an array named countries contains country, The countries array is filled with the data of my plist and all works fine,...
0
votes
0answers
14 views

Sending an array of objects from JS to Flask

I am getting an empty [ ] when i hit generate: 127.0.0.1 - - [18/Oct/2019 01:04:37] "POST / HTTP/1.1" 200 - [] Here's the array & JSON in JS: var List = [ { load: "2", location: "3" ...
1
vote
2answers
27 views

How to add one parameter to every object in array?

so i have some cases. Add category to every object in array, which holds in state Posts, are array of object ( these object are wordpress article, and have a lot of parameters) It's holded in state:...
1
vote
0answers
60 views

Array Reduce giving undefined results for data

I am trying to accumulate JSON values based on unique values of the name. But I keep getting data as undefined. My JSON: [ { "date": "2019-09-16", "browser": "Firefox", "...
-3
votes
1answer
34 views

Remove object from array based on index

I've already looked at How do I remove a particular element from an array in JavaScript? but this doesn't quite answer my question as I can't get it to work. I have an array var cardDeck = [{ ...
0
votes
0answers
25 views

Calculate total, average, maximum, and minimum amount for all a transaction in an array of objects

window.onload = function (){ let filHenter = document.getElementById("fileUpload"); filHenter.addEventListener("change", grabFileObject) } //Task 2, Task 3 and Task 5 function grabFileObject(...
-5
votes
0answers
14 views

I wan to import data into google sheet from infogol [on hold]

https://www.infogol.net/en/team/manchester-city/80 I want someone to show me how using importxlm.
0
votes
1answer
35 views

How to query JSON Object to get the list

I have a JSON file like this: { "APIs": [ { "name": "ALPHA.API01.10", "scope": "ALPHA", "service": "API01", "version": "1.0.0.0" }, { "name"...
0
votes
1answer
25 views

ReactJS: Map array of images with unique pop up per image

I'm new to React & really stuck on how to create a popup which is unique to each image. I have 20 images, which all need to be clickable with a unique pop up (only one pop up at a time open). ...
1
vote
1answer
17 views

Spark “sum” command gives Method sum([class java.util.ArrayList]) does not exist

Am I going crazy? from pyspark.sql.functions import * sum([2,3,2]) Gives: py4j.Py4JException: Method sum([class java.util.ArrayList]) does not exist How can I just get a simple sum? What is ...
1
vote
3answers
33 views

how to extract array data only having multiple value in Javascript?

i have this array data. var arr = {key1:'progress',key2:'done',key3:['new','12'],key4:['checking','10']}; and i want extract array data,but it should only having multiple value data. so i want to ...
1
vote
0answers
12 views

for loop how to show in html div element

in JavaScript for loop result show in html div element ```<div id="empid"></div>``` var emp =[{"firstname":"srikanth", "lastname":"gubbal", "age":"36", "place":"pune", "qualification":"...
0
votes
0answers
28 views

Subarray of ints summing to target number negative values

Referencing https://www.geeksforgeeks.org/find-subarray-with-given-sum-in-array-of-integers/ for some reason I'm feeling a little thick about this and not totally grasping the reason that once you ...
-2
votes
2answers
32 views

How to add together values in an array using a for loop?

The aim of this method is to find the average speed during a bike ride. I already have a method speeds() which returns the average values between GPS points stored in a double array. I tried to use a ...
1
vote
2answers
22 views

Transform Array of Objects to Array of Different Structured Objects

My question is probably simple but my eyes is blinking and I cannot think something else right now. Any help appreciated This is my initial array var Products = [ { "order_product_id":"1111",...
0
votes
0answers
35 views

How do you do you group sections in tableview?

What I’m trying to do is group the sections in the TableView. By sorting them by the storeName so that I can separate the items to go to its proper section and arranged by StoreName. Im trying to ...
0
votes
0answers
19 views

Access array outside function [duplicate]

I need the results of the array outside of the function. Is there anyway to do that? I am trying to push the results of a json object to an array to use. let chan = []; axios.get(names, { ...
1
vote
4answers
51 views

Aggregate an array of objects in JavaScript

I have an array of objects having a boolean field X. [{..., x: true, y: 3, ...] I need to aggregate this array, in order to obtain a value, true(or false), if all values of x are correspondingly ...
0
votes
0answers
14 views

vba to grab values present currently from a range in another range [on hold]

I am counting number of medicine bottles produced & accepted and rejected number of bottles. Manually it is hard to count precisely so I need vba to achieve my task. My Excel Workbook contains ...
1
vote
1answer
35 views

Perl how to pass array as an argument to another Perl script

I have a 2 perl scripts where primary_script.pl would be calling secondary_script.pl script by passing array as an argument. My code is shown below: primary_script.pl #!/usr/bin/perl use Data::...
0
votes
2answers
39 views

Delete array of values from numpy array

This post is an extension of this question. I would like to delete multiple elements from a numpy array that have certain values. That is for import numpy as np a = np.array([1, 1, 2, 5, 6, 8, 8, 8, ...
-1
votes
0answers
20 views

Adding different text in front of each array number

I've got an array of numbers: int[] grades = {64,55,45,67,65,88}; And I need to return it as a String array with text before each number, like this: [APP:64, BSAD:55, CF:45, DAD:67, N&CS:65, ...
0
votes
2answers
36 views

Replace an Array of Objects with a different Array in JS

I have an Array of Items. Each Item in the Array, has a set of Properties. One of them is called config: object[]. It is an array of Objects. Normally, I provide the full object with the correct ...
-2
votes
0answers
33 views

What's the code? Input process will stops and will shows the output when im inputting '0'. My programs needs customize [on hold]

What's the code? Input process will stops and will shows the output when im inputting '0'. My programs needs customize. My programs only missing that thing tho, can u guys help me? i'm using JCreator ...
0
votes
2answers
32 views

Is there any way to compare a value at certain index with all the values to its right till it doesn't match?

Lets say I have an array : $ar = array(0,1,0,0,0,1,0) I want to compare the value at $ar[2], i.e. 0 with all the values to its right until stops matching. By this. I meant that, $ar[2] == $ar[3], $...