set Questions
9
Solved
I have a set of distinct values. I am looking for a way to generate all partitions of this set, i.e. all possible ways of dividing the set into subsets.
For instance, the set {1, 2, 3} has the fol...
Pyro asked 11/12, 2013 at 21:19
4
Solved
I've need for a particular form of 'set' partitioning that is escaping me, as it's not quite partitioning. Or rather, it's the subset of all partitions for a particular list that maintain the origi...
Kickback asked 23/8, 2014 at 5:48
5
My problem is: I need to overload standard get and set for static variables in class... but no such functionality provided in php... it was asked in 2008 and still not implemented... Same goes for ...
Cameron asked 7/12, 2011 at 9:47
3
Solved
The basics of what I am trying to do is to use the 'random' filter to choose a random item from my list but then I want to use that randomly chosen item in multiple locations.
How do I set the res...
4
I have two lists, both contain integers represented as strings. large_list is large, up to low 10s of thousands of elements. small_list is smaller, up to hundreds of elements. I am filtering the la...
Grimsley asked 30/11, 2023 at 16:7
4
Solved
I am currently working on a collection library for my custom programming language. I already have several data types (Collection, List, Map, Set) and implementations for them (mutable and immutable...
3
Solved
I'd like to calculate a hash of a set of strings in Java. Yes I can sort the strings and calculate the
MD5 hash iterative using digest.update.
But I'd prefer to omit the sort and use something like...
3
Solved
How can I convert a java.util.Set[String] to a scala.collection.Set with a generic type in Scala 2.8.1?
import scala.collection.JavaConversions._
var in : java.util.Set[String] = new java.util.Ha...
34
Solved
How do I pick a random element from a set?
I'm particularly interested in picking a random element from a
HashSet or a LinkedHashSet, in Java.
6
Solved
SET @v1 := SELECT COUNT(*) FROM user_rating;
SELECT @v1
When I execute this query with set variable this error is shown.
Error Code : 1064
You have an error in your SQL syntax; check the manual ...
9
How can I iterate over a Set/HashSet without the following?
Iterator iter = set.iterator();
while (iter.hasNext()) {
System.out.println(iter.next());
}
1
Is there a Kotlin stdlib function to find the symmetric difference between two sets? So given two sets [1, 2, 3] and [1, 3, 5] the symmetric difference would be [2, 5].
I've written this extension ...
Toscana asked 18/12, 2020 at 17:37
1
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.new(1...
8
Solved
Background
I have a list.
This list has many objects. Each object has an id. Now the objects are of different types.
objects = [Aobject, Bobject, Cobject]
where
>>> Aobject != Bobje...
7
Solved
I'm working on an AI portion of a guessing game. I want the AI to select a random letter from this list. I'm doing it as a set so I can easily remove letters from the list as they are guessed in th...
8
Solved
Is it even possible?
Say you have
private Set<String> names = new LinkedHashSet<String>();
and Strings are "Mike", "John", "Karen".
Is it possible to get "1" in return to "what's ...
11
Trying to get two data sets to intersect but I can't do it. For example, in my code below, intersecting mySet and mySet2 should yield "1" since they both have a value of "1" in ...
Gaughan asked 10/8, 2015 at 23:40
6
Solved
If I have a python list that is has many duplicates, and I want to iterate through each item, but not through the duplicates, is it best to use a set (as in set(mylist), or find another way to crea...
8
Solved
I'm trying to write a piece of code that can automatically factor an expression. For example,
if I have two lists [1,2,3,4] and [2,3,5], the code should be able to find the common elements in the ...
Camus asked 5/7, 2012 at 16:9
4
Solved
Does Go have something similar to Python's in keyword? I want to check if a value is in a list.
For example in Python:
x = 'red'
if x in ['red', 'green', 'yellow', 'blue']:
print "found"
...
Striated asked 26/5, 2015 at 7:41
2
I'm trying to change code javascript to typescript
In Home.tsx,
interface IState {
mySet: ??; // what is type of Set??
myNum: number;
myStr: string;
myArr: number[];
}
class Home extends Comp...
Momentarily asked 2/10, 2019 at 3:54
7
Solved
In Java I like to use the boolean value returned by an "add to the set" operation to test whether the element was not already present in the set:
if (set.add("x")) {
print &quo...
33
Solved
I have two lists in Python:
temp1 = ['One', 'Two', 'Three', 'Four']
temp2 = ['One', 'Two']
Assuming the elements in each list are unique, I want to create a third list with items from the first li...
Rightness asked 11/8, 2010 at 19:38
8
Solved
The question arose when answering to another SO question (there).
When I iterate several times over a python set (without changing it between calls), can I assume it will always return elements in...
© 2022 - 2025 — McMap. All rights reserved.