Questions tagged [arrayofarrays]
92 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
- 593
- 4
- 13
13
votes
4 answers
Create array of associative arrays
I want to create an array of associative arrays in a while loop. In each iteration 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
- 745
- 2
- 9
- 30
10
votes
0 answers
Issues with nullable reference types for arrays of arrays
Of course, C# supports unidimensional and multidimensional arrays, and supports arrays of arrays. Famously, if, in an array of arrays, the inner array type has a different rank (dimension count) than the outer array, then the C# language and the…

Jeppe Stig Nielsen
- 60,409
- 11
- 110
- 181
7
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
- 19,732
- 32
- 90
- 138
6
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
- 71
- 1
- 2
- 7
5
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…

Anton Degterev
- 591
- 2
- 12
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…

Yellowjacket11
- 71
- 1
- 7
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
- 691
- 5
- 14
3
votes
2 answers
MATLAB: Iterating through multiple double arrays to find min/max value
I'm currently trying to find the min/max value of 5 different 2x1 arrays of doubles on Matlab. I wrote a function below that works, returning the min and max values from all 5 arrays listed. However, it looks so long and bulky. I was wondering if…

Wallace Borges
- 33
- 4
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,935
- 10
- 28
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…

Jacopo Marconi
- 55
- 4
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
- 713
- 14
- 26
2
votes
4 answers
How to filter inside a filter in nested arrays in Javascript
I am trying to fetch all the costBreakdowns where the canceled status is false. So I am trying to filter() inside a filter() to fetch the complete array except the ones where the costBreakdowns have canceled is true:
const a = {
…

Code_ninja
- 21
- 1
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
- 408
- 8
- 20