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
3
votes
1answer
18 views

Pythonic way to replace specific values with other values of numpy array within particular indices

I have seen answers for each part of my question. For example np.where(arr, b, c) converts all b's in arr to c. Or arr[arr == b] = c does the same. However, I have 1000 labels in a numpy array, ...
0
votes
1answer
21 views

How to load the selected option JSON object from an array by clicking button?

I have typescript file of JSON objects. These JSON objects can be selected as options from a dropdown list. I need to know how to load/instantiate the selected JSON object when the user clicks the ...
0
votes
1answer
21 views

mapping json from a fetch function into setstate

I am trying to map a json response into a state, what I am trying to do is map all the children of this array no matter how many, as in skipping the first array and only show its children, here is ...
0
votes
0answers
5 views

MASM beginner, help me out? probably easy…:(

The steps I must complete: Create an array of 50 unsigned integers. Then I must ask the user for a number between 10 and 30 (this will serve as the number of cells in the array we will fill). Finally, ...
-1
votes
3answers
26 views

How do you fix an incompatible types error? [duplicate]

The program I wrote is giving me an error and i don't know how to fix it. I've tried a few different things and they didn't work. public static boolean isVowel(char c) {     c = Character....
-2
votes
1answer
19 views

Is there a function or method Array.reduce in swift?

I would like to reduce the array of strings into a single string using the built in array.reduce closure method. I know using the join method is easier. Just wanted to see if there is a way?
0
votes
0answers
12 views

Cart Array is not updating correctly

I have a cart object with property items[] and want to update the ui when the user added a product button and the view cart is clicked a div is open with all the products in the cart.items[]; I ...
1
vote
1answer
22 views

Fetch data in array's order

I have an array which contains a list of IDs. With it, I'm trying to fetch some posts data from the WordPress REST API. I managed to retrieve the data I was looking for, but the issue I'm running into ...
1
vote
0answers
25 views

Get an object with null values from an array of nested objects

I have an array of nested objects. How do I get an object with null values using only a particular key in the array of objects? let headers = [{ title: 'Arun', id: 'arunId', ...
0
votes
1answer
30 views

Add missing keys, values and data to json object

I have a large piece of json data that dynamically change but. Each JSON Object has a date, site_nm and more values. The dates dont match for all. The distinct dates in this dataset are: 2019-10-01,...
-2
votes
2answers
32 views

Index Item Alterer

Could someone help me out here? I'm trying to create a small javascript code snippet that selects a random item from and array and alters it to be either 'A', 'T', 'G' or 'C' (dna strands) but it ...
-3
votes
0answers
15 views

How to mutate array struct in C

Here is a problem from a "CodingSignal" practice test. Time ran out and I wasn't able to solve the problem. Anyone know how you would code this in C? Prompt: Given an integer n and an array a of ...
0
votes
1answer
25 views

Need to pass an HTML ID for an image into a variable in javascript to use in various functions

I am trying to use code from html into javascript using code from https://www.geeksforgeeks.org/how-to-get-the-id-of-the-clicked-button-using-javascript-jquery/. I am creating a memory game I have ...
0
votes
0answers
32 views

Is there a more concise way to define this array of function values in Python?

I am new to Python. I want to apply various permutations of three functions f, g, and h where juxtaposition means function composition (e.g., fg(x) = f(g(x))) to say, a list x of boolean integers, ...
-2
votes
1answer
43 views

Do math across two arrays

I need to subtract one array from another, by index: a = [3,4,3,5] b = [1,2,2,1] c = [2,2,1,4]
0
votes
0answers
5 views

export scrap to .csv

I added the csv gem to my gemfile but no data in my csv, any idea please ? array_final = [{"BTC"=>"7991.16"}, ...] require 'rubygems' require 'nokogiri' require 'open-uri' require 'csv' def ...
0
votes
2answers
23 views

Why does array content get wiped and reset to the first result for a recursive function?

The issues stems from the output.append(a) on the third line. This program would ideally output 6 unique permutations of the input string, but instead returns 6 of the first result in the recursive ...
0
votes
1answer
38 views

How paginate from data is coming from a json in Angular

I am new in this I have a service with HTTPclient is get all the data from a JSON file have 1000 register, how I can make pagination, for example, show the first 10 and paginate it this is my service ...
0
votes
0answers
29 views

Array Index Out of Bounds Java - I can't catch the error?

I apologize if I've formatted this wrong. I have recursive method (recurseBoats(n)) that takes a parameter n, and generates a random point on a 2d 'char' array (pointS). It then checks if the spaces ...
0
votes
1answer
27 views

Compare two wchar arrays within nested for loops?

hope someone can help me figure this out i´m kind of new to C++ and programing.. I have 2 different arrays first one is Alphabet from a-z second is a integer array filled with virtual keycodes ...
1
vote
2answers
33 views

Interlace Rows 2D Numpy Array

I have a 2D numpy array that looks like this array([[x1,x2,x3,x4], [x2,x3,x4,x5], [x3,x4,x5,x6], [y1,y2,y3,y4], [y2,y3,y4,y5], [y3,y4,y5,y6],]) I want to interlace ...
0
votes
2answers
29 views

Segmentation Fault in C when Initializing an Array

I am trying to dynamically create an array in a separate function and store some variables inside of that array and I came across the following: how come when I write; #include <stdio.h> #...
1
vote
0answers
19 views

How to Pass 2D Array to a Function to be Modified With Pointers C++

#include <iostream> using namespace std; //Constants const int EMPLOYEE_NUM = 4, MONTH_NUM = 5; const double MONTH_QUOTA[MONTH_NUM] = {1, 1.05, 1.1, 1.15, 1.2}; int main () { //Define ...
0
votes
1answer
28 views

Getting hashmap keys based on parameter value and values lower than it

Basically I want to iterate through a hashmap with a value given by the user but also include any smaller values "price" that have keys. Possible values that have keys are 1250, 900, 600, 300. e.g. ...
1
vote
1answer
17 views

Creating an array of structures with data entered by the user

I have an assignment where I need to create a program that explores FIFO queues. The task is to create a array in which each element holds 2 numbers x and y. And then you have to have a push, pop and ...
0
votes
2answers
29 views

Animating DOM elements in an array

I have been attempting to code a Simon Says game and so far I have gotten everything working except for the animation aspect of the game. Whenever the code iterates through the array, it animates the ...
0
votes
0answers
8 views

Is it possible to assign typealias for 2D dimension array in Swift? typealias MatrixT<T> = [[T]]

I'd like assign typealias for 2D generic array. (I don't want to create new type struct MatrixT<T>{}). So I do next: typealias MatrixT<T> = [[T]] But when I started write extension for ...
0
votes
2answers
24 views

how eliminate duplicates by two fields from a multidimensional array php

Array ( [piata-fortei-munca] => Array ( [0] => Array ( [date] => 2019-10-19 09:10:07 ...
0
votes
0answers
32 views

I want to hide a specific navigation bar based on user role

I am having hard time hiding a specific nav bar when the user is succefully log in as admin,I want to hide the navigation bar class named "ordertrackingClass" when the user is log in as admin. here's ...
0
votes
3answers
47 views

read from file and insert in the array

I have a file and I want to read this file(is big file and it has 10000 word) and I want to add word by word and add in the array and I want to count the word how many times Repeats, but I found this ...
0
votes
2answers
43 views

How to initialise array of structs in another struct?

I have the following code that produces a compile error. It is for a command parser for a STM32 micro-controller written in C++. Basically I have a CMD_DEF_ST struct with a string and a function ...
0
votes
0answers
13 views

Draw 8 x 15 Rectangle-Grid in C++ with OpenGL - crash down

i want to create 8 x 15 Matrix of Rectangles in C++ with OpenGl. I first create a Class for just a rectangle. Then i created a class for a row of Rectangles, it contains an Array of 8 Rectangles. Then ...
0
votes
0answers
15 views

How to put int values inside an array from another activity

I am trying to make my first android application but I can't seem to get my codes to work as planned. It crashes as soon as it goes to the second activity. I want to pass the 3 j variable on the ...
0
votes
0answers
12 views

Breaking down large 3d array into blocks and iterating for whole 3d array

I have a large 3D image which takes up around 1.2GB. With all the computation I am doing, I may have to store it outside of RAM I have manage to work out my code of a very very small section of this ...
2
votes
4answers
42 views

Filter nested array of objects to array of objects

I have an array of objects which is nested. How do I make an array of objects with this one getting values from nested properties as well? If onClick property is empty, it means there is a property ...
0
votes
1answer
31 views

How to decode data of an array that is save and read from userDeafults - Swift

I am working on a project that it has a plist contains of rows of dictionaries , and then , I put all the rows of datas to an array and I save it to the useDefaults and all these things seems correct ,...
-1
votes
3answers
33 views

How to find the sum of sums of an array using recursion?

I'm trying to create a program that sums the sums of an array using recursion. For example, if I have an array {1, 8, 6, 15, 10}, I would first sum elements 0-4, and then I would sum elements 1-4, and ...
-1
votes
0answers
33 views

Minimum number of swaps needed to group all similar together in Array

We are giving a circular array with integer from 1 to 4. I can swap any two elements, any number of times. how can I find the minimum number of swaps needed to bring all similar elements together in ...
0
votes
0answers
12 views

How to merge two arrays of same size into an array of tuples with numpy? [duplicate]

I have a project in python where I want to get a 2D matrix filled with coordinates: First, I use the meshgrid function to get my coordinates in 2 arrays: X, Y = np.meshgrid(np.arange(5), np.arange(...
-1
votes
3answers
33 views

How to replace chars in a string with other chars in a string using two input arrays

I have a string and want to replace all chars inside of an array of chars with the corresponding chars in an other array, how would I do that? sample input/output: translate("ㅎello") => "Hello" ...
1
vote
2answers
40 views

numpy's transpose method can't convert 1D row ndarray to a column one

Let's consider a as an 1D row/horizontal array: import numpy as np N = 10 a = np.arange(N) # array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) a.shape # (10,) now I want to have b a 1D column/vertical array ...
0
votes
2answers
41 views

i want to sort an array in php [duplicate]

Array ( [0] => Array ( [count] => 9 [slug] => concediat-reangajat ) [1] => Array ( [count] => 7 [slug] =&...
0
votes
0answers
27 views

Cannot filter empty element from an array

I have a problem with this piece of code. I import input data from a file formated like so and store it in const input: aabcccccaaa aaccb shsudbud There are no spaces or any other white characters ...
1
vote
0answers
23 views

LUA - Arrays management (add/remove elements)

I have two arrays: A={4,8,12} B={1,2,3,5,6,7,9,10,11} And these code, the essence of which is, when calling the function, take a random value from array B, insert it in the order of the queue into ...
0
votes
2answers
28 views

jQuery Dynamic Array with matching Value

I have the following data in my jQuery object: Group - Rank - Value A - 1 - 200 B - 2 - 200 C - 3 - 200 D - 3 - 500 E - 3 - 600 F - 3 - 400 G - 4 - 100 H - 4 - 300 I am trying ...
0
votes
1answer
47 views

Pass Node.js array from endpoint to Javascript function

I have a html chart that will display my array from a javascript function 'window.testDataArray'. I would like to replace the sample array with the array data from the server endpoint. I am not sure ...
-1
votes
1answer
37 views

adding a new value at a certain index in an array and return boolean [on hold]

Add item value at index param idx param value return true if value can be added at index idx, false otherwise (if idx is invalid). For eg: If a list contains 5 items, we can add a new value at any ...
0
votes
0answers
7 views

Optimal way of handling large binary data in Android?

In my app, I have a long-ish running task (up to 10-15 minutes) during which the app transfers large amount of data (up to 16MB) from a BLE device. The current implementation uses RxAndroidBle for ...
1
vote
1answer
51 views

Swift 4: How many times an element from a String array occurs in a String?

Right now I'm making a small project with the Bible showing miscellaneous facts and data, by book. I have the actual bible verses and chapter in text, decoded from JSON remotely. The problem is I ...
-2
votes
1answer
42 views

Is there anything in JavaScript like PHP's explode() method?

Is there anything in JavaScript like PHP's explode() method? Something that can take two arrays and combine each of their respective values? And the arrays are not the same length. Like this: array1 ...