12,135 questions
1
vote
2
answers
111
views
How to sort a set based on another paired set in Java? [closed]
I have two ordered sets (insertion order matters & I need to ignore duplicates, so LinkedHashSet) where the nth item in one set is paired with the nth item in the other set. But they aren't added ...
-5
votes
1
answer
216
views
Why is linear iteration (using any()) significantly slower for Python set than list?
Background:
I am comparing the performance of any() when used on a list versus a set for finding a known element. My initial assumption was that since any() short-circuits, the performance would be ...
Advice
0
votes
6
replies
115
views
Finding substrings from the string using sets: algorithm's logic
I was solving the algorithm problem: find all unique substrings from the string, using sets.
Here is the model solution, but I can't understand what line 6 means. Why does the end go up to length + 1? ...
1
vote
0
answers
36
views
Extracting unique values from multiple sets [duplicate]
I have 3 sets:
alice = {'first_kill', 'level_10', 'treasure_hunter', 'speed_demon'}
bob = {'first_kill', 'level_10', 'boss_slayer', 'collector'}
charlie = {'level_10', 'treasure_hunter', 'boss_slayer',...
Best practices
0
votes
6
replies
30
views
Nested Sets: which languages support this?
What functional or mixed functional programming languages support nested sets, akin to the usage in mathematics and set theory? Specifically those with a REPL?
I tried Python and couldn't get nested ...
4
votes
6
answers
569
views
Is there a more succinct way to convert a String to a Set of Characters in Java?
I want to create an unmodifiable set of specific characters, and for clarity, I want to initialize that Set with a String. Right now I can do it like this:
static {
final String hexCharacters = &...
Advice
0
votes
5
replies
100
views
How to separate variables on each line in a batch SET statement?
I have some data fields gathered in a SET statement like this:
set "datastr=%num_cde%, %id_achat%, %modele%, %sysfam%, %serial%, %ldt%"
later assigned to an email body as:
SET "...
1
vote
1
answer
131
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
187
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
290
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
190
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
123
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
71
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
218
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
77
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
115
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
298
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
62
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
175
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
148
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
49
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
63
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
170
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
147
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
68
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
126
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
123
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
73
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
107
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
972
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
61
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
91
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
218
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
41
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
340
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
135
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
206
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
95
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
76
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
243
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
50
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
80
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
101
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
119
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
233
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
73
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
215
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
89
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.&...