Questions tagged [array-comparison]
15 questions
2
votes
1 answer
Compare two arrays in PostgreSQL
I have a table in postgres with a value column that contains string arrays. My objective is to find all arrays that contain any of the following strings: {'cat', 'dog'}
id value
1 {'dog', 'cat', 'fish'}
2 {'elephant', 'mouse'}
3 {'lizard',…

iskandarblue
- 7,208
- 15
- 60
- 130
1
vote
0 answers
Exact and case insensitive array comparision in mongoose
Suppose, below is the features array already exist in my database records:
const features = [
'Multiple Admin Users',
'Distribute Units',
'Unit Reports',
'Track Single Unit',
'Commercial Usage',
'Multiple Locations'
];
Below is the…

Drashti Kheni
- 1,065
- 9
- 23
1
vote
1 answer
How to compare arrays in GROQ
I have a blog with sanity CMS and I want to request related posts depending on corresponding tags from the current post which means I have to compare two arrays of tags.
My tags are described in post schema this way:
{
name: 'tags',
title:…

Quentin C
- 307
- 3
- 13
0
votes
1 answer
Find item that changed its position in array
I have an array that represents html items that can be dragged and therefore the order can be changed. Let's say before drag'n'drop event there is an array:
let oldArr =
[{id: 'id1'}, {id: 'id2'}, {id: 'id3'}, {id: 'id4'}, {id: 'id5'}, {id:…

Axel Stone
- 1,521
- 4
- 23
- 43
0
votes
0 answers
How to compare two numpy nd arrays of different shapes element wise
I am learning the code that differentiates between spam and non-spam emails. I have done the part of the training data. When dealing with the testing of the data, I had to compare the prediction and test data arrays, I ran into an error, so I built…

Haseeb Ahmad
- 1
- 1
0
votes
2 answers
Creating a list of an object which either does or doesn't exist in another different object list - C#
So I am trying to compare two different lists that both contain differently structured objects. One is easily accessible while the other is very nested in arrays, but sadly, these are responses from API calls so it's not a structure I can change to…

Evelin Ramos
- 11
- 4
0
votes
2 answers
String[] Array variable comparison
I am writing a code that vaguely simulates a poker game, which at this point should output a "Players Hand", an "Opponents Hand" and a "Flop".
Each card should only appear once (that means no identical cards should be given out).
I tried to…

Ma Wi
- 1
- 1
0
votes
0 answers
How to find any common number exists between 2 dynamic values - PHP
From my database my code fetch (dynamic) two values (varChar) from 2 tables and I want to find is there at least one common number between the 2 values. If at least one number is common, my code will fetch rows and display the rows values (while…
0
votes
1 answer
Comparing Two Arrays in Javascript to Find Identical Similarities and Other Similarities
I have two arrays in Javascript: code and submittedCode. I am trying to compare the two arrays. Each of the arrays is 4 integers long, and each integer is a random value of 1 to 6. I also have two variables: red and white. When the two are compared,…

tb_03
- 61
- 10
0
votes
1 answer
Unexpected results with array_uintersect_assoc() when callback returns non-numeric string
I am calling array_uintersect_assoc() with a callback function of strpbrk() to demonstrate a point about how different return values are evaluated based on type.
Given an associative array of haystacks like:
[
'one' => '0',
'two' => '1',
…

mickmackusa
- 43,625
- 12
- 83
- 136
0
votes
0 answers
What is the reason for do in=false in the below script
I am doing bash and I was looking at a problem for array comparison and this was the solution below. I was wondering why they have the do in=false
#!/bin/bash
# enter your array comparison code here
# initialize arrays a b c
a=(3 5 8 10 6)
b=(6 5 4…

JEllis
- 1
- 2
0
votes
1 answer
Analysing two arrays for mastermind game
My main default is the logic for the analysis. What is demanded.
The processing algorithm in the analysis function is the main interest of the exercise.
I need to compare the player proposition called essai[] and the ref[]. The ref[] is a 4-digit…

MimiValsi
- 11
- 2
0
votes
0 answers
Compare two items of the same array in JavaScript
I'm using react for this code. For a time now I been searching for how to do this, I have a array of arrays, and I need to compare if the beginning of the array is equal to beginning of the other array, then get all the next values of both arrays e…
-1
votes
1 answer
How to test if nested arrays are equal to each other
I have a maze generator that generates walls per "cell". This means that there are duplicate walls - e.g. the left wall of one cell is exactly the same as the right wall of the cell to the left. I want to generate a maze and extract the data to a…

Eli Bauer
- 29
- 5
-2
votes
1 answer
How to get the difference between two arrays in JavaScript with repeating values
How can I check to see if one array is contained in another and return the missing values? I have found ways to do this in this post but none account for repeating values in the arrays. For example, I am trying to do something like this:
getDiff([1,…

JasonFitz
- 183
- 1
- 11