Questions tagged [arrayofarrays]

63 questions
30
votes
9 answers

What is the difference between char*str={"foo",...} and char str[][5]={"foo",...} array definitions?

Case 1: When I write char*str={"what","is","this"}; then str[i]="newstring"; is valid whereas str[i][j]='j'; is invalid. Case 2: When I write char str[][5]={"what","is","this"}; then str[i]="newstring"; is not valid whereas str[i][j]='J'; is…
Ashish Dogra
  • 583
  • 4
  • 13
12
votes
4 answers

create array of associative arrays in PHP

I want to create an array of associative arrays in a while loop. In each itteration of the while loop I want to add a new element in the array. How I can do that? After that I want to pass this array in a foreach and print the data. I have this part…
anna
  • 715
  • 1
  • 9
  • 30
6
votes
6 answers

Combine two array's data using inner join

I've two data sets in array: arr1 = [ ['2011-10-10', 1, 1], ['2007-08-09', 5, 3], ... ] arr2 = [ ['2011-10-10', 3, 4], ['2007-09-05', 1, 1], ... ] I want to combine them into one array like this: arr3 = [ ['2011-10-10', 1, 1, 3, 4], …
WoooHaaaa
  • 17,162
  • 29
  • 79
  • 130
5
votes
3 answers

Object to Array (an array of arrays)

I am trying to convert an object literal into an array of arrays by using a function. Using the two sample objects I have, the end result I'm looking for would be: [ ["ugh","grr"] , ["foo", "bar"] , ["blah" , 138] ] from obj1 […
Dabi Lobi
  • 61
  • 2
  • 6
4
votes
3 answers

Julia: A fast and elegant way to get a matrix from an array of arrays

There is an array of arrays containing more than 10,000 pairs of Float64 values. Something like this: v = [[rand(),rand()], ..., [rand(),rand()]] I want to get a matrix with two columns from it. It is possible to bypass all pairs with a cycle, it…
4
votes
1 answer

Creating an array of empty arrays in Ada

I am trying to write an Ada equivalent of the following statement in Python: L = [[] for i in range(n)] I am solving a dynamic programming problem and my plan is to eventually copy the contents of the jth array inside L into the ith array (j < i) if…
4
votes
2 answers

Julia: counting total number of elements in an array-of-arrays

Is there a single function in Julia that will give you the total number of elements in an array-of-arrays (or 'jagged array')? Here's what I mean: my_array_of_arrays = [ [1, 5], [6], [10, 10, 11] ] I'm looking for a function such…
Conor
  • 611
  • 2
  • 9
3
votes
2 answers

How to convert an array of array to array in Julia?

In the following example I am getting an array of array as an output. I would like to seek suggestion on reducing it to n-element vector. Example: I have a vector x and then I perform subtraction on first 2 elements of the array which outputs a. x =…
Mohammad Saad
  • 1,371
  • 2
  • 14
3
votes
2 answers

Julia "strange" behaviour using fill() and .+=

I observe an unexpected behaviour for ".+=" in my code (it's probably just me, I'm rather new to Julia). Consider the following example: julia> b = fill(zeros(2,2),1,3) 1×3 Array{Array{Float64,2},2}: [0.0 0.0; 0.0 0.0] [0.0 0.0; 0.0…
3
votes
2 answers

Access elements of arraylist of arraylist of arraylist?

I am new to Java, and I am currently using BlueJ for a project. I am having troubles accessing the objects inside an ArrayList of an ArrayList of such objects. Say I have a Student object: public class Student { private String homeAddress; private…
Sveva
  • 33
  • 4
3
votes
2 answers

Building a parent/child array menu structure from SQL query result

I need to build a complex menu structure dinamically using a MySQL DB query. The query allows to define the menu items the user is entitled to use and see. The Menu structure is stored into a results set in a classic parent/child relation where each…
Power Engineering
  • 635
  • 12
  • 22
2
votes
2 answers

Reduce Array of Object Arrays to Array of Objects

var data=[ {name:'Sam',ssn:123, age:25, hobbies:[{name:'cricket'},{name:'football'}]}, {name:'John',ssn:234, age:25, hobbies:[{name:'cricket'},{name:'football'}]}, {name:'Mathew',ssn:345, age:25,…
Mithun S
  • 343
  • 5
  • 15
2
votes
1 answer

How to delete a specific array in an array of array references?

I am interested in deleting a specific array from an array of array references. Towards this end I loop through the array references and look for a match. If a match is found, I attempt to delete this specific array reference by setting it to equal…
Emma
  • 23
  • 4
2
votes
4 answers

Javascript - Is there a more efficient way to create an array of arrays? - Examples provided

Question: Is there a more efficient way of creating an array of arrays of incrementing numbers? I've created a function to produce an array of arrays of incrementing numbers, which took far longer than expected, and I'm sure there is a more…
Ryan M
  • 43
  • 1
  • 4
2
votes
1 answer

Google-Apps-Script can not write back a database with getDataRange().setValues()

I have a database loaded from a google spreadsheet: mydatabase = sheet.getDataRange().getValues() which then I extend with a new record: mydatabase.push(mydatabase[x]) and then at the end of the script, I would want to write back the entire database…
1
2 3 4 5