418,170 questions
0
votes
0
answers
14
views
Trouble accessing a single element of an array in Powershell
I am attempting to use a single element of an array, when creating a string message, but it is using both elements, concatenated by a space, whether I use $myArray[0] or $myArray[1]...
# Multiple ...
Best practices
0
votes
1
replies
22
views
C memory initialization for a char** after a malloc
I've been researching this for a day and I've found a lot of conflicting information on multiple websites. I'm writing a simple test that will allocate and initialize a char** (array of strings, char*...
-4
votes
2
answers
96
views
Draw a diamond pattern, representing the top face of a cube [closed]
I am trying to produce a multi-colored cube in perspective, a Minecraft logo, on an HTML canvas.
This is part of my code for producing the top face of that cube:
for (let i = 0; i < 16; ++i) {
...
-2
votes
0
answers
82
views
How to properly include other .cpp files into my main project? [duplicate]
I have this part of my code where I have an array and want to compare it with other constant arrays, to find a match. As I am working with Multi-dimensional arrays, I decided to store these constants ...
-3
votes
0
answers
47
views
How do I code a binary search involving two arrays of words? [closed]
I have two arrays (one going from 0-49 listing every US state, and another one going from 0-49 listing the US capitals.) and I need to binary search the second array to match a selected US state to ...
4
votes
2
answers
132
views
Error with creating an array of named/predefined string constants in c
For background, I am working to create a version of minesweeper that runs in the terminal to become more familiar with coding bigger projects in c.
I am coding in VScode, to run on a Linux server (...
1
vote
1
answer
51
views
What is the correct NumPy representation of a row vector for gradients
I am doing an assignment on matrices and gradients, where the final answer must be expressed as a row vector.
vr = np.array([1, 2, 3])
vrr = np.array([[1, 2, 3]])
Mathematically, a row vector should ...
Advice
0
votes
1
replies
63
views
How to recursive loop json with relationship and convert to object?
I have this json data which I need to convert into an object. The json has a parent/child relationship instead of actual children object in the parent object.
{
"queryType": "tree&...
0
votes
2
answers
123
views
Parse JSON object in SQL with list
I have a table with data structured like this. Each product ID has a list of element IDs--for each element, there is a dictionary including a list of elements and their assigned IDs. Not every element ...
Best practices
0
votes
5
replies
91
views
Option Array, locating and returning array with correct criteria
I have an object db that has one field containing SKU's that correspond to another object that contains different venues.
db.SKU = [1002,1005,1001,1008,1007];
I then have another object listing the ...
Advice
0
votes
1
replies
58
views
How can I achieve the same search behaviour as in iOS 26 Wallet app?
So in iOS 26, the search field changed a bit where it can be at the bottom. While other apps have the search in the nav bar, wallet has it in the toolbar, so when it's pressed it changes to a ...
4
votes
2
answers
77
views
Set a limit/cap on how many children can be appended with appendChild()?
I have a search function on my site that takes a text input and searches "documents" for a matching string of text, then displays the matching items in a list. This works perfectly. I just ...
-8
votes
0
answers
113
views
I need to create an array that contains the values of the attributes of an object, but Object.values(obj) does not work [closed]
I need to create an arraylist, that contains an array of objects to act as the rows of a table, like this:
ArrayList<Object[]> rows = new ArrayList<>();
each of these Object[] arrays will ...
0
votes
1
answer
83
views
CKQueryOperation parse Array from public database [closed]
The operation:
operation.recordMatchedBlock = {recordID, result in
switch result {
case .success(let record):
print("RecordID: \(recordID), record: \(record)")
let ...
1
vote
1
answer
53
views
Copy and paste with .getValues / .setValues, but clearing the array inbetween
I have a table which looks like this:
I want to copy the first two columns of data and insert them before the EOF, but empty them before the paste. The end result should look like this:
So far, my ...
-7
votes
0
answers
120
views
Array of pointer to objects [closed]
I'm using C#. I have a certain number of Newtonsoft.Json.Linq.JArray, let's say A1, A2, A3, and so on.
I need to create an array or something similar of this objects in a way that, if I do something ...
1
vote
0
answers
68
views
Inserting into text array column when using unnest() [duplicate]
I have a table with the follow definition:
CREATE TABLE "test" (
id UUID PRIMARY KEY,
created TIMESTAMPTZ NOT NULL,
description TEXT,
permissions TEXT[]
);
I want to bulk ...
5
votes
0
answers
206
views
Why is my user-defined contiguous 2D array not dramatically faster than std::vector<std::vector<>>?
I implemented a simple 2D array wrapper using a single contiguous std::vector and, benchmarked it against std::vector<std::vector<>>.
Surprisingly, array2d is just slightly faster!
#...
0
votes
1
answer
105
views
How to remove duplicate rows based on array column subset relationship?
I have a DolphinDB table with an array vector column. I need to remove duplicate rows based on subset relationships within that column.
Sample Input:
sym
prices
a
[3,4,5,6]
a
[3,4,5]
a
[2,4,5,6]
a
[5,...
1
vote
1
answer
82
views
Pre-Selecting Values for a MultiDatePicker
Premise
I have a MultiDatePicker bounded to a closed range of the current month. In addition, I have a datePicker representing a "Start Date" that is the current day. I want the Day of the ...
1
vote
2
answers
74
views
How do I use a json array to search and extract matched values from a different json array in mariaDB?
Situation
I have two tables. ing_master is a master list of ingredients; pdet is a product table, with an ingredients field formatted as json array.
For each product's ingredient list in pdet, I want ...
Tooling
0
votes
4
replies
107
views
Compare unordered lists / objects javascript
I would like to compare unordered lists / objects with an indeterminate depth in javascript like:
const t = {
key: [
{
subKey: [
{
subSubKeyOne: 1,
subSubKeyTwo:...
-7
votes
1
answer
173
views
How should I efficiently add all pairs in a key-value array to an object?
I have an object obj; and I then obtain an array arr of key-value pairs. Assuming that the key sets of obj and of arr are disjoint (i.e. no key appears in both) - how do I efficiently add all pairs in ...
-6
votes
0
answers
150
views
How to bubble sort an array stored inside a class? [closed]
I have a simple class that contains a fixed size int array.
The class can initialize the array, shuffle it, and print it:
#include <iostream>
#include <algorithm>
#include <random>
...
3
votes
2
answers
117
views
Code is returning "[C Kernel] Executable exited with code -11", don't know what's wrong with it?
I'm working on this piece of code as part of my coursework, ideally any advice I get for this would be educational in some way; I don't want an exact answer, just need someone who knows more than I do ...
4
votes
4
answers
118
views
Map unknown associative array element
How can I map an unknown value alongside other known values in bash using an associative array, so that:
#!/bin/bash
array=("foo" "foo" "bar" "something else" &...
3
votes
2
answers
63
views
I'm getting an 'index out of bounds' error using solve_ivp
I'm trying to find the outbreak time (when the number of zombies >= number of humans) as a function of the zombification rate gamma, using the following code:
arrOutbreakT = []
arrGamma = np....
-5
votes
2
answers
136
views
Text file with JSON data became corrupted
This is my code
$serverGuestFile = fopen($_SERVER['DOCUMENT_ROOT'] . '/server/guest.txt', "r");
$serverGuestFileData = fread($serverGuestFile,filesize($_SERVER['DOCUMENT_ROOT'] . '/server/...
-1
votes
0
answers
43
views
How to get foreach from file get contents php array url [duplicate]
I created a php array file.
My PHP Array File Example.
I put array to g.horje.com/t.php
<?php
$val = array (
0 =>
array (
0 => '1',
'id' => '1',
1 => 'Search Engine ...
Advice
0
votes
3
replies
100
views
Java : getting sorted order of Objects
I have an List of Objects that implements the Comparable Interface that I want to sort. I do not want the original List returned sorted, nor do I want an new List returned in sorted order. What I ...
Advice
0
votes
5
replies
88
views
How to assign unique elements to different indices?
I've been working on a program that prints out each word, their number of occurrence's and percentage of the number occurrences over total length of the sentence.
As you can imagine I had to create a ...
Advice
2
votes
3
replies
119
views
How do you use set() on PHP arrays?
When using setters/getters on arrays, does your set() override the entire array or just the key? What is the accepted or best practice for this?
Would you use set() for something like this or would ...
1
vote
1
answer
138
views
Why can't I return type byte in lambda expression in Arrays.setAll
I'm trying to implement a lambda function (for educational purposes) to initiate an array to append to the front of potentially encrypted data to save information like salt and initiation vector, ...
0
votes
2
answers
160
views
Updating stateful list in React based on another stateful variable
Here are two React components:
function MainScreen() {
const [stopwatches, setStopwatches] = useState([
new Stopwatch('A'),
new Stopwatch('B')
]);
const [selectedStopwatchIndex, ...
1
vote
1
answer
69
views
Array Reverse Proof by Dafny
Regarding the array reversal problem, I guess loop invariants are logically correct, based on the symmetry of the elements in the array and their relationship after reversal.
However, I don’t ...
1
vote
2
answers
67
views
How can I loop over an XML structure using Coldfusion
I'm trying to loop over an XML file and output the structure. However, I'm only getting one set of data on the second loop. Below is my code, and below that is a snippet of the XML structure.
<...
Advice
1
vote
14
replies
249
views
Ordered array vs. hash map in c++ (100 elements)
I need help regarding a code I want to write in c++.
I want to develop a program that receives and visualizes CAN messages on a GUI. The messages in question are about 100 distinct ID's, so we're not ...
4
votes
3
answers
175
views
Why does my C code display the correct output, but with garbage characters added after?
The practice question I am working on reads as:
Read two strings, both of them do not contain white spaces (but may contain non-alphanumeric, such as ‘,’, ‘.’, ‘/’ ...).
Display the first string ...
-2
votes
2
answers
198
views
What am I doing wrong with my SAFEARRAYs? [duplicate]
I'm setting my first steps in COM communication. I have an application, written in C#, using a byte array, and that is working fine.
When I try to do the exact same thing in C++, it does not work.
I ...
1
vote
1
answer
69
views
query an array to a R {plumber2} API
The {plumber2} R package recently got released and I'm trying to understand how to leverage an API.
This basic example below works as long as I'm passing only one string without comma in my query.
#* ...
0
votes
0
answers
118
views
ClassCastException when comparing elements in custom ArrayOrderedList using Comparator
I am implementing an ordered list that automatically inserts elements in the correct sorted position using a Comparator. The list is built from scratch (not using java.util.ArrayList) and uses an ...
Advice
1
vote
9
replies
201
views
Is this array subscripting behavior really undefined in C?
unsigned int n = 1;
char* s = "X" + 1;
s[-n];
Is that third statement undefined in C23? It seems it is, as by the standard in 6.5.2.1.2:
... The definition of the subscript operator [] is ...
-5
votes
1
answer
137
views
Why is this C++ program giving a "Segmentation Error" on line 84? [closed]
I'm doing an assignment for an engineering course I'm taking, and I'm testing my code as I go along. For some reason, it gives an error when I compare an array element to a value passed into my ...
2
votes
1
answer
66
views
Edit Array issue with array of enums in Dymola
When editing an array of enumeration with unknown size in Dymola (2025x r1), it is possible for the user to set a value to the array which is not a vector:
type Catalogue = enumeration(A "A",...
Advice
1
vote
4
replies
97
views
Acyclic shifting of arrays (`eoshift`) in Julia
Circular shifting cshift in fortran as an equivalent in Julia : circshift. But I'am seeking an equivalent of eoshift (https://fortranwiki.org/fortran/show/eoshift) which is a acyclic shifting that ...
2
votes
2
answers
187
views
how to get PowerShell to gracefully accept a multi line, array, system.object input to a `[string]` parameter?
ff
I have a function foo, it needs to accept a string, this string can be passed to it directly by typing at the terminal, from a variable or from the clipboard.
function foo{
[CmdletBinding()]
...
1
vote
2
answers
182
views
How to set int array pointer within for loop in c
The following code is trying to set the test array in the first for loop, but it can't be used in the second for loop.
int main()
{
int *test[3];
/** Try to set the array value one by ...
0
votes
0
answers
27
views
How Can I Use String of Coordinates Within a Mapbox Feature?
I am trying to fetch a comma separated list of coordinates from a database and then show them on a Mapbox GL JS map.
By using the following FeatureCollection, I am able to show a Line between ...
0
votes
1
answer
47
views
Why does the use of "enlist" in the cross-sectional engine sometimes result in errors and sometimes work normally?
I am using the cross-sectional engine and need to store multiple rows of fields as a single array vector. However, I have encountered several issues during the process:
The scenarios I attempted are ...
3
votes
1
answer
148
views
How to convert a string in an array to variable using the array index in PHP [duplicate]
Let's say I have an array_1 containing a string which is a name of another array_2. And now I would like to convert the array index into a variable containing the array_2.
I have the following working ...