compare

Possible behaviors of `predsort/3`

你离开我真会死。 提交于 2019-12-21 10:40:34
问题 This is a followup to an answer to a question about sorting on a particular argument of a term, without creating a new list for a keysort (if I understood the original question correctly). Say we wanted predsort/3 to behave exactly as sort/2 : if I understand correctly, this would mean calling it as: ?- predsort(compare, List, Sorted). Now say that we wanted to use predsort/3 to sort as implemented by msort/2 (see also this question). One way to do it would be to define a comparison predicate

Problem comparing dates (times) in Android

不打扰是莪最后的温柔 提交于 2019-12-21 06:05:08
问题 I am having a problem when i am trying to compare two dates in Android. I am not sure if it is a problem with the emulator or if i have a problem in the code itself. The thing is the code works in a normal Java program environment, which confuses me even more. I have the following code to compare dates in Android 2.1 : public boolean compareDates(String givenDateString) { SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); boolean True; try { True = false; Date givenDate = sdf.parse

NSAttributedString Color Test

大城市里の小女人 提交于 2019-12-21 04:50:38
问题 What is the correct way to compare, or test, for a particular color attribute of an NSAttributed string? As an example, I'd like to know if the text selection has red text. I have tried several approaches, as you can see below, but none of them ever results in a match. I see the text turn red on screen, and logging the attribute returns: UIDeviceRGBColorSpace 1 0 0 1 - (BOOL)isRedWithAttributes:(NSDictionary *)attributes { BOOL isRedWithAttributes = NO; if (attributes != nil) { // if (

How can I verify that an array of strings contain a certain string? [duplicate]

[亡魂溺海] 提交于 2019-12-21 03:25:20
问题 This question already has answers here : How do I determine whether an array contains a particular value in Java? (28 answers) Closed 2 years ago . Given : String[] directions = {"UP","DOWN","RIGHT","LEFT","up","down","right","left"}; String input = "Up"; How can I verify that an input from stdin is within the directions array or not ? I can make a loop and check each item with input using equal ,but I'm looking for a more elegant way. Regards,Ron 回答1: Convert the array of valid directions to

How should I compare Perl references?

早过忘川 提交于 2019-12-21 03:12:13
问题 I want to check if two references point to the same object. It seems I can simply use if ($ref1 == $ref2) { # cheap numeric compare of references print "refs 1 and 2 refer to the same thing\n"; } as mentioned in perlref, but I vaguely remember seeing the use of some function for the same purpose. Is there any reason I shouldn't use the simple numerical equality test? Note I only want to know whether the references point to the exact same object. I don't look for a way to compare the content

C# - IComparer - If datetime is null then should be sorted to the bottom not the top

我的未来我决定 提交于 2019-12-21 02:38:34
问题 I have a list of dates that I want to sort in an ascending order. However, the default comparer means that I have: null null 18/01/2011 23/01/2011 Can someone help with a IComparer that will mean that the dates sorted in ascending order will look like: 18/01/2011 23/01/2011 null null 回答1: Here's a generic comparer that should work for pretty much any type: var yourList = new List<DateTime?> { null, new DateTime(2011, 1, 23), null, new DateTime(2011, 1, 18) }; var comparer = new

compare two xml files with xslt?

我只是一个虾纸丫 提交于 2019-12-21 02:25:09
问题 I have 2 xml files. How can I compare both files are equal or not by using xslt? If not equal means where the changes havebeen occur in the second xml? 回答1: In XPath 2.0 you could simple use fn:deep-equal. Following the same pattern in XSLT 1.0, this stylesheet: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:param name="pSource2" select="'emp2.xml'"/> <xsl:template match="/*"> <xsl:variable name="vDeep-equal"> <xsl:apply-templates select="." mode="deep

Comparing an NSDate to [NSDate date]

霸气de小男生 提交于 2019-12-20 20:31:11
问题 I am trying to force a user to select a date in the future with a date picker. I obviously used the compare: method, however, when I do the following code, even if it's the same date as [NSDate date], it tells the executes the if statement. Here is my code: if ([datePicker.date compare:[NSDate date]] == NSOrderedAscending) // If the picked date is earlier than today { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Hmm, this date is earlier than today" message:@"The date you've

Compare the similarity of two images with opencv?

耗尽温柔 提交于 2019-12-20 15:24:28
问题 I want to check two images are similar or different with opencv. if they are same printf("same"); if they are not same printf("not same"); is there any method or way for that in opencv? 回答1: It is not so easy task, and it is impossible to do with one if. What I recommend is to match image's interest points. Basically you can use opencv library to identify interest points on images and perform the match of them. If the percentage of the match is high enough, you can conclude that images are

Compare every item to every other item in ArrayList

非 Y 不嫁゛ 提交于 2019-12-20 11:43:01
问题 I'm having trouble with what I thought should be a pretty simple problem. I need to compare every item in an arrayList with every other item in the the list without comparing items to themselves. It's not as simple as calling an equals() comparison, it involves some custom logic that I've omitted from my code below. Also the ArrayList should not be changed in any way. The problem I seem to be having is that once I get into the second loop, I don't know if I have another object to compare to