logic

How to create list splitted by columns?

How to implement splitting by columns alpha ordered list as shown on the picture? ...

Generating truth tables for logic expressions in Haskell

I completely forgot about my Haskell project which is due in a couple of hours, any help would be appreciated. The first part is an evaluation function that has the following type signature: evaluate :: Logic Expr -> [(Variable, Bool)] -> Bool This takes a logic expression and a list of assignment pairs as input and returns the value...

End of month calculations

Hi guys Just wondering if any know of an elegant solution for the following. If I have 30 June 2009 and I add a month I want it to go to 31 July 2009, not the 30 July 2009. This logic is based on the fact that the 30 June 2009 was the end of the month of June and when I add a month I want to go to the end of the next month. But if...

Multiple Browser Windows Synchronization

Hello, I am trying to create an inline chat. The problem arrives when two windows of my site are open. Because then my script sends the new message to the the window which requests it for (for the time being i am using simple polling, will move to comet later). Is there any good technique that I haven't thought of, so that I can send a...

How to calculate scores?

Hi, This question is more related to logic than any programming language. If the question is not apt for the forum please do let me know and I will delete this. I have to write a logic to calculate scores for blogs for a Blog Award website. A blog may be nominated for multiple award categories and is peer-reviewed or rated by a Jury on ...

ASP.NET : Logic for Image Resizing proportionaly

I have a C# function to REsize images.The parameters of the funciton would be orginal image path,new image path(path after saving the resizing of image). Now i want to build a logic for the below requirement. 1 . If the orginal file's width is greater than 480 or lessthan 450 ,then i want to set the width of output image as 450px.and ...

Advanced Formal logic / Automata Theory textbook

I know this is more a Math/Formal Language/Automata/Computer science question than an a programming one, but I hope I can get some advice on a comprehensible textbook (not an indecipherable monograph) on formal logic beyond Propositional and Predicate Calculus. I’m especially interested in monadic second order logic and Büchi Automata. ...

Logic Building Abilities

Programming is mainly logic. It is said that if you have good logical abilities, you can become a good programmer. Logic can be learned. Is there a training / tutorial / book etc.. for logic building ? ...

How to automatically generate a sports league schedule

I'll start of by saying that I understand that this topic is complicated and that there probably isn't an easy answer. If it were easy then everybody would be doing it. That being said... I've been asked to build an application to manage a sports league. Most of the concepts are fairly easy to understand except for this one: How to gene...

Is it possible to convert code into a logical graph?

Is it possible to convert code into a logical graph? EDIT: What I am thinking is that math is absolute. We can judge whether it is right or wrong for sure. But for code, there is something other than the logic. What I want to do is remove that 'something' to keep the logic there only. ...

A java practice problem

I came across this problem in javabat(http://www.javabat.com/prob/p183562): We want to make a row of bricks that is goal inches long. We have a number of small bricks (1 inch each) and big bricks (5 inches each). Return true if it is possible to make the goal by choosing from the given bricks. This is a little harder than...

Performance Vs Principles , how much business logic should be there in the Stored Procedures

I always have debate with my Architect / DB team , on having a hybrid model to move partial business logic into the SP, like give the results based on few flags like Status , Date and logged-in USER ID ROLE( might also have some basic business logic) for a huge volume of DATA. If we can do this in SP then we could improve the performance...

General rules for simplifying SQL statements

I'm looking for some "inference rules" (similar to set operation rules or logic rules) which I can use to reduce a SQL query in complexity or size. Does there exist something like that? Any papers, any tools? Any equivalencies that you found on your own? It's somehow similar to query optimization, but not in terms of performance. To sta...

What are the best introductory logic programming books?

When people talk about functional programming books, the "classics' of Structure and Interpretation of Computer Programs, The Little Schemer, etc. inevitably enter the conversation. What are the equivalent logic programming books out there? Edit: I'm not really looking for books specific to learning a particular logic language like Pro...

ASP.Net: Conditional Logic in a ListView's ItemTemplate

I want to show certain parts of an ItemTemplate based according to whether a bound field is null. Take for example the following code: (Code such as LayoutTemplate have been removed for brevity) <asp:ListView ID="MusicList" runat="server"> <ItemTemplate> <tr> <% if (Eval("DownloadLink") != null...

XSLT Bitwise Logic

I have an existing data set that utilizes an integer to store multiple values; the legacy front end did a simple bitwise check (e.g. in C#: iValues & 16 == 16) to see if a particular value was set. Is it possible to do bitwise operations in XSL, and more explicitly, to do bit level comparisons via masking? The built-in "and" will always ...

How to display opening times?

Hi all, I'm trying to show intervals of working hours/days it's should look like this: I have table where I'm storing day number, open time and closing time for each day Then I created query=> var groups = from s in this.OpenTimes orderby s.Day group s by new { s.Till, s.Start } into gr select new { Time = gr.Key.Start + "-" + g...

How to execute SELECT and INSERT in single query with PHP/MYSQL?

I have a table user_name with 3 fields, id, Name, Email (id is auto_increment field). I want to execute the following query in PHP, but its not returning any result. INSERT INTO user_name (Name, Email) VALUES ('Example', '[email protected]'); SELECT LAST_INSERT_ID() AS 'userid'; When I am executing the above query in PHP as below then ...

How do I properly create an HTML class?

I'm working on an HTML class in PHP, so that we can keep all our HTML output consistent. However, I'm having some trouble wrapping my head around the logic. I'm working in PHP, but answers in any language will work. I want the class to properly nest the tags, so I want to be able to call like this: $html = new HTML; $html->tag("html...

PHP logic if statments

I have this code: $distance= -1 ;//default //distance calc if($dgalaxy = $galaxy){ if(($dx = $x) && ($dy = $y)) { //inter planitary currently unknown formula }else{ $distance = round(Sqrt(pow(($dx-$x),2)+pow(($dy-$y),2)));//interstllar } }else{//intergalatic if ($galaxy < $dgalaxy){ ...