I'm trying to write a circuit schematic drawing tool in Python. I'm creating a simple database based on dictionaries which holds all the components and their properties. I'm also trying to create a simple query language where you can select, for example, all resistors with value>100ohms or footprint='0402'
So far, I can select things using some primitive predicate search and then union and intersection for more complex things.
However, I'm having trouble defining what the semantics ought to be for a purely negative search. For instance, something like
footprint != '0402'
should select all items with footprint not equal to 0402. But doing this with only intersection gives me a blank result. For this to work I need to select all components, then intersect with "not 0402" to remove the ones I don't want.
But this seems kind of brute force and seems like a fishy solution. I'm not interested in using a "real" database and query language, so please don't suggest that. I'm looking for the proper engineering rationale here, not necessarily a workaround to the problem.
This problem was covered to some degree in SICP book, but I got very confused, since I think they were also using continuations and stuff, which I don't get yet.
Can someone please explain what the 'proper' usage ought to be for negatively selecting stuff. I tried this in a commercial cad tool and it worked as expected, but then I've seen some SQL query examples (I think), which selected things first, then removed the unwanted ones.
thanks
michael