logic

Why do Strings start with a "" in Java?

Possible Duplicate: Why does abcd.StartsWith() return true? Whilst debugging through some code I found a particular piece of my validation was using the .startsWith() method on the String class to check if a String started with a blank character Considering the following : public static void main(String args[]) { Strin...

Why do we have "is not a Number" (isNan) functions?

Many languages have an isNaN() function. I am asking myself: why check for not being a number? Is the reason purely logical or is it faster to check for not a number instead of is a number? Note that this is a pure question of understanding. I know that I can negate isNaN() to achieve an isNumber() function for example. However I am se...

Combinator logic and unification

Summary: if we are trying to use combinator logic to solve first-order logic type problems, is the best method to feed in free variables and use the standard first-order unification algorithm? In standard first-order logic, consider the problem of deducing that the following is a contradiction p(x) ~p(5) By the rule that we can subst...

Help with the logic of an script for composing multiple videos.

Hi All, I'm working on a Video Application and would like to hear some opinionenter code here of other developer about the logic for this section of the application. The application I'm working on will allow two live video streams to be recorded, and combined into a single FLV file. The application will have two "channels", I will hav...

How to write reusable business logic in MVC models?

Hi guys, my problem is that we try to use a MVC (php) framework. After discussing a lot think that MVC is very good, but I´m missing the possibility to write reusable model-(application)logic. So, I´m not sure if we have the right approach to implement our software in a MVC framework. First I´ll describe the non-MVC, oo-approach which ...

How to evaluate/translate Logic sentences defined in XML Files

I am going to work with some XML files containing logic sentences like these: <condition> <or> <not> <eq> <variable> <name>X</name> <variabletype>Test</variabletype> <datatype>String</datatype> </variable> <c...

Logic for software verification

I'm looking at the requirements for automated software verification, i.e. a program that takes in code (ordinary procedural code written in languages like C and Java), generates a bunch of theorems saying that each loop must eventually halt, no assertion will be violated, there will never be a dereference of a null pointer etc., then pas...

Determine if two strings are similar in Javascript?

Let's say I have two strings, is there any way to check if they are at least 90% similar? var string1 = "theBoardmeetstoday,tomorrow51"; var string2 = "Board meets today, tomorrow"; Thanks, Tegan ...

and/or conditions in a SQL query

I have to select all the records where FIELD1 is value11 or value12 and FIELD2 is value21, value22, value23, ... or value29. All 2*9=18 pairs of admissible values for FIELD1 and FIELD2 are possible. Which is the most compact form to write down my SQL query? ...

How to write a SQL statement to use "LIKE" for 9 different values?

I have to select all the records where: where FIELD2 like '%value21%' or FIELD2 like '%value22%' or FIELD2 like '%value23%' -- repeat up to or FIELD2 like '%value29%' Here, value21, ..., value29 are parameters which the user can put in a form before submitting the query. They are (not subsequent) numerical codes, and FIELD2 is a dat...

Which of these extensions to my little logic language are unifiable?

I plan to make a little obfuscatory logic language. It's going have some features prolog doesn't. Probable some of the features I want aren't possible to unify. But before I ask what features I should drop you should know what my language is. A comma means and. A semicolon means or. Things which would be zero-ary constructors take one ar...

How to keep fuzzy lookup index always in memory using SSIS

is it possible to keep fuzzy lookup index always in memory even after SSIS package has finished with execution? point here is, if it can be done then, when we call again same SSIS package, we don’t have any warm-up time because index is already in memory so we have better performance. We have seen that when we call out SSIS package ind...

Determining if a Powershell command was successful

Hi I am quite new to Powershell but I have one niggling question. I want to be able to tell if a command has completed successfully so I can give meaningful messages to host. I am using the appcmd command to add a binding in IIS. Essentially that goes as follows: ./appcmd set site /site.name:........................ But how can I do a...

Solving using DPLL sat solver

I found a sat solver in http://code.google.com/p/aima-java/ I tried the following code to solve an expression using dpllsolver the input is (A <=> B) AND (C => D) AND (A AND C) AND (NOT (B AND D)) AND (NOT (B AND D AND E)) CNF transformer transforms it to ( ( ( NOT A ) OR B ) AND ( ( NOT B ) OR A ) ) it doesn't consider t...

Java Collections Logic / Over coding issue

Below is an implementation of an exercise I've been asked to do (see comments). It works, and the reason I'm posting it is that the function checkMiracle looks like it should be contained in a much smaller loop of code - I'm writing out the same thing plus one ten times. The problem is, I can't seem to find a shorter way of doing it. My ...

How to code first order logic formula in C?

Hello, I am newbie in C and new to stackoveflow too. I have some problems in coding first oder formula like forall([X],implies(X,f(X))) Here x is a variable, implies is predicate and f is function. It sounds like for all x, x implies function of x i'e f(x). using C. Any kind of suggestions and help will be appreciated. ...

How to implement template logic in PHP.

Having my first attempt with PHP templates and i'm a bit confused separating business with presentation logic. I've choosen Dwoo as my template engine as you will see on the example below but my question is independent of Dwoo. I see that what im doing isn't a good logic, it'll confuse the designer and it doesn't really separates PHP/HT...

Prolog - return value from base case

Ok, here's the deal: I've got two piles of shirts I want to take a random shirt from each pile and put them in a new pile Then get the new pile out And here is the code: mix([],[],_). mix(P1,P2, Pile):- takeshirt(P1,1,Taken1,Rem1), takeshirt(P2,1,Taken2,Rem2), #Take one append(Pile,Taken1,New), append(New,Taken2,New...

Assembling a variable from other variables based on a condition

Hi Gang, Brain totally not working today. So, I have a few columns in a table that basically designate whether a certain piece of information WAS or WAS NOT provided by the user. For example, I have a table with: | ID | USER | crit1 | crit2 | crit3 | crit4 | etc. | Now, the record could have a 1 or yes for any of the "critX" fields...

How to use tricks in combination of "IF" conditions?(C# ASP.NET)

I have four checkboxes in my form. I have string variable called "CheckedString". If i check the first checkbox "A" must be assigned to "CheckedString". If i select both first and second checkbox at a time. "AB" must be assigned to "CheckedString". If i select third and fourth checkbox "CD" must be assigned to "CheckedString".So that sev...