Questions tagged [logic]

Logic refers to the ultimate flow of your code and how you arrive your desired solution. Questions should relate to finding a coding solution (or improving existing coding logic) to a given problem. Please use with an appropriate language tag, a thorough description of your logic, and the relevant code you're working on. General logic questions are off-topic. If you simply need a code review, consider https://codereview.stackexchange.com

Note that the bulk of questions tagged concern the broad sense of program logic described in the excerpt above. Before using the tag, consider if a tag about a more specialised logic-related topic would be a better fit. Examples include:

Furthermore, if your question is about one of those specialised topics, consider whether it essentially involves programming in some way. If it doesn't, it will likely be more appropriately posted elsewhere in the network. Some sites in which such questions might be a good fit, depending on the circumstances of each concrete case, are Philosophy, Mathematics and Computer Science.

9357 questions
2
votes
3 answers

De Morgan Law in Python 3

According to De Morgan law: ¬(P ˄ Q) ↔ (¬P) ˅ (¬Q) ¬(P ˅ Q) ↔ (¬P) ˄ (¬Q) In Python 3.5 when I run: A = True B = True x = not(A and B)==(not A) or (not B) y = not(A or B)==(not A) and (not B) print('x is :', x, '\ny is :' ,y) This returns: x is :…
KitKat
  • 161
  • 2
  • 10
2
votes
2 answers

R within() order of operation and logic

I am trying to understand how the within() function in R "works." For example, in the code below I try to make a new variable named "FEELS" based on a condition. The first two uses of the within() function do not work. The third use of the…
user1491868
  • 596
  • 4
  • 15
  • 42
2
votes
2 answers

How could I encode "implies" logic in LogicBlox?

I would like to encode "implies" logic in LogicBlox. I have a predicate: Number(n),hasNumberName(n:i)->int(i). isTrue[n] = i -> Number(n), boolean(i). And I add some data in that predicate: +Number(1). Now, I want to create number 2 and number 3,…
jitron
  • 135
  • 1
  • 9
2
votes
1 answer

Which example for a do-while loop?

Inside of a do-while loop and if else statements is it in best interest for at the end of your statements you change a variables value and use that to create your while boolean expression, or is it best to set your while expression to always being…
Augie Luebbers
  • 308
  • 1
  • 2
  • 15
2
votes
1 answer

Dimension security OLAP. Again

There is a fact table. This fact table is viewed by two types of users. Each role has access to different dimension: Role A is allowed to see values for specific set of customers (c1, c2). Role B is allowed to see values for specific set of…
barzozwierz
  • 148
  • 2
  • 9
2
votes
1 answer

Making K-maps with S2, S1, S0 (seven states), one button input, and four outputs

So my state diagram has seven states (000 to 110), an input B button, and four outputs P, Q, R, and S. I've made the truth table, which has 16 rows (two of which have Xs). I'm supposed to make 7 K-Maps out of this, S2' S1' S0' P Q R and S. I…
sumitz1212
  • 63
  • 4
  • 10
2
votes
4 answers

How can I set the value of textbox to "0" if blank or empty?

I'm trying to have a textbox, which if blank or empty, will have the number zero inserted into it once a button is clicked. So far I've been trying this code, below, to no avail. The code below is for the button_click method. What am I missing? if…
Kayla
  • 165
  • 2
  • 4
  • 13
2
votes
4 answers

How can I do something only for the first function call?

I am losing data from array with the code below: private function addIndexKey($parent) { $myKeys = array(); foreach ($parent->children as $child) { $pos = $child->varGet('flow_pos'); if (!isset($pos)) $pos = $child->position; if…
Shaonline
  • 1,597
  • 6
  • 18
  • 36
2
votes
1 answer

Defining more efficient logic for given scenario

Got some interesting logic that I am trying to encode in the most efficient and readable way possible. I will lay out the scneario below (with a simulated/dummy context) I have a data store of banks and their teller reviews (1-5 int field). A teller…
John Baum
  • 3,183
  • 11
  • 42
  • 90
2
votes
1 answer

How to infer state of unknown variables given that you know something changed?

There exists a game, whose state is quantified by n boolean variables p_1, p_2, ..., p_n. Assume 0 <= n <= 10. The purpose of the game is to keep track of the state of as many variables as possible, and when they will change states (see below). Only…
Chris Hunt
  • 3,840
  • 3
  • 30
  • 46
2
votes
4 answers

Create a command line star rating with full and half stars from a float? Python 3

So I'm working on a command line app that gets hotel details and one of these details is their "star rating". I could just list out the string that I get it as, but that's no fun, and I want the app to really look nice. So I wanted to create the…
Graham S.
  • 1,480
  • 1
  • 20
  • 28
2
votes
1 answer

Logical AND in Clojure

Is Clojure's logical and different from the normal logical and (&&)? Why does this yield true ((and odd? #(> 10 %)) 6) Doesn't and need 2 true statements to return true?
user4813927
2
votes
1 answer

Using multiplication instead of logical AND

Is there any reason why using multiplication instead of logical AND operator would be preferred or discouraged (using any programming language)? Example below shows that it could make the code simpler, but are there any other advantages (or…
Tim
  • 7,075
  • 6
  • 29
  • 58
2
votes
3 answers

Large binary shifts in 8086 assembly?

I have a binary chunk of data 512 bytes long, I was wondering what the most efficient way would be if I wanted to shift it once to the right. My best guess right now (very new to assembly) would be that I would have to first check a chunk (probably…
Corey Ogburn
  • 24,072
  • 31
  • 113
  • 188
2
votes
0 answers

Font awesome icons do not load sometimes

In my web site, 'sometimes' the font awesome icons are not loading. It shows only as squares. When I googled I found out that to change the .htaccess file in the server. But my web site is hosted in weblogic server. Is there any equivalent to…
Amila Fonseka
  • 392
  • 1
  • 5
  • 15
1 2 3
99
100