Category "arrays"

Javascript - Remove duplicate ID from array of objects

Take the following two arrays: const array1 = [ { props: { type : 'text', id : 'item1', name : 'item1', value : '@item1@', },

How to replace item in array?

Each item of this array is some number: var items = Array(523,3452,334,31, ...5346); How to replace some item with a new one? For example, we want to replace 3

Converting an int[] to byte[] in C#

I know how to do this the long way: by creating a byte array of the necessary size and using a for-loop to cast every element from the int array. I was wonde

Create a new line whenever an array value reaches more than 10 characters

Here is my code, but it isn't dynamic. What I need is it will automatically create new line if array value is greater than 10. <?php $limit = 10; $newline =

array_map triple dimensional array [duplicate]

How do I run a array_map on a triple dimensional array? Where I want to "clear" the innermost array? It looks like this: Array ( [1] =&g

How to filter related models (hasMany relation) using where in LoopBack 3

Customer hasMany relationship with jobs Filtering by the top-level property works as shown below Customer.find({ include: ["jobs"],where :{username:"mel"} },

PHP array_filter with arguments

I have the following code: function lower_than_10($i) { return ($i < 10); } that I can use to filter an array like this: $arr = array(7, 8, 9, 10, 11

Check if string contains a value in array [duplicate]

I am trying to detect whether a string contains at least one URL that is stored in an array. Here is my array: $owned_urls = array('website1

Apply a function to three parallel array of arrays

I have three arrays of arrays like this: catLabels = [catA, catB, catC] binaryLabels = [binA, binB, binC] trueLabels = [] trueLabels.extend(repeat(y_true_cat

What is the most efficient way to concatenate N arrays?

What is the most efficient way to concatenate N arrays of objects in JavaScript? The arrays are mutable, and the result can be stored in one of the input array

Can numpy bincount work with 2D arrays?

I am seeing behaviour with numpy bincount that I cannot make sense of. I want to bin the values in a 2D array in a row-wise manner and see the behaviour below.

Can PostgreSQL array be optimized for join?

I see that PostgreSQL array is good for performance if the array's element is the data itself, e.g., tag http://shon.github.io/2015/12/21/postgres_array_perform

How to merge two arrays in Java?

Its not to concatenate but to merge two arrays so that they become array of name value pairs. firstarray = ["a","aa","aaa"] secondarray = ["b","bb","bbb"] resu

Yii model to array?

How can I convert the result of Trips::model()->findAll() to an array?

Comma separated list from array with "and" before last element

I have an array ($number_list) that has a dynamically generated list of values. There will be at least 1 value in the array and no more than 4. Currently, I ha

Powershell: Two dimension arrays

The following works as expected: $values = @( ("a", "b"), ("c", "d") ) foreach($value in $values) { write-host "Value 0 =" $value[0] write-host "Value 1 ="

How can I generate a "Social Golfer" matrix for worker seating arrangement?

EDIT: I am looking for an APL function, or MS Access VBA function, which takes as arguments the total number of employees, total number of dinning tables, and n

For loop to average over individual time points Matlab

I have a 21x2 vector in Matlab that looks like this: A = [0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5; 0 0 0

Multidimensional Array zip array in scala

I have two array like: val one = Array(1, 2, 3, 4) val two = Array(4, 5, 6, 7) var three = one zip two map{case(a, b) => a * b} It's ok. But I have a multid

How do I iterate an array of JSON data to always get the first JSON object

I'm trying to get the first JSON object from the video array, I only want to get full highlights and not the goals. { "response": [ { title: "United