All Questions
Tagged with swift-array or arrays
418,168 questions
0
votes
1
answer
89
views
How to use strtok to separate into tokens and append to an array [closed]
I am working on a function where I will be recieving data from an SPI communication and then get the date/month/year from them
I have created a function to do the latter
void set_file_header(const ...
1
vote
1
answer
40
views
Index array without assigning it to parameter
I have to split a string and use a part of it for further processing. So the idea is:
string='aaa-bbb-ccc-ddd'
parts=(${(@s:-:)string})
print -- $parts[3]
# ccc
I would like to refactor the second ...
2
votes
2
answers
81
views
My Swift for in loop is not stopping when I call an await function
I have a for in loop in my ViewModel that I want to process elements in an array one at a time, and if the API result from each element has a count of 1, then continue to the next element in the array,...
0
votes
1
answer
78
views
Why does my rotation (up / down) break when I rotate 90 degrees left or right, and how do I fix it?
I'm trying to make a simple 3d renderer in CMU Graphics using rotation matrices. When I rotate the camera 90 degrees (left or right), and I try rotating (up / down), it does a "barrel roll" ...
-6
votes
0
answers
59
views
How to compare array's element each and char by char in assembly lang 8086 [closed]
.model small
.stack 100h
.data
;menu
IDS dw "anmol","jia12","chaht", "nida1$"
passwords db 0000h,0001h,0002h,0003h,0004h
start_msg db "Welcome to ACJN ...
Advice
1
vote
12
replies
132
views
How can I combine two or more arrays into a unique set without changing the data type in Powershell?
Say I have a combination of the following:
# This is a [string[]] type
$A = [string[]]@("Aasdf","Casdf","Basdfs")
# This is a [string] type
$B = "Dasdfs"
# This ...
Advice
1
vote
5
replies
100
views
CUDA C: How to keep an entire, somewhat complex calculcation on the GPU w/o bringing intermediate results back to host
So I'm trying to learn CUDA C. I had an idea for a simple code that could calculate the simple average of a float array. The idea is that main() will call a host function get_average(), which will ...
-2
votes
0
answers
44
views
jquery array returns empty result [duplicate]
I have the following which creates an array (of sorts!):
var combined = [];
function slides(){
$.ajax({
type: "GET",
url: '../queries/get_all_slides.php',
cache: false,
dataType: &...
0
votes
3
answers
76
views
Convert JSON file to CSV using jq, expanding nested array data in multiple columns
I need to convert a JSON file to CSV in a bash script, this a sample file:
{
"total": 1,
"jobs": [
{
"deviceData": {
"deviceId": "...
-1
votes
0
answers
28
views
How do I set indepenedent height/width in collection view item
I want to make the collection view pills like the first screenshot but the moment i scale height up the width also scales up with it, i want small height and more width kind of resembling the fatso ...
Best practices
2
votes
3
replies
82
views
Create mask from array based on threshold
I have an array and I want to create a mask for this array based on a threshold, sorry if the explanation is a bit convoluted.
The first step is to find the intervals of elements higher than half of ...
-1
votes
0
answers
79
views
Excel dynamic arrays not able to be multiplied together [closed]
I have two arrays that won't multiply together, I just get a single zero. I would expect the result to be an array.
Is there some behaviour of dynamic arrays that I don't understand here? The arrays ...
4
votes
3
answers
155
views
C# 12 - How do I make sense of this behavior? Passing an array of non-nullable reference type to a parameter expecting nullable reference type array
I am on a quest to understand the nullable reference type system in C# (well, I guess the non-nullable reference types are the unique part). The mechanics of this particular situation are totally lost ...
4
votes
2
answers
114
views
Trouble accessing a single element of an array in Powershell [duplicate]
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
1
vote
12
replies
169
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*...
-2
votes
2
answers
133
views
Draw a diamond pattern, representing the top face of a cube
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) {
...
-3
votes
0
answers
108
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 ...
4
votes
2
answers
146
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
58
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
68
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
140
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
102
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
94
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
79
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 ...
0
votes
1
answer
84
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
54
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 ...
1
vote
0
answers
69
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
223
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
114
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
85
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
90
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
113
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
179
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 ...
3
votes
2
answers
120
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
130
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
68
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
139
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
44
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
103
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
4
replies
94
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
120
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
146
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
170
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
75
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
70
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
257
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
177
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 ...
1
vote
1
answer
70
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
119
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
205
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 ...