logic

Complex SOLR query including NOT and OR

自闭症网瘾萝莉.ら 提交于 2019-12-10 15:04:11
问题 I have some fairly complex requirements for a SOLR search that I need to execute against my database of tagged content. I need to first filter the database to those results matching my filter tags. Any of these results which have a tag from the blacklist should be removed unless they also contain tags from the whitelist. So let's say I want to retrieve all documents tagged "forest" or "conservation". But I want to exclude documents tagged "uk" or "europe" - unless they are also tagged with

C# code only gives expected results on step through?

北城以北 提交于 2019-12-10 14:54:39
问题 Ok so I have a dice throw app... When I step through the code it functions normally and 'results' contains the correct number of throw results and they appear to be random, when I leave the code to run and do exactly the same thing it produces a set of identical numbers. I'm sure this is a logical error I cannot see but fiddling with it for hours hasnt improved the situation, so any help is much appriciated. :) class Dice { public int[] Roll(int _throws, int _sides, int _count) { Random rnd =

Integer division using only addition, multiplication, subtraction and maximum

China☆狼群 提交于 2019-12-10 13:47:59
问题 Suppose we have a programming language ℤ which has the following syntax: ℤ := 0 | 1 | (+ ℤ ℤ) | (* ℤ ℤ) | (- ℤ ℤ) | (max ℤ ℤ) For convenience, we can define new binding forms in our language as follows: (not x) = (- 1 x) (abs x) = (- (max 0 (+ x x)) x) (min x y) = (- 0 (max (- 0 x) (- 0 y))) (nil x) = (not (min 1 (abs x))) This language is powerful enough to express branching and comparison operators: (if x y z) = (+ (* x y) (* (not x) z)) (eq x y) = (nil (- x y)) (ne x y) = (not (eq x y))

How does the arithmetic logic unit actually works? [closed]

牧云@^-^@ 提交于 2019-12-10 13:46:58
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . In other words, how can energy combined with metal perform logic operations? In the research I've done i'ts always assumed how the 'magic' happens but usually there's a lack of explanation on how can a physical device can 'understand' and perform processes of logical nature. I think would be a good approach to

AI: Partial Unification in Open-World Reference Resolution

做~自己de王妃 提交于 2019-12-10 10:59:22
问题 When performing reference resolution on predicates describing the semantics of dialogue expressions, I need to be able to allow for partial unification due to working in an open world. For example, consider the following scenario: There is a blue box in front of you. We refer to this blue box using the id 3 . A set of predicates box(x)^blue(x) can easily resolve to the blue box you know about. Making this query will return 3 A set of predicates ball(x)^yellow(x) will not resolve to anything.

VBA If <any of these> = <value>?

扶醉桌前 提交于 2019-12-10 02:24:56
问题 I'm fairly new to VBA, and I can't find an easy way to test if any of the specified variables equal a specified value. The below seems to work, but is there an easier way to do it? If variable1 = 1 Or variable2 = 1 Or variable3 = 1 Or variable4 = 1 Or variable5 = 1 Then End If I've also tried the following, with no luck. If (variable1 Or variable2 Or variable3 Or variable4 Or variable5) = 1 Then End If 回答1: You can use select case :) Sub Sample() Dim variable1, variable2, variable3, variable4

C# & operator clarification

天大地大妈咪最大 提交于 2019-12-10 01:45:39
问题 I saw a couple of questions here about the diference between && and & operators in C#, but I am still confused how it is used, and what outcome results in different situations. For example I just glimpsed the following code in a project bMyBoolean = Convert.ToBoolean(nMyInt & 1); bMyBoolean = Convert.ToBoolean(nMyInt & 2); When it will result 0 and when >0? What is the logic behind this operator? What are the diferences between the operator '|'? bMyBoolean = Convert.ToBoolean(nMyInt | 1);

Alternative to bitwise operation

旧巷老猫 提交于 2019-12-09 21:49:37
问题 Scenario : I have say 4 check boxes and users can select those checkboxes in any combination(they also have the power to not select even a single check box). I have to store these 4 options to a single column. I think the best option is to store using binary representation option1 has the constant value 1 option2 has the constant value 2 option3 has the constant value 4 option4 has the constant value 8 So if the customer selects option2 and option4, then the value that is stored in the DB

Truth Tables from Anonymous Functions in Haskell

馋奶兔 提交于 2019-12-09 17:29:14
问题 I'm trying to generate a truth table for a given boolean expression. I could do this with creating a new Datatype BoolExpr, but I want to do it with an anonymous function. It's supposed to work like this: > tTable (\x y -> not (x || y)) output: F F | T F T | F T F | F T T | F My approach: tbl p = [(uncurry p) tuple | tuple <- allval] where allval=[(x,y) | x <- [False,True], y <- [False,True]] This works, but only for 2 Arguments. I want to do it for any number of Arguments. So I figured I

How could I implement logical implication with bitwise or other efficient code in C?

久未见 提交于 2019-12-09 15:48:41
问题 I want to implement a logical operation that works as efficient as possible. I need this truth table: p q p → q T T T T F F F T T F F T This, according to wikipedia is called "logical implication" I've been long trying to figure out how to make this with bitwise operations in C without using conditionals. Maybe someone has got some thoughts about it. Thanks 回答1: FYI, with gcc-4.3.3: int foo(int a, int b) { return !a || b; } int bar(int a, int b) { return ~a | b; } Gives (from objdump -d):