Category "arrays"

Split array into 4-element chunks then implode into strings

$array = [1, 2, 3, 4, 5, 6, 7, 8, 9]; I want output like ['1, 2, 3, 4', '5, 6, 7, 8', '9'];

Adding 2D arrays in Assembly (x86)

I have to add two 3*3 arrays of words and store the result in another array. Here is my code: .data a1 WORD 1,2,3 WORD 4,2,3 WORD 1,4,3 a2 WORD 4, 3, 8

passing an array to web-service php nusoap

i have a problem with passing an array to a web-service function that i created with php and nusoap. the problem is that i guess i'm doing something wrong.. i s

Merge key and value of array index [duplicate]

I have an array as follows: ['foo'=>'bar','baz'=>'bat'] im trying to determine an elegant way (not using a standard forloop, prefer lea

Printing more than one array using print_r or any other function in php

I need to print contents of multiple arrays in my code. Eg function performOp($n, $inputArr, $workArr) { printf("Entered function, value of n

numpy's interp function - how to find a value of x for a given value of y?

So I have an array of values of x (in increasing order) and the corresponding y values. Numpy's interp function takes in the X value, and the x and y arrays. Ho

3-Dimension List or Map

I need something like a 3-dimension (like a list or a map), which I fill with 2 Strings and an Integer within a loop. But, unfortunately I don't know which data

Remove pair duplicates from array of values

The problem In lua I have an array of values (specifically - x and y position values) from which I would like to remove duplicate pairs. The array looks as fol

In a CUDA kernel, how do I store an array in "local thread memory"?

I'm trying to develop a small program with CUDA, but since it was SLOW I made some tests and googled a bit. I found out that while single variables are by defau

javascript - match string against the array of regular expressions

Is there a way in JavaScript to get Boolean value for a match of the string against the array of regular expressions? The example would be (where the 'if' stat

Why is this PHP array not the same?

I'm not understanding why the array: <? $data = array( 'items[0][type]' => 'screenprint'); ?> Is not the same as <? echo $data['items'][0]['typ

ElasticSearch aggregation query that concatenate array of strings into one bucket if attribute has value

The aim is to create an aggregation query in ElasticSearch that concatenate array of strings into one bucket if the attribute has a certain value. An example J

Remove objects with a duplicate property from List

I have a List of objects in C#. All of the objects contain a property ID. There are several objects that have the same ID property. How can I trim the List

Daily Coding Problem 260 : Reconstruct a jumbled array - Intuition?

I'm going through the question below. The sequence [0, 1, ..., N] has been jumbled, and the only clue you have for its order is an array representing whether e

Is it possible to define function that creates an N-dimensional list of lists easily?

I have searched and found these questions: How to create a multi-dimensional list and N dimensional array in python which hint toward what I am looking for, but

How to determine if one array contains all elements of another array in Swift?

I have 2 arrays: var list:Array<Int> = [1,2,3,4,5] var findList:Array<Int> = [1,3,5] I want to determine if list Array contains all findList elem

Given sorted Array, Returns index i if array A contains an element A[i] such that A[i] = i (recursive and divide and conquer)

So i have homework to make a recursive method that uses a divide and conquer algorithm to search a sorted array and check if A[i] == i (if value matches current

JS group by month of date values (objects) in an array

My array is like this: myArray = [ {date: "2017-01-01", num: "2"} {date: "2017-01-02", num: "3"} {date: "2017-02-04", num: "6"} {date: "2017-02-05", nu

Upsample and Interpolate a NumPy Array

I have an array, something like: array = np.arange(0,4,1).reshape(2,2) > [[0 1 2 3]] I want to both upsample this array as well as interpolate the re

Trying to understand Abstract class inheritance and subclass object comparison

I'm working on a project for my data structures class and I've been having a hard time wrapping my head around Abstract class inheritance and how it can be mani