Category "arrays"

Parse CSV records in to an array of objects in JavaScript

I'm new to JS and not much exp in Regex to play with string manipulation. Here is my CSV file with records in tabular form with the first line as headers and

Sum array values of a column within each column of an array with 3 levels

I'm trying to use array_sum() on columns within columns of a multidimensional array. For eg: I have an array that looks like this: $array = [ [['value' =>

How to reverse SwiftUI ZStack order?

trying to recreate a next/previous item on a stack of cards. I have my cards in a ZStack. The problem I’m having is that by default ZStack are in reverse

Generate array from 0 to N with custom increment in Javascript

Problem Description I am trying to generate an array using keys() and .map() methods, given a preexisting array with length = arrLength, such that only items at

How to remove from a multidimensional array all duplicate elements including the original?

I am using php 7.1. I have seen that to eliminate the duplicate elements it is enough with this array_unique($array, SORT_REGULAR); I've also seen this work ar

How do I set multiple values in a Javascript Map at once?

I have a simple chain of logic here, where bigCities is a Javascript Map. In this example, d represents each object in an array of data read in from a csv file.

Write a recursive method called which takes in an array of integers and returns said array in reversed sorted order

I have a programming exam in a few days so I'm doing some exercises just to practice. However, I've been stuck with this problem and I started to doubt if it's

Expected to return a value in arrow; function array-callback-return. Why?

I'm having some issues understanding why I'm getting a compile warning on this piece of my react code fetch('/users') .then(res => res.json())

Find index of numbers from a string in Javascript

I would like to get the index of numbers ( 1994 and 27 ) in the string bellow i tried to split the string but no idea what to do after that let str = 'year o

The loop over two arrays take LONG

Thanks for your helps, I have two arrays: A (100k row, 10 col) and B (100k row, 12 col) The following code (thanks to BSALV) loop through A and B => It takes

update objects in array with useState (reactJS)

Go to the end of this question for the solution that worked for me! i'm currently making my own chess game and i want to check if a position already occurred 3

Numpy array of tuples to PIL image

I currently have a numpy array or RBG tuples that I want to convert to a PIL image and save. Currently I'm doing the following: final = Image.fromarray(im_arr,

How to add a comma in array.map after every element except last element in React JSX

How can I add a trailing comma after every element of an array for making a list like: INV, INV, INV, INV Note that the last element doesn't have a trailing c

Merge JavaScript objects in array with same key

What is the best way to merge array contents from JavaScript objects sharing a key in common? How can array in the example below be reorganized into output? Her

Merging 4 sorted Arrays into one

I have this method to merge 2 sorted arrays into one sorted array: public void merge(T[] a, int l1, int r1, T[] b, int l2, int r2, T[] c, int l3) {

Inserting array values

How do I write and execute a query which inserts array values using libpqxx? INSERT INTO exampleTable(exampleArray[3]) VALUES('{1, 2, 3}'); This example code

Copying Character array into char array

Hi I want to fast copy array of Characters to array of chars I can write a method that copies Character array into char array, by converting every Charater in a

numpy arange: how to make "precise" array of floats?

In short, the problem I encounter is this: aa = np.arange(-1., 0.001, 0.01) aa[-1] Out[16]: 8.8817841970012523e-16 In reality, this cause a series problem si

Date showing as serial number in formula

I'm currently having an issue with the date format. I have basically extracted the month and year from a standard dd/mm/yyyy date and wish this to be formatted

Javascript twoSum algorithm: Given an array of integers, return indices of the two numbers such that they add up to a specific target

Given an array of integers, return indices of the two numbers such that they add up to a specific target. Example: Given nums = [3, 2, 4], target = 6, Because