theory

jquery storing properties in elements?

I have a select element. This element is looped over using jquery, any options that are :selected are added to one list(lista) any options that are :not(':selected') are added to another (listb) these lists follow the structure of <div id="lista"> <div>1st selected option text <div class="button"></div></div> <div>2nd selected o...

What are the consequences of saying a non-deterministic Turing Machine can solve NP in polynomial time?

Hello guys, these days I have been studying about NP problems, computational complexity and theory. I believe I have finally grasped the concepts of Turing Machine, but I have a couple of doubts. I can accept that a non-deterministic turing machine has several options of what to do for a given state and symbol being read and that it wil...

How many operations would it take to simulate an Atom?

So I got into an argument today with a colleague of mine about how much processing power it would take to simulate a human brain and that it should be possible within the next 15 – 20 years. This argument is based on the assumption that consciousness lies at the atomic level and not at the quantum level or some unknown state below. Base...

Why logic programming didn't win?

Seeing what it gives I see several huge advantages: Better approach to bug-free programming. Example. If you have to enable/disable a menu item with imperative programming, you should not only remember on what condition this item is enabled, but also don't forget to track all the moments where this piece of the code should be executed....

Finding a regular expression

I have a simple question about finding a regular expression for a given language. I am given the language L where: L = {w ∈ {0, 1}* : w has exactly one pair of consecutive zeros} My first attempt at this was to try L( (0 + 1)* 00 (0 + 1)*), but I noticed the problem with that would be with where I have (0 + 1)* because if 0 is ch...

Smoothing values over time: moving average or something better?

I'm coding something at the moment where I'm taking a bunch of values over time from a hardware compass. This compass is very accurate and updates very often, with the result that if it jiggles slightly, I end up with the odd value that's wildly inconsistent with its neighbours. I want to smooth those values out. Having done some readin...

What do we call this (new?) higher-order function?

I am trying to name what I think is a new idea for a higher-order function. To the important part, here is the code in Python and Haskell to demonstrate the concept, which will be explained afterward. Python: >>> def pleat(f, l): return map(lambda t: f(*t), zip(l, l[1:])) >>> pleat(operator.add, [0, 1, 2, 3]) [1, 3, 5] Haskell...

Algorithms used in game programming

What are the most frequently used algorithms in game programming? I guess some will be about graphs (traversals, minimal paths and so on), some about geometry (drawing circles, finding intersections of figures). It would be nice if someone with experience write down his thoughts about it. ...

Multiplication with .NET regular expressions

In the spirit of polygenelubricants' efforts to do silly things with regular expressions, I currently try to get the .NET regex engine to multiplicate for me. This has, of course, no practical value and is meant as a purely theoretical exercise. So far, I've arrived at this monster, that should check if the number of 1s multiplied by t...

When should I release my code?

I've been holding off on releasing a library I wrote because it is the first library which I'll be releasing publicly. Here are my concerns: The library isn't complete it is in a very usable state, I'd say it is version 0.3, however it still lacks a number of features which I would like to at some point implement, and control how they...

How to reduce duplication in code - If statements vs separate class

Let's say you have a website that lets you build an account with up to three different account owners. Each entry page for the owner is a separate aspx page. The first person has very different business rules than the second and third owners. The first will have more fields as well and different ones will be required for them but not f...

Determining synchronization scope?

Hi, in trying to improve my understanding on concurrency issues, I am looking at the following scenario (Edit: I've changed the example from List to Runtime, which is closer to what I am trying): public class Example { private final Object lock = new Object(); private final Runtime runtime = Runtime.getRuntime(); public void...

dijkstra's algorithm with negative edges on a directed graph

What if the only negative edge costs are coming from the initial node? Will the algorithm still work? I feel like yes because I can't think of a counter-example, but I'm having trouble proving it. Anyone have a counter-example? Negative edges are a problem for Dijkstra's because there's no guarantee that the edge you pick produces the ...

What does API usually represent?

I'm working on small ticket system. It's very simple and useable already, but I want it to be OOP in every possible way. So currently I'm at the point when I've started wondering, what might the API of such system look like or what it could offer. For example there is Twitter API, but twitter is a public service. The ticket system on th...

Hypothetical performance yield to not using SELECT *

To preface, I'm aware (as should you!) that using SELECT * in production is bad, but I was maintaining a script written by someone else. And, I'm also aware that this question is low on specifics... But hypothetical scenario. Let's say I have a script that selects everything from a table of 20 fields. Let's say typical customer informat...

Big O complexity of finding cycles in an Undirected graph

Hello! I need to find the complexity of finding all the cycles in a undirected graph consisting of 50 nodes. Moreover, if the graph grows large, will the complexity be changed and what will be it if the network grows considerably large. In addition, if I find only few cycles then how do I find the complexity of finding few cycles in a g...

Partially Overriding a Virtual Auto-Property in a Child Class

Time for a theoretical question I just ran across. The following code is valid and compiles: public class Parent { public virtual object TestProperty { get; set; } } public class Child : Parent { private string _testValue = "Hello World!"; public override object TestProperty { get { return _testValue; } } ...

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...

The Relational Model & Queries That Naturally Return Duplicate Rows

It's commonly understood that in the relational model: Every relational operation should yield a relation. Relations, being sets, cannot contain duplicate rows. Imagine a 'USERS' relation that contains the following data. ID FIRST_NAME LAST_NAME 1 Mark Stone 2 Jane Stone 3 Michael Stone If someone runs a query se...

What is in the future for JADE?

I'm starting my thesis on Agents and Smart Objects interaction and I'd like to know what's in the future for JADE, the Java Agent framework. I find the whole concept of agents, programmable behaviors, federations and their help in solving Artificial Intelligence problems very interesting but will it always be an academic field, like Hask...