12,134 questions
1
vote
1
answer
92
views
What is the difference between session_authorization and set role
In Postgres, you can set current_user by:
set session_authorization = 'new_user';
and
set role 'new_user';
While I like the shorter syntax, I'm asking if there is a difference in functionality ...
0
votes
4
answers
179
views
How to create objects from sets?
How can I create objects from a Set?
const dupObj = [{ id: 1, value: 'a' }, { id: 2, value: 'b' }, { id: 1, value: 'c' }];
const uniKeys = [...(new Set(dupObj.map(({ id }) => id)))];
// [ '1', '2' ]...
3
votes
2
answers
279
views
Is iteration order of a set in Python preserved until that set is modified?
According to the Python documentation, set is a mutable unordered collection.
Usually, it's implemented as a hash table that stores references to objects as its keys. Comparing to dict (which is also ...
8
votes
3
answers
1k
views
How can I create an array of arrays of strings of varying lengths in C?
I am trying to solve the problem posed in this question. Here the OP asks that given a 15 element set, its 2^15 element power set be generated in a manner such that the elements of the power set are ...
4
votes
2
answers
182
views
Combination generator written in C : works for big n but for small n when n=0 or n=k crashes saying "segmentation fault"
Let's say I have a box and there is a bunch of balls in that box. I can label each ball with a character while making sure no two balls get the same character as labels. I get a string this way. Let's ...
0
votes
3
answers
94
views
How Do Sets and Set Comparisons Work in Python? [duplicate]
I'm learning Python coming from some beginner-level experience with Java. It all makes sense for the most part, but one of the exercises kind of made me wonder what actually happens within Python.
...
0
votes
2
answers
59
views
How can I add elements to an existing Set in GAMSPy?
I'm working with the GAMSPy Python API and using Set objects to define sets in a GAMS model. I can define a set like this:
from gamspy import Container, Set
m = Container()
regions = Set(m, name=&...
2
votes
3
answers
207
views
Writing a Von Neumann Ordinal generator in C : Problem with malloc
I want to write a computer programme that will do the following things :
1a. It will make an array 3 characters long.
£££
2a. It will then initialize the array with the string "{_}" and ...
1
vote
2
answers
75
views
A dead loop problem in JavaScript about Set
Why the following code caused dead loop?
const s = new Set([1]);
s.forEach(e => {
s.delete(e)
s.add(e)
})
I tried to change the order about delete and add operation,the dead loop ...
0
votes
2
answers
107
views
Would python function any() iterate or just locate the item if used with a hashset
to clarify, it would be used like any(set()). I am asking for efficiency sake.
Example: if any(fnmatch(a,b) for a in set)
where a would be an item in a set and b would be a string.
5
votes
3
answers
289
views
Fastest way to find the least amount of subsets that sum up to the total set in Python
Say I have a dictionary of sets like this:
d = {'a': {1,2,8}, 'b': {3,1,2,6}, 'c': {0,4,1,2}, 'd': {9}, 'e': {2,5},
'f': {4,8}, 'g': {0,9}, 'h': {7,2,3}, 'i': {5,6,3}, 'j': {4,6,8}}
Each set ...
0
votes
1
answer
55
views
Alternative for ajax with async true too slow
I have a serious problem with an app.
I have a selection box with types of services and other below with student names. Once selected the service, the students will be filtered to the ones that are ...
0
votes
0
answers
56
views
Delphi Extending a set with custom values [duplicate]
I'm looking for a way to extend the tFieldType with my own custom types.
I've tried
type
pSetExtendedFieldTypes = (ftAlpha, ftAlphaNumeric, ftNumeric);
pSetNativeFieldTypes = tFieldType;
pSetDataTypes ...
0
votes
1
answer
142
views
Why does 'set /a counter=counter+1' work without using %% in a batch script?
in this code I think I have to write set /a counter=%counter%+1 but I just tried write it without %% and interestingly it works I don't how?! can anyone explain it
@echo off
setlocal ...
2
votes
3
answers
141
views
How to use output iterators without a container: Set intersection without storage
The C++ reference has this example for printing the intersection of two sets (or sorted containers):
#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector&...
-1
votes
1
answer
47
views
Error setting sublist value Netsuite client script
I am trying to set sublist value on suietelet in a client script.
Getting error as:
cannot read properties of undefined reading 0.
Please advise Thank You!
Below is client script sample.
function ...
1
vote
1
answer
58
views
Automation error due to 1000+ workbooks opened and closed
Me and my colleagues have created around 14.000 copies of a certain workbook in the last 8 years or so. Pretty simple lightweight workbook, few userforms, some code, 2 sheets with a variable amount of ...
2
votes
4
answers
158
views
Getting a mutable element from a std::set, for operations that won't break the order
I've got a data type that consists of actual data and an id:
struct Data {
int value;
int DataId;
};
I've got a collection of these data from which I have to frequently get an element based ...
2
votes
1
answer
139
views
How to create set with values 1, 0, True, False along with other values in the same set
I am trying to create a set having different values along with True, False, 1, 0.
I am aware that Python treats 1 as True and 0 as False. Imperatively, since the set keeps only the unique values, my ...
0
votes
0
answers
66
views
Tracking Unique Transactions
For my application, I need to track the number of duplicate transactions. Transactions are represented by a struct.
type Transaction struct {
items map[string]int
date int
}
The struct ...
2
votes
2
answers
113
views
Apply std::set_difference to the keys of two std::maps which each have differing value-types
I have two maps. One (A) is maps unique identifiers to allocated resources. The other (B) maps unique identifiers to resource prototypes. I would like to take the two maps and find the items that are ...
-5
votes
1
answer
120
views
Declarations of list or nested lists
What is this declaration?
lists are declared using [ but these contain key-value pairs as seen with the use of {}. It's confusing. list with {} brackets with a pair of two items forming one.
players = ...
1
vote
1
answer
69
views
How to model an intermediate container node in OWL (Protégé)?
I'm designing an ontology for app users in Protégé, and I need advice on how to properly model intermediate "container".
Suppose you have an User with multiple contact details (e.g., ...
1
vote
1
answer
101
views
How to interpret a get; set; value when debugging step by step in Visual Studio
I'm debugging a program I'm not at all familiar with in Visual Studio 2022.
I am trying to see the value which goes into the NumeroProjet property.
In order to do this, I have put the set; on a new ...
1
vote
0
answers
693
views
nftables managing sets of ips
I'm building a new server, and thought, its 2025 and probably good time to migrate from iptables, ipset... to nftables. earlier or later it has to happen any way, right?
# uname -a
Linux starnet 6.12....
0
votes
0
answers
56
views
How to dynamically Access `c:set` defined values in JSF Facelets (Primefaces Datatable)?
The value defined by c:set refers to a var (name of the iterator variable used to refer each data), but the column values are not displayed.
How should it be defined to be displayed correctly?
<c:...
-1
votes
2
answers
86
views
Batch script: SET command behaves differently for the similar code piece [duplicate]
I have been using batch for a while but not an expert of it.
I recently wrote a piece of code to do the following thing:
Get a date input from the command line. If its format is like 20200102, it is ...
-1
votes
2
answers
155
views
C++ How to insert (and override if necessary) an item in std::set with a single traversal and no rearrangement of the underlying tree
You can insert an item into std::set but if there already exists an equivalent item, it won't override. You can also first remove the equivalent item from std::set and then insert the item you want to ...
0
votes
0
answers
40
views
C++ set with user defined type and custom compare [duplicate]
I have a class like this
class Point {
private:
int x;
int y;
public:
Point() = default;
Point(int x_arg, int y_arg):x(x_arg), y(y_arg) {};
bool operator<(const Point& ...
5
votes
5
answers
326
views
Finding loops between numbers in a list of sets
I marked my answer as the answer because it is the one that is doing what I was wanting and anyone wanting to do the same thing should start there. But I would love to see a better answer (order of ...
4
votes
1
answer
115
views
How many data structures are created when collecting with java parallel stream?
Stream<String> stream = Stream.of("w", "o", "l", "f").parallel();
Set<String> set = stream.collect(TreeSet::new,
Set::add,
Set::...
4
votes
1
answer
177
views
How do I convert a string to a table in Lua?
I have a string like such:
{a="foo", b="bar", c=12345}
(imported & read from a file)
How do I convert this into a table/set with those contents? Or how can I save tables/sets ...
-4
votes
1
answer
92
views
I have a set of words I would like to exclude, and I want to check if each new word entered is contained wholly within another. How would I do this?
So I am currently making a word game, and I want to have it so that the user cannot enter a word that is wholly contained within another word (e.g. 'set' in 'subset'), however my current code:
noWord =...
0
votes
0
answers
70
views
Sequence relations with multisets
I am trying to verify the following lemma in dafny:
ghost predicate noD(s: seq<nat>)
{
forall i :: 0<=i <|s| ==> !(exists j :: 0<=j< |s| && i!=j && s[i]==s[j])
...
3
votes
1
answer
211
views
Android Compose MutableStateFlow: Adding to Set does not invoke recomposition
There are many similar questions about this, but usages have been changing; this is the only question I've found that talks specifically about MutableSets, MutableStateFlows, and collectAsState().
The ...
0
votes
1
answer
48
views
How to efficiently match different versions of grouped elements?
I'm trying to remap primary keys between versioned data and code releases with as small a diff as possible.
I have a list of elements, e.g. [a,b,c,...,j], and some deterministic process that assigns ...
0
votes
0
answers
56
views
Using complex objects as dictionary keys in Python
So I'm working XML files and am not quite sure if what I'm doing is 'Pythonic' enough.
The XML file has tagged text and I want to get all paragraphs that contain countries and rivers. So each ...
-2
votes
1
answer
88
views
Define a object to be unique in a Set, irrespective of order of List elements within the given object
I have a Class B defined as below -->
Class B {
private List<String> obj1;
private List<A> obj2;
// Need to implement hashcode() and equals() methods
}
In my code, I am using ...
0
votes
1
answer
100
views
Determining a combination of selections from a list of sets that would yield the maximum number of unique numbers
Determining a combination of selections from a list of sets that would yield the maximum number of unique numbers
Consider an array of sets, with each set containing an arbitrary number of integers.
A ...
2
votes
3
answers
160
views
Compare sets in a match expression
I want to compare sets in a match expression in Python.
So imagine you want to compare multiple variables but they do not have any order. They only have to include the same values as a whole. In this ...
0
votes
0
answers
72
views
I want to plot a semi-random graph in Matlab
Our sample set is given as {-1,1.5,2,2.5}.
b = from "outcome" value to outcome(index100) value.
There is a problem that outcome(1) cannot be equal to a matrix value. Hence I set "...
3
votes
3
answers
176
views
Set.Has() does not work with arrays because they are mutable. What's the alternative?
I have a list of (lots of) coordinates.
coordinateList = [[1,2], [2,1], [3,5]];
These coordinates are unique and since I have a lot of them I want to be able to quickly check if a new coordinate is ...
-1
votes
1
answer
87
views
set -- arguments with $string and "$string"
Compare $string and "$string":
string="xx yy zz"
if [[ $string == "$string" ]]; then
echo "Strings are equal."
else
echo "Strings are not equal.&...
0
votes
5
answers
155
views
Using 'this' in a getter/setter defined on a class field property. How to define class field getters/setters on child properties?
The issue in question relates to human readability and data organization. I would like to assign getters and setters as children of class field properties, however I can't get this to reference the ...
0
votes
1
answer
90
views
pandas, determine if set value already exists in dataframe
I am checking to see if a tuple of unordered values is already in another list. I am new to Python, and so have not used sets much, but am a heavy pandas user and so was thrilled to find this question ...
0
votes
1
answer
100
views
A hash function that maintains mathematical equality (especially for sets)
I'm working on a little math-based programming language (written in Rust) that uses sets instead of types. In it, a variable or value belongs to a set of values (eg. x : {1, 2, 3} or msg : Str). The ...
1
vote
0
answers
51
views
What is a fast and statistically powerful way of heuristically removing duplicates from a set of (unordered) sets?
I have an application where I (heuristically) create a large set of test candidates, which are themselves large sets of elements in no particular order. In order to not use the same test candidate ...
-1
votes
1
answer
37
views
How to check if an object is a Set in Joi?
how to create a Joi validation to check a Set type? my object does contains a field with a new Set([]) type, but using Joi.array().unique throws an error when validating.
const data = { name: "...
0
votes
0
answers
70
views
Pyomo indexed set into constraint
I'm attempting to add an indexed set to a constraint, and Pyomo returns Cannot apply a Set operator to an indexed Set component (td)
import pyomo.environ as pyo
from pyomo.opt import SolverFactory
td ...
-3
votes
3
answers
2k
views
Remove Duplicates from Sorted Array LeetCode problem
Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative order of the elements should be kept the same. ...