set

Is there a more efficient way to calculate the power set of an array?

百般思念 提交于 2019-12-23 17:54:30
问题 This is my current implementation using bits: Function Array_PowerSet(Self) Array_PowerSet = Array() PowerSetUpperBound = -1 For Combination = 1 To 2 ^ (UBound(Self) - LBound(Self)) ' I don't want the null set Subset = Array() SubsetUpperBound = -1 For NthBit = 0 To Int(WorksheetFunction.Log(Combination, 2)) If Combination And 2 ^ NthBit Then SubsetUpperBound = SubsetUpperBound + 1 ReDim Preserve Self(0 To SubsetUpperBound) Subset(SubsetUpperBound) = Self(NthBit) End If Next

MYSQL Trigger set datetime value using case statement

不想你离开。 提交于 2019-12-23 17:43:28
问题 I'm using mysqlimport to do mass table inserts (replacing duplicates primary keys). Several tables have date time columns with records containing values '0000-00-00'. What I would like is a trigger which detects these '0000-00-00' values and replaces with '1950-01-01', otherwise keep the datetime value in the record (i.e. when it's not '0000-00-00'). I have tried the following: CREATE TRIGGER set_datetime BEFORE INSERT ON tbl FOR EACH ROW CASE WHEN date_col='0000-00-00' THEN SET date_col=

Set file name using user inputted variable in PHP

梦想与她 提交于 2019-12-23 17:25:00
问题 I'm just wondering how I can use the name of a variable to set a file name in PHP? When I run the following code: <?php if ($_POST) { $filename = $_POST['firstName']; header("Content-Type: application/txt"); header('Content-Disposition: attachment; filename="$filename.txt"'); echo "Welcome, "; echo $_POST['firstName']. " " . $_POST['lastName']; exit; } else { ?> <form action="" method="post"> First Name: <input type="text" name="firstName" /><br /> Last Name: <input type="text" name="lastName

Resharper says OnPropertyChange set member can be private while not true

烂漫一生 提交于 2019-12-23 17:19:41
问题 I use C#, MVVM, WPF and Resharper. When using the following code: public bool CombiBanksSelected { get { return _selectedBanksType == ESelectedBanksType.CombiBanks; } set { I get a warning of Resharper: Make set accessor private. When making the set method private, I get an InvalidOperationException: A TwoWay or OneWayToSource binding cannot work on the read-only property ''CombiBanksSelected'' of type ''PcgTools.ViewModels.PcgViewModel.' Of course I can suppress it by adding: public bool

Grouping integers by set membership in Python

☆樱花仙子☆ 提交于 2019-12-23 16:14:12
问题 Working in Python, given a list of N sets of integers from the range range(s,n), how can I build a list that groups all these integers according to their set memberships? An example is really going to help me explain here: Example input (N=2 sets): integerRange = range(0,13) input = [set([0,1,2,3,7,8,9,12]), set([0,1,2,3,4,5,6,12])] Desired output: out = [set([10,11]), set([4,5,6]), set([7,8,9]), set([0,1,2,3,12])] So in the output each integer in range(s,n) appears exactly once, and there

Assigning IP from Batch Script

回眸只為那壹抹淺笑 提交于 2019-12-23 15:01:11
问题 With the below code I am getting an error "Invalid interface LAN: specified". This code works in Win7, however, does NOT working in windows XP. I suspect it has something to do with the "!adapterName!" conflicting within XP. I utilize this script to obtain the NIC Name in case it changes in the future some how and would like to keep this scheme. Any ideas how I can continue with such script in an XP environment? :: Set primary and alternate DNS for IPv4 @ECHO OFF for /f "tokens=* delims=0" %

Mutable MultiMap to immutable Map

二次信任 提交于 2019-12-23 13:26:14
问题 I create a MultiMap val ms = new collection.mutable.HashMap[String, collection.mutable.Set[String]]() with collection.mutable.MultiMap[String, String] which, after it has been populated with entries, must be passed to a function that expects a Map[String, Set[String]] . Passing ms directly doesn't work, and trying to convert it into a immutable map via toMap ms.toMap[String, Set[String]] yields Cannot prove that (String, scala.collection.mutable.Set[String]) <:< (String, Set[String]). Can

Java combination of Set and List interfaces

谁都会走 提交于 2019-12-23 12:46:56
问题 I have a data structure, for which I am currently using an ArrayList . I realised that in this structure I do not want any duplicates to be present. My first thought was to use some form of set, however the order is also important. After a bit of googling and searching the Collections docs I found LinkedHashSet which almost does the job. Unfortunately, one of the primary reasons for preserving order is because I am using the get(int index) method of the ArrayList for random access, and I can

Finding Unique Items in a Go Slice or Array

筅森魡賤 提交于 2019-12-23 12:24:33
问题 I'm pretty new to go and I'm really, really confused right now. Let's say I have a list of coordinates and lets say I have some doubles in this list of coordinates. I can't for the life of me figure out how to make a unique list. Normally in Python I can "cheat" with sets and other built-ins. Not so much in Go. package main import ( "fmt" "reflect" ) type visit struct { x, y int } func main() { var visited []visit var unique []visit visited = append(visited, visit{1, 100}) visited = append

How are Int sort (of SMT-LIB 2.0 Ints theory) and dynamically declared sorts defined in z3?

懵懂的女人 提交于 2019-12-23 12:17:30
问题 Here is an SMT-LIB 2.0 benchmark which I executed with z3 : (set-logic AUFLIA) (declare-sort PZ 0) (declare-fun MS (Int PZ) Bool) (assert (forall ((x Int)) (exists ((X PZ)) (and (MS x X) (forall ((y Int)) (=> (MS y X) (= y x))))))) (check-sat) I expected the result to be sat , with at least a model where PZ is the powerset of Z (integers) and MS is a predicate which tests the membership of an integer into a subset of Z (an element of the sort PZ ). But z3 answered unsat . Could you help me