A sub-array is a subset of an array.
Questions tagged [sub-array]
434 questions
                    
                    90
                    
            votes
                
                6 answers
            
        In Swift, Array [String] slicing return type doesn't seem to be [String]
I'm slicing an array of strings and setting that to a [String] variable, but the type checker is complaining. Is it a possible compiler bug?
var tags = ["this", "is", "cool"]
tags[1..<3]
var someTags: [String] = tags[1..<3]
         
    
    
        Liron Shapira
        
- 1,967
- 1
- 14
- 17
                    27
                    
            votes
                
                1 answer
            
        How to get a subArray from Swift 2.0
I keep trying to search for the proper way to get a sub array in Swift but I am missing something here. This code doesn't work because rowArray.append(row) throws an error that states.
Cannot convert value of type 'ArraySlice' to specified… 
         
    
    
        Skyler Lauren
        
- 3,792
- 3
- 18
- 30
                    20
                    
            votes
                
                1 answer
            
        How to use MPI_Type_create_subarray?
It is clear that its arguments are:
int MPI_Type_create_subarray(
  int ndims,
  int array_of_sizes[],
  int array_of_subsizes[],
  int array_of_starts[],
  int order,
  MPI_Datatype oldtype,
  MPI_Datatype *newtype
);
However, I cannot understand…
         
    
    
        Pippo
        
- 1,543
- 3
- 21
- 40
                    16
                    
            votes
                
                2 answers
            
        How to properly return part of ArrayList in Java?
I have a class SomeClass with a static member myMap enter code herethat has the form HasmMap> which gets de-serialized from a file.
I have a method
public ArrayList getList(final String key, final int…  
         
    
    
        I Z
        
- 5,719
- 19
- 53
- 100
                    14
                    
            votes
                
                4 answers
            
        Group row data by one column value and populate a subarray in each group with the other column value
I want to group the data in an array with associative rows. Group should be determined by the type value and all label_id values within each group should be formed into a subarray.
Sample input:
$array = [
    ['type' => 'AAA', 'label_id' =>…
         
    
    
        408
        
- 161
- 1
- 1
- 4
                    13
                    
            votes
                
                7 answers
            
        Julia: does an Array contain a specific sub-array
In julia we can check if an array contains a value, like so:
> 6 in [4,6,5]
true
However this returns false, when attempting to check for a sub-array in a specific order:
> [4,6] in [4,6,5]
false
What is the correct syntax to verify if a specific…
         
    
    
        Nicky Feller
        
- 3,539
- 9
- 37
- 54
                    13
                    
            votes
                
                2 answers
            
        R array manipulation
In python lists can be sliced like this x[4:-1] to get from the fourth to the last element.
In R something similar can be accomplished for vectors with x[4:length(x)] and for multidimensional arrays with something like x[,,,,4:dim(x)[5],,,].  Is…
         
    
    
        momeara
        
- 1,341
- 2
- 17
- 29
                    12
                    
            votes
                
                3 answers
            
        Maximizing a particular sum over all possible subarrays
Consider an array like this one below:
  {1, 5, 3, 5, 4, 1}
When we choose a subarray, we reduce it to the lowest number in the subarray. For example, the subarray {5, 3, 5} becomes {3, 3, 3}. Now, the sum of the subarray is defined as the sum of…
         
    
    
        AvinashK
        
- 3,309
- 8
- 43
- 94
                    10
                    
            votes
                
                1 answer
            
        Filter a 2D numpy array
I want to have a sub array (between min and max) of a numpy 2D ndarray
    xy_dat = get_xydata()
    x_displayed = xy_dat[((xy_dat > min) & (xy_dat < max))]
min and max are float in order to be compare with the first value of the array…
         
    
    
        reynum
        
- 125
- 1
- 1
- 7
                    7
                    
            votes
                
                4 answers
            
        Two dimensional arrays and pointers
I have the following code snippet:
char board[3][3] = {
                     {'1','2','3'},
                     {'4','5','6'},
                     {'7','8','9'}
                   };
printf("address of board : %p\n", &board);
printf("address of…
         
    
    
        intex0075
        
- 115
- 1
- 7
                    7
                    
            votes
                
                1 answer
            
        Subarray from NSMutableArray
I have a NSMutableArray with many objects.
Can i extract a subarray from index range 'i' to 'j' directly?
Yeah i know i can do a loop and use objectAtIndex:x and extract each object to a new.
I need to call a method which input is an array and want…
         
    
    
        Jorge Vega Sánchez
        
- 7,430
- 14
- 55
- 77
                    7
                    
            votes
                
                3 answers
            
        Numpy unique 2D sub-array
I have 3D numpy array and I want only unique 2D-sub-arrays.
Input:
[[[ 1  2]
  [ 3  4]]
 [[ 5  6]
  [ 7  8]]
 [[ 9 10]
  [11 12]]
 [[ 5  6]
  [ 7  8]]]
Output:
[[[ 1  2]
  [ 3  4]]
 [[ 5  6]
  [ 7  8]]
 [[ 9 10]
  [11 12]]]
I tried convert…
         
    
    
        Petr
        
- 113
- 1
- 7
                    7
                    
            votes
                
                5 answers
            
        How to extract all possible matching arrays of objects from one array of objects?
I have an array of objects, e.g.  
var arr = [
    {"a": "x"},
    {"b": "0"},
    {"c": "k"},
    {"a": "nm"},
    {"b": "765"},
    {"ab": "i"},
    {"bc": "x"},
    {"ab": "4"},
    {"abc": "L"}
];
Let's say I am only interested in objects whose…
         
    
    
        lyrically wicked
        
- 1,185
- 12
- 26
                    7
                    
            votes
                
                9 answers
            
        Find the first occurrence/starting index of the sub-array in C#
Given two arrays as parameters (x and y) and find the starting index where the first occurrence of y in x. I am wondering what the simplest or the fastest implementation would be.
Example:
when x = {1,2,4,2,3,4,5,6}
     y =       {2,3}
result
    …
         
    
    
        Jeff
        
- 13,079
- 23
- 71
- 102
                    6
                    
            votes
                
                1 answer
            
        Taking views of views allocate in Julia
I noticed that taking views of non-"fast linear indexed" subarray allocates, while this is possible on classical vectors.
Any idea, how to make this allocation free?
Here is an illustration of the behavior:
function temp!(lin::Vector{Int},…
         
    
    
        Tanj
        
- 442
- 2
- 9