Questions tagged [set]

A set is a collection in which no element is repeated, which may be able to enumerate its elements according to an ordering criterion (an "ordered set") or retain no order (an "unordered set").

Filter by
Sorted by
Tagged with
0 votes
2 answers
69 views

Java Set doesn't store a similar list with same elements but it stores a duplicate for arrays [duplicate]

How does set compare objects in java? I was reading java documentation for equals method for arrays and list and from the documentation it looks similar. Is there a better way to differentiate. This ...
tomday's user avatar
  • 1
1 vote
2 answers
44 views

tcl how to redefine "set" command

I am new comming of tcl. How to use tcl to imitate "set" command? I try to build like below cold, but below code with error: unknown command name: proc my_set {varName {value ""}} {...
JoshTitle's user avatar
-2 votes
0 answers
56 views

Want a data structure storing visited sets. It should allow inserting supersets but not allow subsets of inserted sets [closed]

I want to implement a data structure satisfying the requirement that: I can insert the sets I have visited. It doesn't allow inserting subsets of previously visited sets. It allows inserting ...
Lesterth's user avatar
-1 votes
0 answers
53 views

Strange behavior of sets in python 3.10.2 and 3.11.6 [duplicate]

Screenshots of jupyter lab import sys sys.version '3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)]' I created two sets: set1 = {'a', 'r', 'b', 'c', 'd'} set2 = {'a', ...
seeker's user avatar
  • 1
0 votes
3 answers
59 views

Problem removing from Java-HashSet while implementing Kruskal's algorithm

in the following code I am trying to implement Kruskal's algorithm to compute the minimal spanning tree of a graph. The problem is that removing sets from the connected components does not work ...
sorry's user avatar
  • 121
0 votes
2 answers
80 views

Cartesian multiplication of two sets where the member of each set is a set

enter link description hereI have two expressions that I want to get a member-by-member union of. But the problem is where the member of each expression is a set. I have a graph from which I obtained ...
Mohammad Omidi's user avatar
-1 votes
1 answer
58 views

UNION query for every raw in a table

Version of mariaDB I have a table: USER Animal 1 1 3 1 4 1 5 1 1 2 3 2 4 2 5 2 2 1 5 7 2 2 5 8 2 9 5 9 4 10 5 10 I want to count UNION set for user1 with every other user. For ...
Михаил Зуев's user avatar
1 vote
1 answer
71 views

Using an image as orbit trap for coloring a Julia set

Searching the web I couldn't find any example on how to use a bitmap (a raster image) as orbit trap to color a Julia set or Mandelbrot set. Here Inigo Quilez is explaining the method he uses in only ...
petem's user avatar
  • 770
-1 votes
2 answers
56 views

Why is a private variable of type HashSet is being shared among object instances of the class? [closed]

I recently stumbled upon this weird behaviour of Java where a variable of type Hashset, which is declared private in the parent class, is not unique for each instance of the child. Instead, all the ...
ACP's user avatar
  • 1
-1 votes
0 answers
120 views

Why is a HashSet allowing duplicates even though they're the same? [duplicate]

I'm writing a library for graphs (graph theory) and I'm currently working on an undirected simple graph. As such, I want the edges in a Set since there shouldn't be any duplicates allowed. Graph.java ...
Kelavandoril's user avatar
0 votes
0 answers
28 views

How can I save the language of the login page and will be displayed in the next page using JavaScript and without localstorge?

How can you save the last language displayed in the login page and going to the next page and garding the same language for exemple i choose French in the login page and the next page must be in ...
Benjazia mohamed oussama's user avatar
0 votes
1 answer
23 views

Printing out a set with one element shows nothing

The problem came as I was trying to figure out why the solution I wrote to a leet code problem was not working. #include <algorithm> #include <iostream> #include <set> using ...
tryst with freedom's user avatar
0 votes
1 answer
50 views

Cleanest Way to Get a Set in Redis where Individual Elements Expire in 30 Days?

I need a data structure similar to a Python set in redis, with the additional capability of individual elements automatically expiring (getting popped) from the set 30 days after insertion. Basically, ...
Della's user avatar
  • 1,304
1 vote
1 answer
39 views

How to handle unordered sets of tags in Python Pandas Dataframe in terms of merging

I have two Dataframes which contain tags in one of the columns. Tags can be present or absent in the list and are stored in an unordered manner. I would like to get the merge of the two datasets with ...
Melon Pie's user avatar
  • 135
0 votes
1 answer
24 views

Comparing elements of nested lists in python's record linkage library using BaseCompareFeature

I am working with python's record linkage library to identify matching entities in two different dataframes (let us call them dfA and dfB for simplicity). One of the features that I would like to use ...
mbgzoo's user avatar
  • 1
0 votes
1 answer
18 views

MongoDB finding set differences

What would be the best way to compare one attribute from two collections to find which ones are missing? I have two collections "items" and "items_recovery" items look like this { ...
lesolorzanov's user avatar
  • 3,542
0 votes
2 answers
44 views

how to solve the undetermined issue in a let-such-that expression in Dafny?

here is an example: function intsetmax(s:set<int>):int requires |s| > 0 ensures var m := intsetmax(s); m in s && forall i :: i in s ==> m >= i { var x :| x in ...
ZihaoZhang's user avatar
0 votes
0 answers
37 views

beginner coder first code with error 91 help me? [duplicate]

i have a probleme with a simple vba code and its make a error 91 and in don't understand why. Sub test() Dim rng As Range rng = Range("SET_HEADER_BOX").CurrentRegion.Select -> error here ?...
Charly RUBIGNY's user avatar
0 votes
0 answers
15 views

Incorrect Pivot Table Totals in Qlik Sense

I have a problem with Pivot Table Totals, as showed here: Example I know that it could be dependent on Aggr function, but i have tried with no result. My measure is composed by two dates put on ...
Damiano D'Angeli's user avatar
0 votes
1 answer
115 views

Does collections.abc.Collection have a uniqueness property, like Set?

From https://docs.python.org/3/library/collections.abc.html#collections-abstract-base-classes, it's clear to me that a collections.abc.Set is a collections.abc.Collection. And a useful property of Set ...
Intrastellar Explorer's user avatar
-1 votes
0 answers
32 views

Java Exception: Cannot invoke "Object.equals(Object)" because "this.items[i]" is null [duplicate]

public class ArraySet<T> { private T[] items; private int size; public ArraySet() { items = (T[]) new Object[100]; size = 0; } public void add(T value) { ...
Proteus Yi's user avatar
-1 votes
1 answer
73 views

Custom comparison for set accessing member variables of a class where the actual keys belong to [duplicate]

How to specify custom compare for the following example? The idea is to access member variable within a class for comparison. struct MyStruct { unsigned p; unsigned t; }; class MyClass { ...
Maryam Shabani's user avatar
2 votes
1 answer
173 views

s = {1, True} is {1} and s = {1, False} is {1, False} why? [duplicate]

I am confused on the following output of set data structure of python. # case 1 s = {1, True} print(s) # case 2 s = {2, True} print(s) # case 3 s = {1, False} print(s) # case 4 s = {0, False} print(...
Habibur Rahman's user avatar
1 vote
1 answer
48 views

'Set like' behaviour of dict.items() for non hashable values

https://docs.python.org/3/library/stdtypes.html#dictionary-view-objects The documentation says: If all values are hashable, so that (key, value) pairs are unique and hashable, then the items view is ...
Evan Benn's user avatar
  • 1,591
1 vote
1 answer
53 views

Pretty print a julia set

Is there a quick function without looping etc to pretty print the items in a set without the "Set(Any[])" in Julia? Have searched to no avail. I'm printing the output to use for a latex ...
sarl's user avatar
  • 11
-1 votes
0 answers
20 views

Sets in Python on intersection_update [duplicate]

I am new to programming and going through the set concept and got stuck at this point The protection method is working fine, but intersection update method is printing out "none" Though ...
Keerthi GN's user avatar
1 vote
1 answer
54 views

What is the fastest way to remove multiple elements from a set, just based on their properties? (E.g. remove all negative numbers.)

In the following example all negative numbers are removed from the set. But first I have to create the subset of negative numbers. This does not seem like the most efficient way to achieve this. ...
Watchduck's user avatar
  • 1,086
-2 votes
0 answers
54 views

Problem with string, substring and set in C++

I have a Node object: Class Node { protected: std::string _name; Node* _parent; Node* _child; std::set<std::string> class; } Associated to this destructor: ~...
PenPen's user avatar
  • 1
0 votes
0 answers
26 views

Invalid or deleted object. when i use set function in matlab

i am trying to update the xdata and ydata of a plot using set function.I get the following error: Error using matlab.graphics.chart.primitive.Line/set Invalid or deleted object. the following is how i ...
Gavrila Razvan's user avatar
0 votes
1 answer
43 views

(1 week into learning Swift) Is it ok to compute(?) inside the body?

import SwiftUI struct ContentView: View { @State private var fiveNumbers: Set<Int> = [] @State private var twoNumbers: Set<Int> = [] // there has to be a better way to ...
Adjadj's user avatar
  • 3
0 votes
0 answers
11 views

I have an Accounts with multiple related Contacts. How can I retrieve only one Contract for each Account?

I have an Accounts with multiple related Contacts. My requirement is to retrieve one contact record for each account. If one Account have multiple Contact I just want to retrieve one Contact record. I ...
newbieApexLWCDev's user avatar
0 votes
1 answer
34 views

AMPL Syntax Error - N is already defined, but i didnt define it

Here is the .dat code: # ---------- Sets ---------- set N := 1 2 3 4 5 6 7 8 9 10; set L := 1 2 3; set N_l[1] := 1 7 8; set N_l[2] := 2 4 5 6; set N_l[3] := 3 9 10; # ---------- Parameters ---------- ...
SupBrudi's user avatar
0 votes
1 answer
22 views

The method addAll(Collection<? extends Set<Integer>>) is not applicable for the arguments (Set<Integer>)

I've been away from Java for over a decade, and generics were something I'd just barely encountered before I set it aside. I'm coming back and working on a practice problem, I'm running into an error ...
Joseph Collins's user avatar
1 vote
2 answers
61 views

Split set in java

I am trying to find the best way to retain the first half of a set in java. My Set (java.util.Set) contains 60000 elements and I need to retain only 30000 of it. What's the best way of doing this?
user4202236's user avatar
-1 votes
1 answer
41 views

java - Why contents of Set are changed unintentionally in the background

In a spring boot microservice, I'm having a Set of Wrapper Objects in my service class. This set represents subscribers, where the wrapper object includes all configurations needed by the subscriber's ...
Omar Hossam's user avatar
0 votes
2 answers
66 views

How can I bring the modification of a list from the values ​of a set to java stream?

I am currently working with Java and practicing my programming logic and as a good practice I am trying to apply stream in some operations with Java collections. In this case I have a method that ...
Cesar Justo's user avatar
-3 votes
1 answer
100 views

List comprehension to set

I want to make set with list comprehension, while the output while get multiplied. I try to print with output (list comprehension) with 1 - 5, when i multiplied it with 6 ,the second element not get ...
VrMoore's user avatar
2 votes
2 answers
76 views

How to make the `yaml.dump({1}) ` output "? 1" instead of "1: null" in Python?

This code in Python: import yaml data = {1} print(yaml.dump(data)) prints: !!set 1: null Is it possible to make this output: !!set ? 1 I think we should be able to do it, because this code: ...
Osama Adel's user avatar
0 votes
1 answer
48 views

Names from list to a set()

This is just a simpler version of what i need to do, but it doesnt work I have this list of names: liste = ['Bell,G.I.', 'Swain,W.F.', 'Pictet,R.', 'Cordell,B.', 'Goodman,H.M.', 'Rutter,W.J.'...
Christina H Christiansen's user avatar
0 votes
0 answers
17 views

set creation using constructor

This is actually in my Python course manual, yet VS-Code flags it with syntax errors at the quoted elements. I just don't get this. my_set = set(['X', 1, 'yesterday', 56.9]) or my_set = set(["...
S M's user avatar
  • 41
6 votes
1 answer
156 views

Semantics of set() versus Set() versus Set.new

Should &set, Set, and Set.new have different semantics? If so, why? Consider the following code: my @array = 1, 2; my @other-array = ([3, 4],); dd set(@array, @other-array); #OUTPUT: Set....
codesections's user avatar
  • 9,380
0 votes
1 answer
24 views

how to define a set such that elements of set vary with time

I want to define a time-varying set for 6 hours. The elements of the set vary with time. At t = 1 hr the element of the set is {3,6,8,1,4}, at t = 2 the element of the set is {6,8,1,4}, at t = 3 hr ...
VANDANA KUMARI's user avatar
0 votes
3 answers
73 views

Remove first comma from a comma separated list in Python

I have code that computes a Fibonacci sequence from the first 2 inputs from a user. Then it will accept and compare the subsequent entries if they belong to the sequence earlier computed. Then it will ...
codinguniverse's user avatar
0 votes
1 answer
96 views

Why is iterating over the set and modifying element not allowed here [duplicate]

In the following code, we cannot iterate over set s1 using non-const reference. Why? #include <set> struct st { unsigned int f; std::set<int> s2; }; struct comp { bool operator()(...
Ali Tavakol's user avatar
-3 votes
1 answer
96 views

TypeError: 'set' object is not callable [PYTHON] [closed]

viewed some other forums to see if I could find an answer to this but I didn't find anything satisfactory. I'm writing a program to work out the fibonacci sequence up to a specified index, but I keep ...
Fprime's user avatar
  • 5
0 votes
1 answer
41 views

VBA Excel Dim and Set 2 workbook files with FilePicker and work with them

I would like to pick, open, set and work ( copy data from 1 file to another) with 2 Workbooks. For this I have a 3rd .xlsm file where I have the following code to pick, open and set the 1st Workbook ...
Tom's user avatar
  • 131
-1 votes
1 answer
56 views

Difference in python execution on LeetCode and locally [closed]

** Update: This was a typo on my part, but I was struggling with the issue all morning. Sometimes something this obvious can elude you even if it is right in your face. I have solved a question on ...
Faisal Khan's user avatar
0 votes
0 answers
4 views

eror 91 Object variable or With block variable not set

Here is the code: Sub CopyAdjacentCell() Dim wb1 As Workbook, wb2 As Workbook Dim ws1 As Worksheet, ws2 As Worksheet Dim col1 As Range, col2 As Range Dim emptyCell As Range, ...
Popa Cristian's user avatar
0 votes
0 answers
20 views

pyyaml: dump set without null values

By default, pyyaml seems to dump sets like this: test_set: !!set member_a: null member_b: null However, I would prefer it to do this instead: test_set: !!set {'member_a', 'member_b'} which is ...
mara004's user avatar
  • 1,610
-2 votes
2 answers
82 views

usage of `OR, AND` operators in set union

Bear with me if the question is duplicate. But cant seem to find any related questions/solutions. Suppose I have tow sets: set_one = {10,5,7} set_two = {10,1,3,6, 5, 7} set_one | set_two # union of ...
Onyambu's user avatar
  • 69.2k

1
2 3 4 5
242