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 specific to a programming language - tag the question with the programming language being used.

0
votes
1answer
5 views

C# LINQ multiple arrays to simple list of objects

I have an array of objects List<SlovnikWords>, here is the model: class SlovnikWord { public int Id { get; set; } = -1; public string Title { get; set; } public string Description { ...
0
votes
1answer
4 views

How to make the probability of a element being selected twice lower?

This code selects a random number from 1-27 and assigns that number to a index. Random A = new Random(); int picture = A.nextInt(27); driver.findElement(By.xpath("//android.widget.RelativeLayout[@...
1
vote
2answers
14 views

Numpy: Combine list of arrays by another array (np.choose alternative)

I have a list of numpy arrays, each of the same shape. Let's say: a = [np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]), np.array([[11, 12, 13], [14, 15, ...
-1
votes
1answer
26 views

How to generate set strings in javascript

Trying to generate a set of strings such as 'TCP', 'DNS' or 'SQL' I want to be able to have these strings set and be able to have them appear randomly like you would with random numbers.
0
votes
1answer
24 views

How to delete and add an element from an array based of the user input in JAVA?

String[] courseNames=new String[numbOfCourses]; Double[] courseCredits=new Double[numbOfCourses]; String[] gradeLetters= new String[numbOfCourses]; I asked the user to enter some course names,...
0
votes
0answers
7 views

Warning: key() expects parameter 1 to be array, null given in C:\xampp\htdocs\mom\functions.php on line 165

I have a problem with key() and current(). I want to make a fuzzy logic application. When I change the variable it works but errors happen in the rules. function to_string(){ global $HIMPUNAN, $...
1
vote
3answers
27 views

Create a Input and Label for each object in an array

I have populated an array with a list of ingredients. I need to make a dynamically create a checkbox & label combo for each object (just the "Name" Object) within the array here is the code that ...
-1
votes
0answers
23 views

How can methods alter object array?

I am very new to java, and OOP in general. I have created a class Card which stores a integer value and a string. Then, in another class called Deck, I want to create an array of type Card. I have ...
0
votes
3answers
28 views

How to fix code that extracts even numbered index values in an array of a sentence and combines it with odd numbered index values?

Basically, my code is supposed to encrypt a sentence(or word) by taking out all the even numbered index values(starting from 0) and the odd numbered index values and placing the even index values ...
-3
votes
0answers
15 views

How can I get my code to check if the other objects have been done before?

I have this shop I have set up that is supposed to calculate the discount and amount of product a user inputs. My problem is when choosing a function (1, 2, 3, 4 ) I am not getting the output I ...
0
votes
0answers
18 views

Built-in Way to Filter Text in Array to Exclude Periods, Commas, Etc?

Is there a "Built-In" method to filter out a string to exclude periods, commas, etc by default? It seems kinda janky to have it manually set. if the method being used is off I am open to ideas. This ...
-1
votes
0answers
41 views

Nested keys in a JavaScript object

I have a problem and I think it has something to do with the ".show('selector'," is blocking attempts to access nested keys [ ie: 'target' ]. Attempted: console.log(Object.keys(radar)); Logs: (2) [...
-2
votes
0answers
12 views

Error when trying to add to Array (Null pointer Exception) [duplicate]

NullPointer when adding to Array. I am making a family tree and I am new to Graphs in java so I am not sure if I am doing it correct. Problem is I keep getting this Null pointer exception. I think ...
0
votes
1answer
22 views

Storing text file in Oracle DB as BLOB cuts off the end of the file

I'm generating a text file in a process which at the end loops through a list of strings that were fed to it, and through a MemoryStream and StreamWriter it converts that list to byte[]. The byte[] is ...
0
votes
1answer
17 views

Typescript `custom type` only works in type world, but not actually working with `function`

I have a custom type called Tail, it will return array type without first element: type Tail<T extends any[]> = ((...t: T) => any) extends ((_: any, ...tail: infer TT) => any) ? ...
2
votes
3answers
35 views

How can I use 1 array with 2 different sizes using inheritance and constructors

I need to use a single array to track scores of a game where the indices are the levels of the game. In the parent class, the player is allowed 10 levels. In the child class, they are given 40 ...
0
votes
0answers
11 views

The program is printing raw array location when i try to convert the data to farenheit?? idk how to fix it [duplicate]

The program is printing array location when I try to convert it to farenheit idk why it is doing that.. I would appreciate it if i can get any suggestions. Should i make another while loop for ...
-1
votes
1answer
28 views

what is the algorithm that will give me O(logd)

the question is " Suggest an algorithm that takes a sorted Array and X , and it will return the index of X in the Array if it's not found in the array return -1 , the Time Complexity of the algorithm ...
0
votes
2answers
23 views

Text to pig latin translator inserts duplicate characters

I'm creating a c# Windows Forms app to convert English Text to Pig Latin, but the program is inserting the first letter (if it's a consonant) five times in the end, instead of just one. I was able to ...
1
vote
2answers
38 views

C - Counting number of same elements in 2 arrays

Let's say we have 2 arrays: char arr1[1024]="ABDDDABAC"; char arr2[1024]="DDDABKDDJABAJJ"; and would like to determine the position at which arr2 has the maximum number of matching elements as arr1. ...
1
vote
1answer
27 views

ng-multiselect-dropdown no data available

I am attempting to display an array of items in a ng-multiselect-dropdown. When I hard code the values in the array they show up, however when I attempt to create the array dynamically from items in a ...
0
votes
2answers
61 views

Javascript - adding Integers using arrays

I am using an array in order to calculate large powers of 2. The arrays add to each other and afterwords they calculate the carries and loop n-1 amount of times until i end up with the number as an ...
0
votes
0answers
14 views

Convert Json array into csv using Nifi

I'm looking to convert JSON with an array to csv format. The number of elements inside the array is dynamic for each row. I tried using this flow, ( attached the flow file xml on the post ). GetFile ...
2
votes
7answers
42 views

functions on arrays of different sizes in for loop

I have two arrays of different sizes that I want to perform logical functions on in a for loop. For example, if I have: array1 = [6,7,8] array2 = [1,2,3,4,5] I want to do each element from array1 ...
0
votes
3answers
52 views

Multiply a digit array by int in C

I have a very large number (>100 digits long) so it can't be stored as an int or even an unsigned long long (aka uint64_t). The array looks like this: {5, 1, 2 ... 8, 6} The array must contain single ...
2
votes
3answers
53 views

How to find a combination of 3 numbers from an array that, when added, equals another given number

I have an array that has multiple numbers in it. I want the function to return another array of maximum 3 numbers from the array that, when added together, equals another number. It can be 1 or 2 ...
2
votes
3answers
42 views

How to split 1 key value into 2 keys values

I'm new to JavaScript. I have the following object: let obj1 = [{ 'id': 1, 'longString': 'Joe - 2011-04-23T18:25:23.511Z' }, { 'id': 2, 'longString': 'Mary - 2010-04-23T18:25:23.511Z' }]; I ...
-5
votes
0answers
29 views

How convert simple function into arrow function?

This is my function, this function work normally. This function must traverse the elements in array: function infiniteLoop(a,d,n){ if (d ==="left"){ for (i = 1; i <= number; i++) { ...
0
votes
2answers
34 views

How to acces a nested json value when it has no key? [duplicate]

How can you access a nested json value when the value has no key? im trying to access the "2019-03-19T22:57:47.972Z" value of this json object: var json = {"metaData":[{"name":"ACTION_NAME"},{"name":...
0
votes
3answers
43 views

How to fix array method for finding if elements in one array exist in another in javascript?

I am attempting to solve a problem where if the elements in one array are squared, and all of the new elements are found in array 2, then return true, otherwise return false. My code looks right but ...
0
votes
1answer
12 views

How to get around issues with global variables when creating image gallery?

I am trying to create a click through image gallery for a project in pixi.js. You can see in my fiddle when you click on the right side of the screen it adds the next image. The problem is when you ...
0
votes
1answer
11 views

capture successfully inserted records into array

Using PDO to insert records from one table into another. I'm trying to capture the records that were successfully inserted into the other table, while also capturing the records that might have ...
-5
votes
0answers
50 views

C++ Array of pointers to an abstract class [on hold]

I have this homework for my OOP class which I hope someone can check for me: Make an abstract class ElementOnMap which contains a unique id (int), a type (char array) and a static var #ofElements. ...
-1
votes
0answers
23 views

_Right_data was 0xCCCCCD04 - Bubble Sort [duplicate]

I'm working on a Phone Book program where the Contacts should be sorted alphabetically, by last name. I'm getting this error (I've narrowed it down using the Call Stack) in the bubble sort function. ...
0
votes
1answer
36 views

How do I enter an array in D3.js?

Does It have a way to enter an entire array from my data set in D3.js? Or do I have to clean up It before enter? An example of my dataset .jason is here: [ { "promoter": "Vigun01", "upstream"...
1
vote
2answers
66 views

Why c++ vector inner elements/array are copied when passed by value

Why does the inner elements of the vector are copied when the vector is passed by value? #include<vector> using namespace std; // this func won't modify v[2]. // Meaning v[2] (and the whole ...
0
votes
1answer
45 views

Where is an array stored in memory in Javascript? [on hold]

We know objects are stored in the heap area. Suppose we are inside a function block where we declare: var a=[1,2] And var b=new Array(1,2) Will both the array objects be stored on the heap or ...
1
vote
3answers
80 views

Printing array of sums returned from function doesn't print the sums

The task is to return the sum of each row of a 2D array in a 1D array. Example int[][] values = { {1, 2, 3, 4, 5}, {2, 3, 4, 5, 1}, {3, 4, 5, 1, 2}, {4,...
3
votes
2answers
29 views

Nested Array Map

class Array extends React.Component { constructor() { super(); this.state = { newArray: [ { "Category": "Category1", ...
0
votes
2answers
36 views

Javascript return array from array of objects where property value matches

Is there a built in Javascript function or library to do the following: const data = [ { name: 'name1', type: 'type1' }, { name: 'name2', type: 'type2' }, { name: 'name3', type: 'type3' },...
0
votes
4answers
40 views

How to filter out matches between arrays, and add an additional key/value?

I have 2 arrays that contain objects. Each object has a key/value pair of "color" and "number". I want to check against these 2 arrays to find the objects that match the "number". After finding this, ...
-2
votes
0answers
10 views

Extracting data from elaborate event calendar FULL of javascript to excel?

I am trying to automatically extract the data from this online event calendar to make an excel spreadsheet: http://caninechronicleshowcalendar.com/K9shows.php?rand=9623&week=2458565&brno=...
0
votes
1answer
11 views

Array difference in postgresql

I have two arrays [1,2,3,4,7,6] and [2,3,7] in PostgreSQL which may have common elements. What I am trying to do is to exclude from the first array all the elements that are present in the second. So ...
0
votes
0answers
26 views

“Subscript requires Array or Pointer” Error

I am trying to find the sum of values in an array, but keep getting different type of errors. I am currently getting a "subscript requires array or pointer" type error. My code for user entering ...
0
votes
1answer
33 views

PHP: How to add value to array within foreach

I have the following array: $cards = array(); foreach($cardList as $card) { if ($card->getIsActive()) { $myValue ='my_value'; $cards[] = $card->getData(); // need to add $myValue to $...
0
votes
2answers
62 views

How do I iterate through multiple arrays

How would I iterate through these 5 array in a function call? Right now I am just manually iterating through each to form a specific character
1
vote
2answers
21 views

Numpy savetxt saves 1D array as column

I use loadtxt to initialize array. source = np.loadtxt('source.txt').astype(int) After that I use this array in function, which body is: file = open('johnson.txt', 'ab') first = increase(np.argsort(...
2
votes
1answer
28 views

Maximum possible integer x, such that sum of every element of array divided by x is not less than k

We are given an array of n integers, and a constant value k, can any one suggest me to find out the maximum possible integer x such that arr[0]/x + arr[1]/x +.. arr[n-1]/x >=k , -> where '/...
0
votes
5answers
40 views

show array from database

I have this db id | domain | whois_server | --------------------------------------- 1 | ac | whois.nic.ac | 2 | ae | whois.nic.ae | 3 | id | whois....
-1
votes
2answers
28 views

print multi dimentional json array in java [duplicate]

My app fetches JSON response from server. The response string has multiple rows and columns. I need to print this in java. Here is my JSON response : [ { "name": "name2", "id": "99", "...

http://mssss.yulina-kosm.ru