Questions tagged [arrays]

An array is an ordered data structure consisting of a collection of elements (values or variables), each identified by one or multiple 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 ...

0
votes
1answer
6 views

initialising array of vectors in constructor

I have a class named Graph. There this vertices member of the class. I have initialized vertices in the constructor. Also, There is a member array of vectors. I want the number of vectors to be equal ...
-3
votes
0answers
15 views

txt file into array in python [duplicate]

I'm new to python and i'm having a trouble with txt file and array. I have a text file which contains 12 numbers in one line. Loading from this txt file, I want to make 1x4 array for the first 4 ...
0
votes
0answers
4 views

how to define nested array object in swagger 2.0

I try to define an object array in swagger as response: /product: get: operationId: api.product.read_all tags: - Product summary: Read the Products description: ...
0
votes
0answers
12 views

How to display the content of an array?

How can I display the contents of arrays to find out they are from this: $g['template_options'] = array( 'fields_not_available' => array(133,136,137,139,140,142,144,145,146,148),); Thank you!
0
votes
2answers
33 views

Convert array of strings to array of objects in JSON property

I have the following JSON returned from an endpoint { "response": { "lines": [ "[{'line':'3007621h7s2','type':'national'},{'line':'3007663f7s9','type':'international'}]", ...
0
votes
1answer
26 views

JavaScript array.push() for object [duplicate]

I try to Insert new data in an object as an object. But the problem is when i use array.push() method it inserts new data/data's in a array first then push it into my desire object but as an array. ...
0
votes
1answer
12 views

Making 2D arrays larger than 100x100 in processing 3

So I'm just in my first weeks of uni and they've been putting us through a "coding bootcamp" to get everyone up to speed and make sure they know the basics. At the end of the bootcamp, we're supposed ...
0
votes
0answers
36 views

Getting a weird negative number in my output when using an array I modified in one function, in another function

I am writing a program that takes a user-inputted list of up to 25 integers, then prints the sorted list using bubble sorting, the sorted list in descending order, and some other info about the list ...
1
vote
2answers
28 views

Changed value in numpy array based on index and on criteria

I have a numpy array: arr = np.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]]) >> arr [[ 1 2 3 4 5] [ 6 7 8 9 10]] I want to take a portion of the array based on indices (not slices): ix =...
-2
votes
0answers
28 views

How much memory a simple array[19990] = value does consume? [duplicate]

when I do use var ar = []; ar[1990] = "user1"; ar[19900] = "user1"; ar.length gives me 19990 as result Does it mean I do consume 19990 integers in memory just to store 2 values ? is that a good ...
2
votes
1answer
14 views

PowerShell, weird behaviour of Get-WinEvent -FilterHashTable ID and arrays

What I want to do? I run the Get-WinEvent function with -FilterHashTable supplying an array of interesting Event ID's for ID argument. $IDS = 4720,4722,4723,4724,4725,4726,4727,4728,4729,4730,4731,...
1
vote
1answer
17 views

Sort Structured Numpy Array On Multiple Columns In Different Order

I have a structured numpy array: dtype = [('price', float), ('counter', int)] values = [(35, 1), (36, 2),           (36, 3)] a = np.array(values, dtype=dtype) I want to sort for price and then for ...
0
votes
1answer
37 views

Php top list from arrays [duplicate]

