Join us in building a kind, collaborative learning community via our updated Code of Conduct.

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
0answers
13 views

.map is not a function - react

I'm trying to map over an API response but it gives me "TypeError: response.map is not a function". I think it might be due to the map method getting a string instead of an array. but when I console....
0
votes
1answer
6 views

Prompt user to Input Numbers in Array and then Sum it using JavaScript

This works fine if I sum numbers in JavaScript in an Array. But when I ask their input from User then they are printed as if the numbers are in string. Kindly help me in finding the flaw in my code. ...
-1
votes
2answers
26 views

Mutation of array/list

I am trying to solve a problem which states to remove(delete) the smallest number in an array without the order of the elements to the left of the smallest element getting changed . My code is -: ...
0
votes
1answer
11 views

PHP Multidimensional Array Extract Specific Values Based Upon Key

I'm trying to create an anchor link by extracting specific array values based upon based upon the key. I've tried using a foreach loop inside of a for loop, however that doesn't seem to work. Based ...
0
votes
0answers
9 views

Python 3 fastest data structure for storing positions and values of a matrix in a loop

Given a matrix (two dimensional numpy.array) I am using a loop to iterate over each position. For some specific positions I want to store the value and the position to access it in later iterations of ...
-2
votes
3answers
32 views

Array with random integers

I need and array that generates 10 random numbers between 1 and 5, inclusive. I then need to display the number of times 1-5 shows up in the array. This is what I have so far, it runs fine, it's just ...
-4
votes
1answer
40 views

In C++ how can I extract members from an array and return an array of the member's type?

