logic

How similar is an std::vector to a raw array in C++?

I'm writing a hangman game. I'm having a logic fail, both with myself and my game logic. Char guess (the letter the person guessed) isn't being added into the correct memory slot of the vector guessArray. Assume that word is an inputted word by the user. I assume this would work if guessArray were a raw array. Is there some reason this...

writing logic to store data in Mysql to store Metadata of Files

Hi Guys, Lemme explain the scenario: I need to fetch all the Metadata of Files, i.e., Title, author, subject.. and Custom Attributes.( Custom attributes are not fixed, they are not fixed and can be of any numbers). Now to Store this Struvture I have Designed a DB like : MainTable: FileID, FileName, Title, Author, Subject and To Store C...

Web Applications: Client-side domain logic

We see more and more work for web-applications done on client side. UI manipulation, input-pre-validation (not as last resort of validation, of course), widgets, effects, etc, etc. What if one decides to put domain logic on client side written in Javascript/GWT/anything else? The server just provides database infrastructure. Does this ...

Simple iterator looping gives unexpected result

I am sure it's an obvious error with my logic, but I can't seem to work out what I am doing wrong. Quite simply I have an array list of security codes, I want to compute the correlation between each combination of security codes. My code is as follows: private void crossCorr(ArrayList<String> codes, HashMap<String, Stock> stockMap){ /...

Logic expression parser

I'm trying to create a logic expression parser for expressions like: ((VariableA -> VariableB) AND NOT VariableC) The parser should be able to return, wheather the result is true or false for given values of variables. Basicly the expressions will only contain variables, logical operators (or, and, implication, equivalence, negation a...

Sql date select rows within X seconds range of each other

Hello, My sql table is something like (message,created) I want to select those rows which are within X seconds from each other. Say the last message is within X seconds from NOW(), then it should select it. If the second last message is within X seconds from the last message then it should select it too. In other words each row should ...

What is the optimal "most general unifier" algorithm?

The Question What is the most efficient MGU algorithm? What is its time complexity? Is it simple enough to describe as a stack overflow answer? I've been trying to find the answer on Google but keep finding private .PDFs that I can only access via an ACM subscription. I found one discussion in SICP: here Explanation of what a "most ...

Can anybody explain the contrapositive

I'm trying to construct a contrapositive for the following statement: If A is 0 or B is 0, then A*B is 0. Here is my attempt: If A*B is not 0, then A is not 0 or B is not 0. The original statement is true, but the contrapositive is false since both A and B must be non-zero in order for A*B to be non-zero... am I doing something wrong? ...

How to write correct Regex for url's on the page without anchors?

Hi all, I want to cut all url's like (http://....) and replace them on anchors <a></a> but my requirement: Do not touch anchors and page definition(Doc type) like: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; So I need to find just plain text with url's... I'm tryin...

How do I mark duplicates in a given group in MySQL?

I have the following table structure (in MySQL): DocID, Code, IsDup, DopOf , where DocID is Unique. Values are like : 1,AAAA,nul,nul 2,AAAA,nul,nul 3,AAAA,nul,nul 4,BBBB,nul,nul 5,CCCC,nul,nul 6,CCCC,nul,nul What I want is to write a procedure which can update the table and give the desired result as: 1,AAAA,0,0 2,AAAA,1,1 3,AA...

Predictional Logic in Programming?

I was thinking about how in the probably distant future many people think that we wont rely on physical input (i.e. keyboard) as much because the technology that reads brain waves (which already exists to some extent) will be available. Kinda scares me....anyway, I while I was daydreaming about this, the idea came to me that: what if a p...

Pixies in the custard swamp puzzle

(With thanks to Rich Bradshaw) I'm looking for optimal strategies for the following puzzle. As the new fairy king, it is your duty to map the kingdom's custard swamp. The swamp is covered in an ethereal mist, with islands of custard scattered throughout. You can send your pixies across the swamp, with instructions to fly low or high...

What exactly can concrete domains be used to describe?

I have read the formal definition of a "concrete domain", but I still don't quite get it. Could someone explain it to me in simpler terms, preferably with some examples? The definition is available in Reasoning in Description Logics with a Concrete Domain in the Framework of Resolution by Ullrich Hustadt, Boris Motik, Ulrike Sattler. P...

Will someone help me understand logic?

Ok so I have to prove the following sequent: (p -> r) ^ (q -> r) |- p ^ q -> r I understand why that is clearly correct and I also understand the rules of natural deduction. What I don't understand is how I go about proving it. Here is the model answer provided: 1. (p -> r) ^ (q -> r) |- p ^ q -> r premise 2. p ^ q ...

What is NOR logical operator?

Is nor: !(a or b) !a or !b !(a and b) something else? ...

What is the difference between "someValuesFrom" and "allValuesFrom"?

In description logic, what is the difference between "someValuesFrom" and "allValuesFrom"? In other words, the difference between (limited existential quantification) and (value restriction). For example, consider this: ∆ = {a, b, c, d, e} ext(B) = {<c,d>} ext(R) = {<a,b>, <a,c>, <d,c>, <c,e>} So what is the difference between t...

How does skolemisation of lone EXISTS clauses work?

Hi, If I have a formula like: FAx FAy (Ez(!A(x,z) v !A(y,z)) v B(x,y)) (FA = For All / E = Exists) The rules of skolemisation say that: if E is outside FA replace with a constant or if E is inside FA replace by a new function contain all the vars from outside the FA as arguments. So what do I do in this case? Can I just drop t...

C# convert a string for use in a logical condition

Hi, Is it possible to convert a string to an operator for use in a logical condition. For example if(x Convert.ToOperator(">") y) {} or if(x ">" as Operator y){} I appreciate that this might not be standard practice question, therefore I'm not interested in answers that ask me why the hell would want to do something like this. ...

How to work with Session and Include statement in PHP?

I am having many files with multple includes one into another like below, File1 is included in File2 and then File2 is under File3 Now I want to declare a session variable site_user_conutry from File1 and then I am checking on File2 that if there is any no value in the session variable then Only I am including File1.php I have added ...

How to create Alphabetical list with letters?

Hi all I trying to implement alpha ordered list by columns as shown on picture But my algorithm is not clear and maybe someone could help me within string[] letters = new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "Å", "Ä", "Ö", "0-9...