How do you make someone who has a higher subscriberCount be sorted to the top? For example, I want to list the top 50 by subscriberCount. Currently it just sorts by the order added to $topchan1["items"...
1
vote
3answers
39 views

Check if a merged array has item from two arrays and update the merged array JS

I have two arrays. I merge it and remove duplicates. Merging is done by taking into consideration all keys of the arrays (all key values in the object in array 1 must match with those in array 2). ...
0
votes
1answer
57 views

Searching for values in array

i'm new to coding and have been introduced to C language. I need help understanding a specific concept. I want to know how I can search for a specific number(e.g. 4) in a array(e.g. {1 2 4 5 6 4 6})....
0
votes
6answers
37 views

2 Arrays, different sizes, reuse one array within loop once max index is reached

I have 2 arrays structured like so and want to loop through the larger array and assign a property to it, using random ids from a smaller array //Actual array length is 140 const users = [ { ...
0
votes
1answer
30 views

Python | Importing txt files with spaces and converting them to lists to calculate with

I'm trying to create a code with Python 3 to import text files to python, converting it to lists and then calculate something with it like average marks. Text file: number name subject1 subject2 ...
0
votes
1answer
22 views

inside array of arrays if there is missing index then add empty index for missing index

//this is the array is have and the below is what i want $data = array( array( 'title' => 'My title', 'date' => 'My date' ), array( 'title' =>...
-3
votes
0answers
26 views

How to create a program with 3D Arrays [on hold]

How do I create a java program that takes the input from a user of a row and column and creates an array for it, and stores a * in the first available location and keeps track of that location in the ...
1
vote
1answer
51 views

How do intersect intervals in Javascript?

As an input, I have a string and an array of intervals with colors: // 0123456789.123456789.123456789.123456789.123 const str = 'The quick brown fox jumps over the lazy dog.'; const colors ...
2
votes
2answers
36 views

How can I recursively input parameters into this function with an initial value?

so I have this function which takes in an array of arrays and outputs an array of arrays with different values (I am attempting genetic programming breeding function). So my problem is as follows: I ...
2
votes
0answers
14 views

PHPExcel print vales by comparing 2 array values

In my codeigniter project am trying to export report in Excel. Here i want to print the values by comparing 2 array values. This is my excel sheet In array-1 code: $get_head_branch = $this->...
1
vote
3answers
64 views

MySQL data from PHP to Javascript with JSON

I am trying to use a code that will take data from a mySQL database bind that data to a variable, put all the resulting $x into a PHP array, and finally convert it to JSON format. I then take the JSON ...
1
vote
2answers
54 views

PHP group values from array

I have this array: Array ( [061716v] => 1 [061610A] => 1 [062433AP] => 1 [063868M] => 2 [059173V] => 3 [061579A] => 3 [062404AP] => 3 [...
-1
votes
0answers
37 views

Php array_merge to one result [on hold]

How to combine all the arrays into one total result? now the results with echo like 252 299 i need get total result 252+299 and get from echo 551 <?php $videoListt = array_merge($topchan1["...
0
votes
1answer
31 views

numpy masked ragged array

I want to fill a masked array whose dtype is object (because I need to store masked ragged arrays) with a non scalar fill_value. Here's an example of a 2D array whose elements are 1D numpy arrays. Of ...
2
votes
6answers
68 views

How to get total of values in array of javascript objects

I have the following array: [ {genderAge: "Male 25-39", count: 13029, weightedCount: 18475.6824262314, matchingSegment: 2}, {genderAge: "Female 55+", count: 35639, weightedCount: 32294.5926147014, ...
-1
votes
3answers
110 views

C++ array issue long line

The code inside int main it doesn't break so it out puts a 8x8 array with 5x5 squares in it it just puts it on a long line im pretty new to c++ so please help me understand it. char ruta[8][8]; for (...
0
votes
0answers
31 views

STM32 Array to control individual GPIO

I'm new to embedded systems and C programming. I am Currently trying to program a PCB using an STM32 microcontroller to control an array of 8 fans upon receipt of a single commenad. i.e 00001011 will ...
0
votes
1answer
31 views

How to declare Arduino array with custom type?

I use for my Arduino project OneWire library and Dallas one. This one defines an DeviceAddress type which can contains an OneWire device address. I would like to create an array to store my devices ...
0
votes
2answers
32 views

Trying to get property of non-object in Laravel 5.5 while getting object from array

I am new to Laravel and trying to get an object from an array. However I am receiving the following issue: Trying to get property of non-object in Laravel 5.5 while getting object from array ...
2
votes
5answers
47 views

How to replace certain symbol in array?

Can you give me a hint what do I wrong trying to replace space symbol (' ') to ('-'). This is my code: function hypernateAndLowerCase(strings) { let newArray = []; for (let i = 0; i < ...
-1
votes
0answers
29 views

Navigate through two huge different files an indicate the difference in a .text file

I'm totally novice in Perl programming ad I need your advice/solution. I have two files, one is a Perl program (.pm) with 8.000 lines and the other one is an .XML file with 27.000 lines. What I would ...
0
votes
2answers
21 views

Inserting array data into a single longtext field with php

I need to insert everything from an array created by this: $test = $_POST['productinfo']; $total2 = 0; $totalquantity = 0; $totalamount = 0; for($i=...
3
votes
1answer
46 views

Count the number of elements in array in Python whatever dimension it is

I want to count easily the number of elements in Numpy arra but I don't know a priori their dimensions. Is there a generic function that counts the number of elements in a numpyarray whatever its ...
2
votes
2answers
65 views

Push Value of attribute in array

$(document).ready(function() { function randomColor() { return 'rgb(' + Math.round(Math.random() * 255) + ', ' + Math.round(Math.random() * 255) + ', ' + Math.round(Math....
-1
votes
0answers
19 views

How to pass values from .txt file to OracleSQL Query in PHP

I have data that I want to be filter in my oracle sql query and call it with PHP, I've tried to use OCI_BIND but I cant get the values from txt to string that required by OCI_BIND. So here is the ...
-1
votes
0answers
32 views

Average of 24hrs time array is unreasonable [on hold]

what i'm working with Array ( [0] => 19:20:16 [1] => 19:03:49 [2] => 18:21:49 [3] => ) to be sure i applied date('h:i a', strtotime($value[1]['Time'])); and got ...
0
votes
1answer
68 views

How can I convert Json into 2D array?

If I got a Json like this: { "i": [ "0", [123]] } Is there any possible way can decode the 2D array above? class ModelA: Codable{ var i: [String]? var temp: [Any] = [] enum CodingKeys:...
0
votes
2answers
44 views

Adding data to existing array after using array data

I have an array of data that is being created from a MySQL query which I am then using to create more data which I then need back in the array (or a new one) but I haven't been able to get this ...
-2
votes
1answer
45 views

How to find group of three elements in array whose sum equals to target sum?

I can do this with three loops but complexity will be O(n3), can it be done with less complexity? Adding js fiddle code for three loops approach var arr = [1, 2, 3, 4, 5, 6, 7, 8]; var sum = 8; ...
0
votes
3answers
44 views

Sort an array based on another array element’s class

I am looking for way to sort elements in an array based on the classes of the elements in another array. I have: order = [String, Integer, NilClass ,TrueClass] arry = [1, 2, 3, 4, 5, true, false, nil,...
0
votes
0answers
27 views

Some problems with the arrays dimensions i guess

With this code i want to find a minimum in from a two dimensional function using the newton method: from numpy import array from numpy.linalg import solve, norm def newton2d(f, df, x, tol=1e-12, ...
0
votes
0answers
22 views

Python: Super Dictionary of Simple OLS

I am trying to build a super dictionary which holds within a number of lower level libraries Concept I have interest rates for my retail bank for the last 12 years and I am trying to model the ...
0
votes
5answers
40 views

add value to inner array using map in javascript

Hello suppose I have the following array: let array = [ { id: "1", name: "name", categories: [ { subid: "10", name: "name", }, { subid: "11", ...
0
votes
1answer
31 views

How to check if there are equal values in array [duplicate]

I have a an array of products which I loop though and display them on an item. However it can happen that the same product gets chosen multiple times the same day and I therefore want the quantity to ...
0
votes
1answer
57 views

How to compare a property to the values from an array of object?

d : {"children":[{"name":"China","children":[{"name":"China","value":400,"percentage":"33.33"}],"index":0},{"name":"England","children":[{"name":"England","value":300,"percentage":"33.33"}],"index":1}...
-1
votes
1answer
59 views

detecting a character in file and splitting the byte arrays in C

I have an array of bytes that I need to read from a file. I have to detect a character(basically an identifier telling me that what follows is a new set of data). So whenever I see this character I ...
1
vote
2answers
65 views

Python .txt file with numbers to rgba

Can someone help me with my project? I would like to save the data from a few temperature sensors via a data logger into a file and then analyze this with a Python program. That's my problem. After ...
0
votes
2answers
24 views

Pyspark dataframe: Count elements in array or list

Let us assume dataframe df as: df.show() Output: +------+----------------+ |letter| list_of_numbers| +------+----------------+ | A| [3, 1, 2, 3]| | B| [1, 2, 1, 1]| +------+-----------...