namespace detail { template <typename T, typename U> Array<U> extract_(const Array<T>& array, std::function<U(const T&)> member) { Array<U> ...
-3
votes
1answer
24 views

converting boost::filesystem::path into char ??

i have worked out how to pass the boost path the required format, but i am having some issues figuring out hot to pass the path.stem into a char array, and then run some check on the filename and ...
0
votes
0answers
4 views

Database group by column

SZ | name | Date | back_number 1234 | John | 18.8.2018 | 5512345 2391 | Bels | 18.8.2018 | 6685800 3498 | ESON | 18.8.2018 | 6685800 4531 | me | 18.8.2018 | 5512345 4531 | me | 18.8.2018 | ...
0
votes
4answers
34 views

Incrementing value of an array from another array

I have 2 arrays $array1 = array(22,193,124); $array2 = array(array('id'=>22, 'count'=> 1), array('id'=>124, 'count'=>2)); Now I need to search in $array2 for id from $array1 and if found ...
0
votes
0answers
7 views

Qbasic - trying to call a sub, but i get a message that says “Expected CALL, subname, (…)”

Here is the code, it takes 5 names and alphabetizes them. I have a sub that sorts the names but apparently i'm not calling it in the correct way. DIM i AS INTEGER DIM q AS INTEGER DIM a AS STRING DIM ...
0
votes
1answer
19 views

Arrays manipulation and indexing

I am trying to plot a curve defined as follows : import numpy as np import pandas as pd import matplotlib.pyplot as plt limit1 = 50 nPoints1=50 x1 = np.arange(0,limit1,1) noise = np.asarray(np....
0
votes
1answer
25 views

Removing Array element when user didDeselectRowAt?

I'm trying to remove an item of an array when the user deselects a cell. I understand why my code it's not working, basically, the array might contain 5 elements and if there are 100 cells and the ...
-5
votes
1answer
29 views

Randomize elements within objects within arrays for javascript

I want to create a short fun project where I can randomize the "answers" function, and I can choose to display the "riddle" element of that randomized object. Is there a way to do that? var answers = ...
0
votes
3answers
50 views

how to compare order of two list when one list is not stable

I have some string objects which I store inside a List, for example : [US, CN , IN, EN, FR, GR, PL, MX] and the order of the expected list should be same as above list all the time. but the catch ...
0
votes
1answer
31 views

Given 4 arrays, unsorted, find all possible quadruples with sum <m

Given four arrays of equal length which are not sorted and they have unique elements in them but across the arrays elements can clash so we were asked to pick one element from each array and satisfy ...
0
votes
1answer
14 views

Julia: Template functions to accept multiple array types

I'm trying to maintain code reusability whilst using the Array type, but am unsure of how to proceed without allowing "illegal" types through. Example functionality: foo = function(x::Array{Number,2})...
1
vote
2answers
44 views

convert string array to float array in C#

We are getting an error when trying to run this code ideally changes e.Message from string to a double or float array. Please help us understand what the error means, or how to debug the code. We ...
0
votes
1answer
27 views

Filtering numpy array of numpy arrays

I've got a np array of array and I want to remove all elements that match a condition. I want to avoid for loops to try to make if faster. My np array has size of N. And inside, there are arrays of ...
0
votes
0answers
21 views

How to Access Object properties by Key [duplicate]

I'm trying to access a specific property in an object. The object has unique keys (referencing state codes). I'm wondering how I can access the label property be referencing the unique state code (ex. ...
0
votes
0answers
7 views

self.scan_once(s, idx) json.decoder.JSONDecodeError: Expecting ','

I have a large json file (2.4 GB). I want to parse it in python. The data looks like the following: [ { "host": "a.com", "ip": "1.2.2.3", "port": 8 }, { "host": "b.com", "ip": "2.5.0.4", "...
0
votes
1answer
20 views

Python - running into x_test y_test fit errors

I have built a neural network and it worked fine with a small dataset of around 300,000 rows with 2 categorical variables and 1 independent variable, but was running into memory errors when i ...
-1
votes
2answers
40 views

How can I make my array choose different choices each time it runs?

Right now, I have an array with three options. I have a function set up so it chooses one option each time, but sometimes it repeats outputs. How can I code it so the same color does no repeat twice ...
0
votes
1answer
38 views

How to deal with the elements in the array in the following format? [on hold]

this is my array: $a = [1,2,3,4,5]; Processed format: 1,2 1,3 1,4 1,5 2,3 2,4 2,5 3,4 3,5 4,5 The two elements are a group. If only the last element is left, it ends.
3
votes
2answers
42 views

Compress repetition of 2 dimensional array with javascript [on hold]

var mycars = [['Ford', 'Fiesta', 'Manual', 'Rp. 160.000.000'], ['Ford', 'Fiesta', 'Manual', 'Rp. 163.000.000'], ['Ford', 'Fiesta', 'Automatic', 'Rp. 170.000.000'], [...
2
votes
1answer
32 views

multi-dimensional javascript array only affecting last array in forEach [duplicate]

I have a multi-dimensional array in JavaScript that holds basic Usernames and to-be hashed passwords. At the moment, when the function to check the credentials is called, the forEach will only check ...
1
vote
1answer
19 views

How to edit value in a sub array

I can't understand this behavior in powershell : $PSVersionTable.PSVersion "" $matrix =, @(, @("foo") * 5) * 3 $matrix[0][1] = "bar" foreach($subArray in $matrix){ Write-Host $($subArray[1]) }...
-1
votes
1answer
24 views

“/usr/lib/python3.6/json/init.py”, line 296, in load return loads(fp.read(), MemoryError

I have a large json file (2.4 GB). I want to parse it in python. The data looks like the following: [ { "host": "a.com", "ip": "1.2.2.3", "port": 8 }, { "host": "b.com", "ip": "2.5.0.4", "...
2
votes
7answers
50 views

Convert nested array to an object

I am trying to use reduce to convert a nested array to an object. I want to convert var bookprice = [["book1", "$5"], ["book2", "$2"], ["book3", "$7"]]; to var bookpriceObj = { "book1": "$5", ...
0
votes
0answers
27 views

Return array from object if contains string jquery

I use regex to query all square brackets in string by this command: var sizecolor = textvalue.match(/[^[\]]+(?=])/g); I want to get a square bracket in object above if it contain "SPrice"; Example: ...
1
vote
2answers
32 views

Rail convert array into group

I am trying to convert one of my array into some format where it can convert itself into table format. I have an array which is: [ { id: 1, Revenue_Account: "Revenue Receipt", ...
0
votes
2answers
46 views

Typescript or Javascript: searching for multiple words

const arr = ['hello', 'test', 'two words'] const string = 'this is two test words' what i try to achieve is to check if this two words 'two words' in arr comes back in the string even if they are ...
1
vote
1answer
59 views

Need single code to work on multiple inputs

I am creating a gallery by scraping a folder of images, each image also has a dropdown. I can get the code to work for a single split value dropdown, but when i add the code to my image array, it only ...
0
votes
0answers
20 views

How to post an array of ObjectId references to an existing collection in node js

I am new to Mongodb and nodejs. My questions is with respect to performing an post operation on collection in mongodb that stores ObjectId references to another collection. Exact Scenario being: I ...
1
vote
1answer
26 views

Choose indices in numpy arrays on particular dimensions [duplicate]

It is hard to find a clear title but an example will put it clearly. For example, my inputs are: c = np.full((4, 3, 2), 5) c[:,:,1] *= 2 ix = np.random.randint(0, 2, (4, 3)) if ix is: array([[1, 0,...
-1
votes
1answer
49 views

Printing output in main, not in the function

I have a main function, which calls readNumbers to create a dynamically allocated array of length prompted by the user. Then, this array is passed to printNumbers, which prints the index of the ...
1
vote
1answer
15 views

Detect if values are repeated and apply order criteria using Laravel and collections

How can I detect if a value is repeated in a collection? And if it repeats, apply a criterion of order for the following value? I have the following collection where if the "total" value is repeated ...
0
votes
1answer
35 views

Javascript recognize random choice from array

I have an array that chooses one of three colors at random every time the function runs. How could I make Javascript identify the random color choice as the same variable every time the function runs. ...
0
votes
1answer
18 views

There is any rule for define a json key in JavaScript?

I'm learning JavaScript and I was looking for a while about this and I have not got any answer about this. My question is if there is any rule to define a JSON key in JavaScript. For example, in ...
0
votes
0answers
20 views

How to access array values from a cross-reference array with angular (click)

I have a cross-reference array: examples = [{name: "ex1",steps: 'ex1Steps'}, {name: "ex2",steps:'ex2Steps'}, {name: "ex3",steps:'ex3Steps'}]; and 3 arrays ex1Steps ... ex3Steps=...
-1
votes
0answers
37 views

table data only showing [0] array value

Hey guys i stuck in project, In my table i create Foreach loop and fetching data from database and gives different id to every td in table and posting it through ajax. I have 3 data in my table. ...
-3
votes
1answer
50 views

How to merge the array with same value and updated the exsiting value?

Array ( [0] => Array ( [0] => ABC [1] => CTweak [2] => 5 ) [1] => Array ( [0] => DEF [1] =...
-4
votes
2answers
51 views

How to split this complex string

I have a variable string mymvariable which contains : 864827,,,34200,Sète ,,,445958,,,30220,AIGUES MORTES,,,169807,,,34570,PIGNAN,,,546049,,,13006,MARSEILLE,, I would like to cast this string to an ...
0
votes
4answers
22 views

redirect user with session user role in their respective dashboard

I have kept the array in the session and i want to redirect user to admin if the user role is admin and other also. But i am unable to do so?? I dont know where the problem is. The session is not ...
-9
votes
0answers
42 views

How do i do sum of n values from array in javascript? [on hold]

Assume i have an array as seen below: tax=["2", "2", "4", "6", "8"]; How do i do summation of first n elements alone in javascript? If n is 3, then i should get sum as 8 (2+2+4). Also, is there an ...
2
votes
2answers
32 views

Add Columns And Separate By Category

I have a datatable that is using standard features (pagination, sorting, searching, date range, etc.), but I also need to have a portion at the bottom of the table that displays the total salary of ...
0
votes
0answers
18 views

Python (or prolog!) building an y array from a given set of sub-arrays, with items of the sub-arrays not part of y. Zebra like puzzle

I'd really need some help with a problem related to a mastermind-like game that I'm writing in my free time, to play with my nerd-friends :): I'm stuck with this, and it's quite challenging for me: I ...
1
vote
3answers
64 views

Why can I loop down through an array, but not up - Javascript

Can someone please explain why this doesn't work: function filterNumbers(arr) { for (var i = 0; i < arr.length; i++) { if(typeof arr[i] !== 'number') { arr.splice(i, 1); } } } ...
-2
votes
1answer
51 views

C# Multi-dimensional arrays lengt [duplicate]

I have an array: string[,] array = new string[5, 24]; I want to get the length/size of the first array = "5".
2
votes
2answers
28 views

Compare each index in single array

I have a function to calculate distance, the data comes from a database. Here is the code for calculating: function jarak() { global $conn; $query1 = mysqli_query($conn, "SELECT signature, ...