Menu
  • HOME
  • TAGS

Which is the quickest of prime generating algorithms?

performance,algorithm,comparison

Your second algorithm is faster. I don't know why you only saw a 20% improvement. Here are the results of my tests, with separate implementations: 10^6: First: 00:00:01.0553813 67240405 steps Second: 00:00:00.2416291 13927398 steps Sieve: 00:00:00.0269685 3122044 steps 10^7: First: 00:00:26.4524301 1741210134 steps Second: 00:00:04.6647486 286144934 steps Sieve: 00:00:00.3011046 32850047...

Comparing the InnerHTML of an object in jQuery

javascript,jquery,dom,comparison,sharepoint-2013

So, try the following which is a bit easier than what you were trying. var $divNode = $('div'); var html = $divNode.html(); if ( $(html).children().length > 0 ) { alert ("not empty"); } else { alert ("empty"); } Demo...

get buffer contents, store it in struct, get new buffer contents see if equal in struct

c++,c,arrays,struct,comparison

One problem: if (input == output) That just compares two pointers, not the contents of what they point to. Use: if (strcmp(input, output) == 0 ) PS There might be other problems in your code....

Python: Searching a specific columns of a table for not matching items

python,csv,table,comparison

You can use zip to get your columns then.You can use a generator expression within all function for checking that all the elements mett the condition : with open("test.txt", "r") as Spenn,open("test.txt", "r") as table: reader = zip(*csv.reader(Spenn, delimiter="\t")) writer = csv.writer(table, delimiter="\t") for row in reader: if all(field not...

Ruby: matching a string against another object that may be a string or regexp

ruby,regex,string,comparison

This is a shortened version of your approach: def compare(str, thelist) thelist.any? { |item| item.match(str) } end ...

is it safe to use comparison operators on BigDecimal in groovy/grails?

groovy,comparison,operator-keyword

Groovy allows overloading of operators. When a type implements certain methods then you can use a corresponding operator on that type. For + the method to implement is plus, not add. For greater than or less than comparisons, Groovy looks for a compareTo method on the object, and for ==...

PHP Loose comparison and null on Switch

php,null,switch-statement,comparison,case

If $sHost equals to null or '', then the first switch case is always true because var_dump($sHost == (strpos($sHost, "dev.localhost") !== false)); is true. How switch work. You can do this: switch(true) { // Local case strpos($sHost, "dev.localhost") !== false: $this->_sEnv = 'local'; break; // Prod default: $this->_sEnv = 'production';...

Global class comparison with inheritance

c++,class,inheritance,comparison

Your design has the potential to produce unexpected results. If your main is: int main(int argc, char** argv) { Foo a(1); Bar d(1, 2); coutResult(a, d); return 0; } you'll end up comparing a Foo object with a Bar object and output will be: l.m_a == 1, r.m_a == 1,...

VB.Net Double comparison after some additions

vb.net,comparison,double

If you take the example 3 you would see that the result is actually 3.0000000000000009. The problem is in the rounding of a double. If you change the data type decimal the problem is fixed: Sub Main() Dim i As Decimal = 2 For x As Integer = 1 To...

Can I use « is » to compare against static variables?

python,enums,comparison,identity,static-variables

Can you? Yes - small integers are interned in CPython, so wherever you get e.g. x = 2 from, x is Color.green will evaluate True. Should you? No. For one thing, it doesn't make conceptual sense - do you really care if they're the same exact object (identity, is), or...

testing dynamically created strings

javascript,algorithm,comparison,func

Can't you create a lookup object which holds all the multiplication factors? Think of this as if it were a two-dimensional table: var factors = { a: { b: 16, c: 32, d: 64, e: 256 }, b: { c: 18, d: 20, e: 64, f: 256 } }; Then...

Comparing two images as being identical?

image-processing,comparison,dm-script

I think you need to specify a bit more clearly what you mean by identical. Within the framework of image-analysis in DigitalMicrograph, it could be (f.e.): 1) The identical file on disc. This has been answered by others. But for simplicity - if an image is open in DM you...

What is faster: equal check or sign check

java,performance,comparison,equality,cpu-architecture

Assuming those operations are JITted into x86 opcodes without any optimization, there is no difference. A possible x86 pseudo-assembly snippet for the two cases could be: cmp i, 1 je destination and: cmp i, 0 jg destination The cmp operation performs a subtraction between the two operands (register i and...

Does __ne__ use an overridden __eq__?

python,comparison,equality

From the docs: There are no implied relationships among the comparison operators. The truth of x==y does not imply that x!=y is false. Accordingly, when defining __eq__(), one should also define __ne__() so that the operators will behave as expected. ...

Python Pandas: How to groupby and compare columns

python,pandas,group-by,comparison

If I understood well your very unclear question, this should do the work: import re import pandas df = pandas.DataFrame([['adamant', 'Adamant Home Network', 86], ['adamant', 'ADAMANT, Ltd.', 86], ['adamant bild', "TOV Adamant-Bild", 86], ['360works', '360WORKS', 94], ['360works ', "360works.com ", 94]], columns=['match', 'name', 'group']) def my_function(group): for i, row in...

How do I only send the differences between two images over the network? [duplicate]

c#,image,sockets,stream,comparison

Here is an improved and (somewhat) bpp independent version of the post linked to in my comment. It creates a fresh Bitmap on both diff'ing and restoring. Here is an example: The full images are 1396x906 pixels and have 103k for input and output images. The diff image is 13k....

How to compare date in string with sysdate in Oracle?

oracle,date,comparison

you're missing the century from your date SELECT CASE WHEN sysdate > to_date('30-Apr-2015','DD-MON-YYYY') THEN '1' ELSE '0' END FROM DUAL ...

Write the condition - only one of three numbers are multiple of 5

java,math,numbers,comparison

Then I expect you want something like condition = x % 5 == 0 ? y % 5 != 0 && z % 5 != 0 : y % 5 == 0 ^ z % 5 == 0; Or condition = (x % 5 == 0 ? 1 : 0...

Comparison between two objects under the same class

c++,comparison

if(Object A == Object B) return true; will do the job? No it won't, it won't even compile error: no match for 'operator==' (operand types are 'Fruit' and 'Fruit') You need to implement a comparison operator==, like bool Fruit::operator==(const Fruit& rhs) const { return (apple == rhs.apple) && (banana ==...

Is there a detailed comparison between Propel 2 and Doctrine 2

performance,orm,doctrine,comparison,propel

I'm also during making my decision which PHP ORM to choose and recently I found the following comparison of the main features of Doctrine2 and Propel 2: Side by side: Doctrine2 and Propel 2. The comparison is very precise and comprehensive, so surely it can come in handy when making...

R: Comparing the presence of a string in multiple dataframes

r,comparison,data.frame

First thing I'd do is to rename the dfs to "legit" R names, such as: DvE.plus DvE.minus and so on. Then I'd get the list of all genes (I'll use only 2 hypothetical dataframes for this demonstration); all.genes <- unique(c(DvE.plus$gene, DvE.minus$gene)) Then I'd regroup the dataframes in a list for...

PHP compare 2 arrays (Mac donalds and Burger King)

php,html,checkbox,sum,comparison

I made the necessary changes to your code to make it work and do what I think you want. Here it is, the changes are pointed by commented arrows "// <=======", try it and let me know : <html> <head> <link rel="stylesheet" type="text/css" href="style1.css" /> </head> <?php if(isset($_POST['formSubmit'])) { $breakfastMC...

String comparison in ksh never succeeding

variables,comparison,ksh

== is not a valid comparison operator in POSIX test. If your particular implementation of ksh doesn't implement an extension adding it, you may need to use if [ "$VAR" = "NO" ] rather than if [ "$VAR" == "NO" ] I'd also consider using egrep -o 'SI|NO' to leave...

How can I compare two array lists for equality with a custom comparator?

java,generics,collections,comparison

Just implement the method that iterates, and reuse it every time you need it: public static <T> boolean areEqualIgnoringOrder(List<T> list1, List<T> list2, Comparator<? super T> comparator) { // if not the same size, lists are not equal if (list1.size() != list2.size()) { return false; } // create sorted copies to...

Perl: check in hash if all entries are equal, get an arbitrary/random key from hash

perl,hash,comparison

my $key = (keys %hash)[0] should work, or you can force list context by enclosing the scalar you assign to in parentheses: my ($key) = keys %hash; Another way would be to use each in scalar context: my $key = each %hash; In the testing loop, you are only interested...

Compare code from the files of two directores [closed]

php,ftp,compare,comparison

I use total commander for this... the menu command "commands - synchronize directories" ... shows you which files are different, then you have to merge one by one http://www.ghisler.com/screenshots/en/08.html, to merge a pair, just double click it, If you are on linux, then I really can not help

Comparing float values in bash

bash,if-statement,comparison,bc

In bash, you need to be very careful about spacing. For example: if [ $(echo " 0.5 > $X " | bc -l )==1 ]; then echo grande fi Here, there are no spaces around the ==, so it'll be interpreted as: if [ 0==1 ]; then fi Believe it...

Compare two DATETIME fields from multidimensional array and return a value or index

php,mysql,arrays,multidimensional-array,comparison

Thanks to Marc B this got solved. $sql = mysqli_query($conn, "SELECT firstName, greatest(lastLog, lastReceived) AS eligibleTime FROM customers ORDER BY eligibleTime DESC LIMIT 1"); $result = mysqli_fetch_assoc($sql); print_r($result); ...

Comparing multidimensional arrays using specific key in php

php,arrays,multidimensional-array,comparison,array-difference

You could do something like this in PHP >= 5.5.0: $result = array_diff_key(array_column($array1, null, 'username'), array_column($array2, null, 'username') ); ...

why the following code gives the first mobile no. irrespective of name

c,string,switch-statement,comparison

You cannot compare strings using = (or even by ==, for that matter) operator. You need to use strcmp() for that. In your code, inside mobileno() function, if( s="katrina" ) is essentially trying to assign the base address of the string literal "katrina" to s. It is nowhere near a...

MIPS - is there a way to transfer the value of the flag in coprocessor 1 to integer registers of coprocessor 0?

assembly,floating-point,comparison,mips,spim

You could use MOVF (or MOVT) to put a value in a GPR based on a single FP condition code: MOVF rd, rs, cc To test an FP condition code then conditionally move a GPR If the floating point condition code specified by CC is zero, then the contents of...

Custom String Deficiency

c++,string,char,comparison

std::map doesn't use operator == it uses operator <. You need to implement that operator to be able to use your String type as the key of a map. Here is an example - note the const of the parameter and the function - this is required by std::map. In...

Compare two arrays for a value

php,arrays,comparison

use the function array_intersect function in php. Eg: $a1=array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow"); $a2=array("e"=>"red","f"=>"green","g"=>"blue"); $result=array_intersect($a1,$a2) if (count($result)>=1) { //give access to the user } link: http://www.w3schools.com/php/func_array_intersect.asp...

PHP strings have same encoding (UTF8) and appear as identical in browser but are not equal

php,string,curl,utf-8,comparison

If you look at the HTML source code of what you copy pasted here, they are not the same. The second string has an additional entities & # 8203 ; (check the second `‌​') http://pasteboard.co/wBd2Ea4.png...

Conditionally change GetHashCode() when comparing two objects

c#,.net,performance,comparison,gethashcode

Equals / GetHashCode aren't designed to compare things which are "mostly equal". Equality is just a Boolean property in this case. In particular, having a fuzzy "mostly equal" approach leads to problems with transitivity. The documentaiton of Object.Equals includes this requirment: If (x.Equals(y) && y.Equals(z)) returns true, then x.Equals(z) returns...

Compare two instances of an object in Swift

class,swift,object,comparison

Indicate that your class conforms to the Equatable protocol, and then implement the == operator. Something like this: class PLClient: Equatable { var name = String() var id = String() var email = String() var mobile = String() var companyId = String() var companyName = String() //The rest of your...

Excel VBA: Compare Date to List & Return Next Date In List

excel,vba,date,comparison

Assuming that you have a named range TerminationDate and dates in the sheet "Cuttoff Matrix" are put in ascending order, the following function would yield you the msgbox with the next date compared to the date put in Range("TerminationDate"). Private Function Next_Date() Dim rng As Range Dim rngFoundPayGroup As Range...

Best way to detect changes when values might not exist anymore?

javascript,jquery,jquery-ui,comparison,concatenation

At var initialValues = $(.myNewClass).map(Function(x){ return x.val() }) .myNewClass should be a String , within quotes $(".myNewClass") . F at .map() callback should be lowercase f , to prevent calling native Function . x at first parameter of .map(x) would be the index of the element or object within the...

PHP Comparing 0 does not work

php,loops,comparison

The problem is straightforward; look at the outer loop: for ($hour = 0; $hour <= 23; $hour++) { Consider only the first iteration, so $hour is int(0). Further in the code: if(count($myhours) > 0) { for($h = 0; $h <= count($myhours); $h++) { Pay close attention to the loop condition:...

python merging pairs lists within sublists within a list by comparing previous pair's second number with next pair's first number [duplicate]

python,list,for-loop,merge,comparison

From the link above: def merge(times): saved = list(times[0]) for st, en in sorted([sorted(t) for t in times]): if st <= saved[1]: saved[1] = max(saved[1], en) else: yield list(saved) saved[0] = st saved[1] = en yield list(saved) >>>mylist = [[[0, 2], [2, 9]], [[3, 7], [7, 9], [9, 12], [15,...

C - Why compare constants with & instead of switch/if?

c,switch-statement,comparison,ampersand,opensl

That comment is in reference to the event constants. What you're looking at are not event constants, but rather status constants. Event constants would be for example: #define SL_PLAYEVENT_HEADATEND ((SLuint32) 0x00000001) #define SL_PLAYEVENT_HEADATMARKER ((SLuint32) 0x00000002) #define SL_PLAYEVENT_HEADATNEWPOS ((SLuint32) 0x00000004) #define SL_PLAYEVENT_HEADMOVING ((SLuint32) 0x00000008) #define SL_PLAYEVENT_HEADSTALLED ((SLuint32) 0x00000010) You can see...

Using Comparison Operators correctly

javascript,html,comparison,operators

You don't have html element with id cg, so this line fails document.getElementById("cg").value. However you have fingers as an html textbox. Also first time using not statements (is it !== or !=?) in HTML/JavaScript. In js, both are valid but they differ in functionality, != has an overhead of conversion....

python:compare values with other values in dictionary [closed]

python,loops,dictionary,random,comparison

something like this might work (not tested), assumes that states and capitals are 1 to 1 and in the right order import random random_state = random.choice(your_dict.get('state') index = your_dict.get('state').index(random_state) answer = your_get_answer_method() #returns the answer, process if needed (lower ... etc) if your_dict.get('capital')[index] == answer: #do some stuff here ...

compare “int* pointer” with constant memory adress

c,pointers,memory,comparison,microcontroller

The issue is that you are actually doing this: unsigned int * p; if(p<0x2000) {}; Where 0x2000 is an integer. You can resolve this by using a cast: #define ADR 0x2000 unsigned int * p; if(p<(unsigned int*)ADR) {}; Although a better option might be to actually add the cast into...

Comparing two decimals

c#,comparison,decimal

I think if I don't use Round then this solution is fine. var valOne = 1.1234560M; // Decimal.Round(1.1234560M, 6); Don't round. var valTwo = 1.1234569M; // Decimal.Round(1.1234569M, 6); Don't round if (Math.Abs(valOne - valTwo) >= 0.000001M) // Six digits after decimal in epsilon { Console.WriteLine("Values differ"); } else { Console.WriteLine("Values...

Java 8: More efficient way of comparing lists of different types?

lambda,comparison,java-8,java-stream

Your question’s code does not reflect what you describe in the comments. In the comments you say that all names should be present and the size should match, in other words, only the order may be different. Your code is List<Person> people = getPeopleFromDatabasePseudoMethod(); List<String> expectedValues = Arrays.asList("john", "joe", "bill");...

MySQL Comparison Query

mysql,comparison

Check it using HAVING clause: select Destination_Region, count(*) as Score from pro11 where Destination_Region is not null group by Destination_Region having Score>(SELECT COUNT(*) FROM pro11 WHERE Destination_Region = 'Africa' GROUP BY Destination_Region) order by Score DESC; Sample result in SQL Fiddle....

Python compare tuples with different data types but same values

python,comparison,tuples

tup1 = (1,2,3) tup2 = ('1',2,3) print(map(str,tup2))== map(str,tup1)) # tuple(map.. python 3 Or if you know they are all ints in one and a mixture of string digits and ints in the other just cast one: tuple(map(int, tup2)) == tup1 If you are using python 2 you can use itertools.izip...

Java interface to compare various data types

java,comparison,comparable

Something along the lines of: class MyDataType<T extends Comparable<T>>{ T data; public MyDataType(T _data){ data = _data; } } Feels like a homework question. ;)...

How to test comparison if input will be truncated?

c,integer,comparison

Better Approach is as Follows Scan the number as a String and then convert INT_MAX to String. Use itoa() for this. Make a string comparison and then accordingly print a message. You will not have the problem to store it in any int or float or anything. EDIT:Added a working...

Ruby comparing biggest potential number

ruby-on-rails,arrays,ruby,comparison

ar = [1,2,99,901] p ar.map(&:to_s).sort.reverse.join.to_i # => 9990121 p ar.sort_by(&:to_s).reverse # => [99, 901, 2, 1] This creates an array of strings,which are sorted alphabetically.This sorting is from low to high - the opposite is needed, so the sorted array is reversed....

Theoretically, is comparison between 0 and 255 faster than 0 and 1?

performance,comparison,bit,low-level,machine-code

Hardware is fundamentally different from the dominant programming paradigms in that all logic gates (or circuits in general) always do their work independently, in parallel, at all times. There is no such thing as "do this, then do that", only "do this here, feed the result into the circuit over...

Python: How would I compare two strings using a function with only one of the strings as an argument?

python,string,comparison

Yes absolutely, this is a reason for having classes. Read up on https://docs.python.org/2/tutorial/classes.html. def myFunction(self, cdate): return self.y == cdate.y and self.z == cdate.z ...

Using the !== Operator to compare strings taken froma Dropdown list - Javascript

javascript,comparison,operators

Your use of !== is fine. The problem is with your use of || instead of &&. There's also a typo — you misspelled "q1check" in the second comparison. The test in the if statement: if(q1check !== "1" || q1check !=="0") (assuming you fix the typo like I did) will...

Numpy matrix row comparison

python,performance,numpy,matrix,comparison

Few approaches with broadcasting could be suggested here. Approach #1 out = np.mean(np.sum(pattern[:,None,:] == matrix[None,:,:],2),1) Approach #2 mrows = matrix.shape[0] prows = pattern.shape[0] out = (pattern[:,None,:] == matrix[None,:,:]).reshape(prows,-1).sum(1)/mrows Approach #3 mrows = matrix.shape[0] prows = pattern.shape[0] out = np.einsum('ijk->i',(pattern[:,None,:] == matrix[None,:,:]).astype(int))/mrows # OR out = np.einsum('ijk->i',(pattern[:,None,:] == matrix[None,:,:])+0)/mrows Approach #4...

How could I compare two data sets of X,Y coordinates to look for similarities?

javascript,authentication,comparison,coordinates,gesture-recognition

Reading about handwriting recognition software it seems that the early phases such a recognising the strokes might be helpful. Decompose the gesture into a number of elements (lines or curves) then apply some matching algorithms.

How to compare two arrays in mysql query?

php,mysql,arrays,comparison

You can do this using find_in_set(): where find_in_set(4, educations) > 0 and find_in_set(6, educations) > 0 However, this is generally inefficient. The problem is your data structure. You should be using a junction table with one column for each education, instead of storing a list of integers in a highly-inappropriate...

Comparing two excel Sheets using VBA

excel,vba,excel-vba,comparison

Yes there is - Microsoft Query (SQL in Excel). You can access it from Data->From Other Sources->Microsoft Query SQL is exceptional in comparing/consolidating/updating multiple data sources. See this section of my blog post here. Microsoft Query will also be much faster than any VBA macro. An example of your issue:...

How do I match a date from a list of dates in excel?

excel,excel-formula,comparison

An alternative approach: Assume Date1-Date4 are in A2:A5, and Date5 is in B2: {=OR(B2=A2:A5)} Note that you need to enter the formula as an array formula using Ctrl+Shift+Enter....

Trying to compare a value to multiple, multiple dimension arrays

arrays,excel,vba,comparison

Ok, here is how I got it working. Most of this came from another person, but they deleted their comment so I can't thank them. arrCols = Array(arrA, arrB, arrC, arrD, arrE) arrVals = Array("Dog", "Cat", "Bird", "Monkey", "Blue") For i = 2 To rCnt pID = Cells(i, 2).Value pName...

ACL “fuzzy” comparision

arrays,powershell,comparison,powershell-v2.0

I'd do something like this: $defaults = 'BUILTIN\Administrators', 'MYDOMAIN\DomainGroup', 'S-1-5-21*' $access | ? { $id = $_.IdentityReference -not ($defaults | ? { $_ -like $id }) } | select -Expand value $defaults | ? { $_ -like $id } does a wildcard match of the given identity against all items...

Python : How to optimize comparison between two large sets?

python,list,optimization,comparison,nlp

You can create a set of your stop_words, then for every word in your text see if it is in the set. Actually it looks like you are already using a set. Though I don't know why you are sorting it. ...

How to compare mac-addresses in Perl

perl,comparison,mac-address

How about normalization, make them both upper case, and convert - to :, my $mac1 = "12-23-34-RT-43-23"; my $mac2 = "12:23:34:rt:43:23"; y|[a-z]-|[A-Z]:| for $mac1, $mac2; print "equal\n" if $mac1 eq $mac2; ...

In JavaScript, is there any difference between typeof x == 'y' and typeof x === 'y'?

javascript,performance,comparison,undefined,typeof

It makes absolutely no useful difference either way in this case. The typeof operator returns a string indicating the type of the unevaluated operand. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof We know it is always going to be a string, and it will only be that of a few predefined values, so there is no...

Comparison != doesnt work like I expect

python,comparison,control,operator-keyword,flow

The expression you are evaluating always returns True salir != "s" or salir != "S" == True # always If the user inputs 's', then salir != "S" If the user inputs 'S', then salir != "s" If you want to split the two cases (instead of calling the lower()...

Using comparable to compare different variables

java,libgdx,comparison,comparator,comparable

If you are using this to sort your objects, then your Comparable or Comparator must be well behaved and must respect the transitive and other rules. If not, then your code is broken. It is recommended that your comparing methods be consistent with equals, that means that a.compareTo(b) returns 0...

Error while comparing data fetched from the table

php,mysql,arrays,error-handling,comparison

mysqli_fetch_row return result row as an enumerated array you can use mysqli_fetch_assoc to get while($array1= mysqli_fetch_assoc($result1)){ ...

Comparing values after ChangeType not working

c#,if-statement,integer,comparison,changetype

Your problem is that _pkValue and _defaultValue aren't pure integers, they're boxed. The static type of the variables is object, which means that your != operator is checking for reference equality rather than comparing the boxed integer values. You can use the polymorphic Equals method to check for value equality:...

count how many times characters from a range occur in a string

string,bash,comparison

- has a special meaning in a character class, it denotes a range. Move it to the beginning or end of the class: $ echo :/, | grep -o "[@#$%&*-=+]" | wc -l 3 $ echo :/, | grep -o "[@#$%&*=+-]" | wc -l 0 $ echo :/, | grep...

String Comparison from text file does not return anything

string,comparison,buffer

For one, you're adding line breaks to DriverState that are not present in Yes or No, so both comparisons will always return false. On a side note: the Java naming convention for variables, fields and methods is lower camel case, so driverState instead of DriverState....

Comparison method violates its general contract when sorting

java,sorting,comparison

This is one example of the sort of change that I think is needed. As @CommuSoft pointed out in a comment, the current treatment of null for o1 and o2 breaks transitivity. I would replace: if (o2 == null || o1 == null) return 0; with: if (o2 == null...

Why Comparison Of two Integer using == sometimes works and sometimes not? [duplicate]

java,types,comparison

The Java Language Specification says that the wrapper objects for at least -128 to 127 are cached and reused by Integer.valueOf(), which is implicitly used by the autoboxing.

Comparison between one observation and the others by level of a factor

r,comparison

You can use data.table. library(data.table) df$score=as.numeric(as.character(df$score)) df <- as.data.table(df)[, ratio1:=score/(sum(score)-score) , by = Ident] df Ident iduni score ratio ratio1 1: A_1_2 A_1_2_231 92 NA 0.09246231 2: A_1_2 A_1_2_233 102 NA 0.10355330 3: A_1_2 A_1_2_234 263 NA 0.31917476 4: A_1_2 A_1_2_235 155 NA 0.16630901 5: A_1_2 A_1_2_236 234 NA 0.27432591...

How to check string is laid out in correct format (Python)

python,string,comparison

You could either use regular expressions, or try to parse the date with time.strptime and see if there are any exceptions. See https://docs.python.org/2/library/time.html#time.strptime The strptime way could be something like this: try: time.strptime(input_string, "%d-%H.%M") except ValueError: print("Incorrect date format") Be sure to check the docs and see if the placeholders...

Apache Hadoop vs Google Bigdata

hadoop,comparison,hdfs,bigdata,gfs

Simple answer would be.. it depends on what you want to do with your data. Hadoop is used for massive storage of data and batch processing of that data. It is very mature, popular and you have lot of libraries that support this technology. But if you want to do...

Python, comparison sublists and making a list

python,comparison,append,sublist

You will have to catch the duplicate indexes but this should be a lot more efficient: gr = [] it = iter(mylst) prev = next(it) for ind, ele in enumerate(it): if ele[0] == prev[0] and abs(ele[1] - prev[1]) <= 2: if any(abs(ele[i] - prev[i]) < 10 for i in (2,...

How to compare signal to zero in vhdl?

comparison,vhdl,comparator

The easiest way to pipeline your comparaison operation on Xilinx is to let the tool do it for you. You need to activate the "register balancing" option and use syntax such as: if rising_edge(clk) then check_0 <= unsigned(sig) = 0; check_1 <= check_0; check <= check_1; end if; XST (or...

Why does this string extension method not throw an exception?

c#,null,comparison,ienumerable,argumentnullexception

You are using yield return. When doing so, the compiler will rewrite your method into a function that returns a generated class that implements a state machine. Broadly speaking, it rewrites locals to fields of that class and each part of your algorithm between the yield return instructions becomes a...

Comparing cell contents against string in Excel

string,excel,if-statement,comparison

We need an Array formula. In G2 enter: =NOT(ISERROR(MATCH(1,--EXACT(F$2:F$7,E2),0))) and copy down. Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key. Note: The curly brackets that appear in the Formula Bar should not be typed....

Batch - Comparing two txt files

windows,batch-file,text,comparison

The code below keep lines from File2.txt from the first line that differ vs. File1.txt on: @echo off setlocal EnableDelayedExpansion rem Redirect the *larger* file as input < File2.txt ( rem Merge it with lines from shorter file for /F "delims=" %%a in (file1.txt) do ( rem Read the next...

PHP strict compare two objects is false

php,arrays,object,comparison

Strict compare checks if $a and $b are the exact same object (same memory location). The only way to make them the same (strictly) would be $a = $b; See http://php.net/manual/en/language.oop5.object-comparison.php for reference...

VBA copy rows after comparing column data

excel,vba,comparison

Still not sure what you want to do with the different sheets. But the following macro will copy the rows that are not present in both sheets to the MisMatch worksheet. The Inventory rows are copied first, then a blank line, then the Dev rows. Probably need some formatting to...

SELECT where date is within X months away regardless of stored year

mysql,sql,date,comparison

One approach is to use a conditional test like this: WHERE CONCAT(YEAR(NOW()),DATE_FORMAT(d.deadline,'-%m-%d')) + INTERVAL CONCAT(YEAR(NOW()),DATE_FORMAT(d.deadline,'-%m-%d'))<NOW() YEAR < NOW() + INTERVAL 3 MONTH We can unpack that a little bit. On that first line, we're creating a "next due" deadline date, by taking the current year, and appending the month and...

How to compare matrix elements to treshold in NumPy

numpy,matrix,comparison

You may use np.searchsorted to obtain the indices: >>> np.array(y)[np.searchsorted(y, X)] array([[ 1. , 3. , 3. ], [ 0.5, 3. , 1. ], [ 5. , 1. , 3. ]]) ...

Comparing an object with a String using equals() method

java,language-features,comparison

The short answer: You need to override the implementation of equals() in your Flower (note: capital F) class. This will do something you like to do: @Override public boolean equals(Object o) { return (o instanceof Flower && ((Flower)o).flower.equals(flower)) || (o instanceof String && o.equals(flower)); } @Override public int hashCode() {...

find type equality in one array or list and perform operation. C#

c#,arrays,types,comparison

Use lambda expressions var vars = expression.Par.Select(x => x.GetType() == typeof(VarExpression)).ToList() ; var cons = expression.Par.Select(x => x.GetType() == typeof(ConstExpression)).ToList() ; Then you can do wherever you want with your expressions...

conversion from 'uint64_t' to 'unsigned int'

c++,visual-studio,comparison

The "argument" about which the compiler is warning is the i argument to operator[] in v[i] (note that this is the only argument on either of those lines). The parameter of this operator[] overload is of type size_t. In 32-bit builds size_t is a 32-bit unsigned integer. Conversion of the...

Using Linq to compare a list with a set of lists in C#

c#,linq,list,comparison

You can use Intersect + Any: query = query.Where(x => x.Tags.Intersect(tagList).Any()); This presumes that Tags actually is an IEnumerable<string>or another type that overrides Equals + GetHashCode. If that's not the case you can provide a custom IEqualityComparer<Tag> for Intersect. So tagList is the List<string> of the curent-page as requested. But...

Javascript: Compare backgroundColor set by javascript

javascript,css,background,comparison

Use Window.getComputedStyle() — https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle.

Finding a document in RethinkDB that meets multiple criteria

function,comparison,rethinkdb

RethinkDB doesn't just run your function on the server, it calls your function once to build up a predicate. (See http://rethinkdb.com/blog/lambda-functions/ .) You can build up the predicate you want and return it like so: r.db('test').table('monstertrucks').filter(function(item) { var pred = r.expr(true); arr = [{attr: "speed", val: 5}, {attr: "power", val:...