logic

What is more interesting or powerful: Curry/Mercury/Lambda-Prolog/your suggestion.

Hi! I would like to ask you about what formal system could be more interesting to implement from scratch/reverse engineer. I've looked through some existing and rather open (open in the sense of free/open-source) projects of logical/declarative programming systems. I've decided to make up something similar in my free time, or at least ...

Real world example of Unification in First Order Logic?

I know this is only part of a programming question, but at the moment, I'm doing a little bit of logic programming. One thing I still don't understand correctly is Unification in First Order Logic. I read the Wikipedia article and it is more or less clear that the purpose is searching a term that unifies two sentences... There are also ...

Question regarding mysql_insert_id() application in my code..

I have a page in which there is an if...else loop for processing of input data, this page is reverted two times when submitted, that is when a button called "Continue" is clicked and and second time "Add to cart".... Now in this case when Button "Continue" is clicked then the if loop is executed in which data is inserted in the Database,...

C: XNOR / Exclusive-Nor gate?

I am trying to find the most effective way of writing a XNOR gate in C. if(VAL1 XNOR VAL2) { BLOCK; } Any suggestions? Thanks. ...

Search Engine in php?

Sir, I want to create a search engine in php (like Google, Ask). So, please tell me how can I create it. What is the logic for it. Thanks, ...

PHP + Code Igniter Timecode Calculation Logic Error

Hello everyone, I have what I suspect to be a logic problem with an algorithm I am using to work with Video timecode in PHP. All help is appreciated. The Objective Well basically I want to work with timecode and perform calculations For those not familiar with timecode it looks like this 01:10:58:12 or HH:MM:SS:FF 'AKA' HOURS:MINU...

help, stuck with logic variable comparison loop, javascript

I have an input text box for search of input, the id of the text box is: id="search". if a user enters 'cat' at first and hit search. In the function, I get the value 'cat' by using the syntax: var input = document.getElementById("search").value; After that, the user enter 'dog' in the search box and hit search using the same fu...

Question on First Order Logic formula

Hi, Can someone validate the following. I am supposed to 'write a formula asserting that for every number there's a unique next number...true for integers for instance' L(x,y) means x is smaller than y the intended Domain is the Integer numbers Can I give x y [ x<y ( z : z<x y<z ) ] Thanks ...

Select which satisfies at least N conditions from M available.

Hi, there is a question floated. It's set in basic SQL terms, but its nature is pure math (so maybe I should visit http://mathoverflow.com too). I have a table in some theoretical database with 6 fields, all are numbers. Also we have basic conditions, such as Field_1 > Field_5, Field_4 = 3 etc., 7 conditions total. I need to write a sel...

Simple program logic to Call method continuously

Hi everybody, I am in a situation, in which my program needs to do processing and then wait for some interval, let's say 5 seconds and the do the same processing again. I don't know how to implement the logic. I have developed a logic, the code is below: private void ProcessEmail() { PprocessEmail:; //Do whatever ...

How to make my robot move in a rectangular path along the black tape?

I am working on a robot, it's part of the summer robotics workshop in our college. We are using C-STAMP micro controllers by A-WIT. I was able to make it move, turn left, turn right, move backward. I have even managed to make it go along the black tape using a contrast sensor. I send the robot at 30-45 degrees toward the black tape on ...

Separation of presentation and business logic in PHP

I am programming my first real PHP website and am wondering how to make my code more readable to myself. The reference book I am using is PHP and MySQL Web Development 4th ed. The aforementioned book gives three approaches to separating logic and content: include files function or class API template system I haven't chosen any of th...

How to filter off of a country code?

Okay, here's what I'm attempting. I have a drop down list with all of the countries in the world. The user selects one, and that value is passed to a case statement, if it matches the case, an email is sent. I only have four different recipents, but I can have upwards to dozens of countries to match with each one of the four emails. F...

Best Logic for Processing Master-Detail Records

Let's say, we have these SQL tables: [Articles] bill int (pkey) arti int (pkey) name varchar(50) [Bills] bill int (pkey) fdate date uid int Let's suppose we have a list of items on a grid, representing a bill: -------------------------------------------------------------- Id[ 15] Date [01-...

XKCD - Labyrinth puzzle

There is a modified labyrinth puzzle on xkcd: http://xkcd.com/246/ After reading it we asked on an interview, "how many questions required to survive and solve this puzzle?" Our best solution requires 5 questions, 1-1-1 question to everyone, and 2 to a chosen one based on the first 3. Can anybody construct a better, or different logic...

Does the ``??`` operator use shortcircuiting?

Does the ?? operator in C# use shortcircuiting when evaluating? var result = myObject ?? ExpressionWithSideEffects(); When myObject is non-null, the result of ExpressionWithSideEffects() is not used, but will ExpressionWithSideEffects() be skipped completely? ...

Checking validity of message sizes before sending to Twitter...

I have an ActivityStream that sends messages to Twitter. There is a short and long format for each message. It's possible that both could be over 140 chars, but the short format has much lower probability. By default, I start with the long version, then if that is over 140 chars, I use the short version. Again, there's a chance the s...

Best logic for creating a (true) random labyrinth

I've been trying to make a little simple game just to test my logics, and it's a simple labyrinth, it's ugly, and so far sucky. The engine works pretty well, given that the labyrinth already exists (a matrix), it could be even enjoyable, but I have no intention on drawing a bunch of maps, which might be setting values on 400 (20x20) fie...

Fitch Format Proofs - Any automatic solvers around?

Is there any software around that using the Fitch format (used in ), allows one to put a specific set of premises and goals and have it show us the full list of steps needed to solve the problem? ...

How to do this in Ruby?

I have an array(list?) in ruby: allRows = ["start","one","two","start","three","four","start","five","six","seven","eight","start","nine","ten"] I need to run a loop on this to get a list that clubs elements from "start" till another "start" is encountered, like the following: listOfRows = [["start","one","two"],["start","three","fou...