Questions tagged [boolean-expression]
A boolean expression is an expression in a programming language that produces a boolean value when evaluated, i.e. one of true or false.
987
questions
0
votes
1
answer
27
views
How to linearize boolean expressionfor linear program
I am trying to put a boolean expression into a linear program:
¬A ∧ B => C
but I am not sure how to do so.
I was thinking about the following equation:
0 <= (1-A) + B - 2* C <= 1
But ...
0
votes
1
answer
23
views
Built in ema function in boolean expression
I came across this expression.
longExit() => ema(close, 80) and rsi(close, 2) >= 80
I assume this is a function definition which returns a boolean. When does the first node (ema(close, 80)) ...
0
votes
1
answer
37
views
defining a function that contains match and case in python
I want to define a function called sleep_in(weekday, vacation). The parameter weekday is True if it is a weekday, and the parameter vacation is True if we are on vacation. We sleep in if it is not a ...
-1
votes
0
answers
27
views
What is Exclusive-Sum-Of-Product (ESOP)?
As far as I understand, Sum-Of-Product is basically different products (logical operator AND) of Boolean inputs which are then summed (logical operator OR) together. My question is what is Exclusive-...
-1
votes
1
answer
20
views
Boolean Algebra expression won't simplify consistently?
I got this question on one of my exams recently and it's been annoying me ever since.
¬¬(A.B).¬B + ¬¬¬C
on the exam I put that
A.B.¬B + ¬C = 0 + ¬C = ¬C and left it there, and some of the online ...
0
votes
0
answers
24
views
Is there a shorter, smarter way to deal with a long list of conditions in an if statement? [duplicate]
For example: I have a grid where each square is identified by a value denoting row and column, eg: 32 is in the 3rd column and 2nd row. Nearby locations would be squares 31, 33, 41, 42, 43, 21, 22, 23....
0
votes
1
answer
19
views
Truth table of f(x1,x2,x3,x4) function from given two (4-1) multiplexers
Given two (4-1) multiplexers
How can I get the truth table of f(x1,x2,x3,x4) function??
1
vote
1
answer
19
views
How do I explain boolean into English?
I have a question
that deals with Booleans and || or. I was able to write this program correctly, but I am having trouble putting into English why when you have both inputs as false, the answer is ...
-2
votes
0
answers
16
views
Reducing A'B+(ABC)'+C(B'+A) with boolean algebra [migrated]
what are the possible way to reduce this equation with boolean algebra
A'B+(ABC)'+C(B'+A)
0
votes
2
answers
48
views
Shannon expansion in a boolean function
According to this page in Wikipedia (https://en.wikipedia.org/wiki/Boole%27s_expansion_theorem) The Shannon expansion or decomposition theorem, also known as Boole's expansion theorem is an identity ...
0
votes
1
answer
30
views
What is the Most Rly Way for Lazy Conditional Evaluation
The case. I have a part of code like this: if (exists("mybooleanvar") & mybooleanvar) {statement1} else {statement2}. I expect that if the conditions are lazily (short-circuit) evaluated ...
1
vote
1
answer
26
views
CS50's Introduction to Artificial Intelligence with Python - Knowledge
I'm studyng Harvard's Introduction to Artificial Intelligence with Python course. I'm enjoying a lot. However I downloaded logic file to use Boolean algebra and Knowledge, that simple operations (OR,...
0
votes
0
answers
25
views
How to find minimum number of NAND gates for a given Boolean Expression by Using Genetic Alogorith(How to write a Code )
I have been trying to write a code using gentic algorithm to find minimum number of NAND gates,but i have no idea of how to take a chromosome or case to find nand gates,and how to find fitness value ...
-1
votes
1
answer
35
views
Using numpy.where() to compare numbers in an array to an interval
I have an array of numbers:
my_arr = np.array([n, n+1, n+2 ... , m-1, m]
I want to create an array of Booleans which indicate which numbers are in some (closed) interval, [A,B], to operate on some ...
0
votes
1
answer
48
views
Checking for Whether Both Expression Strings Contain the Variable
I had made a fully functioning method that would grab a variable string like x or var for the equation as so:
// Equation Variable Getter
public String getVar(){
String variable = "&...
1
vote
5
answers
71
views
Why is this 2D array filtering not working?
I have this 2D array and I'm trying to filter it, but it's coming out unfiltered:
Data:
[
["Val #","Val #","Val #","Val #","Val #"],
["SO-...
1
vote
2
answers
62
views
Test two boolean values with AND operator in Perl
I want to test two boolean values in Perl.
In case both are 0 do x, in case not do y.
For example:
$var1 = 0; false in Perl
$var2 = 0; false in Perl
if($var1==0 && var2==0)
{
x //both are ...
0
votes
2
answers
73
views
Short Circuit Boolean operators in C (again): doesn't it produce inefficient code by default?
I know that the topic "short circuit operators" has been discussed a lot here on StackExchange. But w.r.t specifically the 'C' language, there is an aspect that bothers me for quite a while.
...
1
vote
0
answers
19
views
Boolean Expression Error - If Statement - The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
I have a DataFrame with headers for 'City', 'State' and 'Country'. My goal is to clean up the state and country columns and have all states displayed with their proper abbreviation (ex: 'New York' == '...
-4
votes
4
answers
120
views
Else statement and while loop [closed]
Code skips the error if statements and goes straight to the else if
I need laps to go through and if its less than 2 then it'll go to the error and come back again to ask to enter a new value. vice ...
0
votes
0
answers
118
views
pinescript boolean variable has an integer value
I've got this pinescript code I'm trying to translate to python but for some reason the boolean variable has an integer value? or an integer -like syntax? would appericate any form of help
code:
a = ...
0
votes
2
answers
172
views
Boolean statement that prints 'true' if numbers are odd within a given range?
I need to write out a boolean statement that prints 'true' if the number entered (using scanner input) is...
within a range of 1 to 100 but NOT an even number within the range 40 to 50.
As in, if ...
0
votes
0
answers
71
views
How to convert the Boolean expression to Standard SoP form using Boolean Algebra based on given example?
How to convert the given Boolean expression to Standard SoP form using Boolean Algebra? Please show the calculation because I got confused
Z= AB’+C
0
votes
1
answer
71
views
Generating DIMACS CNF file using bc2cnf is missing AND
I tried using the bc2cnf tool to generate the DIMACS CNF file of a boolean equation.
The input file contains the equation of an AND gate as shown below :
BC1.1
f := A & B;
ASSIGN f;
Command used: ...
-2
votes
1
answer
114
views
Evaluating boolean expressions in Java dynamically
I made use of JEP earlier and then realised that it wont fit my case.
On a call to the database/backend, I get a json response, which has a structure as below:
"key": {
"!A & B"...
-3
votes
1
answer
61
views
Leetcode SQL 1440. Evaluate Boolean Expression
Table Variables:
Column Name
Type
name
varchar
value
int
name is the primary key for this table.
This table contains the stored variables and their values.
Table Expressions:
Column Name
Type
...
1
vote
3
answers
94
views
Can someone explain this JavaScript code please?
I am fairly beginner to JavaScript development and I would be obliged if someone could help explain this code to me.
m = function () {
let t = e.getCookie("cli-analytics"),
a = e....
0
votes
2
answers
42
views
Create new data frame columns with return in function
In the DataFrame below, I need to check the shop column and add two columns based on shop
datetime
dtnum
time
tnum
shop
02-03-2022 05:25
20220302052500
05:25:00
52500
PRESS1
02-03-2022 05:26
...
-4
votes
2
answers
47
views
Condition in a if-else-if statement does not work as expected [duplicate]
#include <stdio.h>
int main () {
float x = 30;
if (x < 9) {
printf("A");
} else if (10 <= x <= 20) {
printf("B");
} else if (21 <= x <= 29.9)...
0
votes
0
answers
22
views
Is there a way in sagemath's BooleanPolynomialRing Change the value in the boolean function through the variable in the list
when we can not determine which variable will be determine by a constant,i use a list use a list to store variables ,but the BooleanPolynomialRing do not support change the BooleanPolynomial by ...
2
votes
2
answers
44
views
I do not understand how this JS code is working; how are these two lines being returned?
let specificSuffix = function(words, suffix) {
if (!Array.isArray(words)) {
return [];
}
return words.filter(function(word) {
return word.endsWith(suffix)
});
}
console.log(...
1
vote
1
answer
28
views
Boolean function for binary shift with a variable amount
How can I construct a Boolean function for a binary shift operation by a variable amount?
I looked that there are possibilities using and and or operators Binary Shifters using Logic Gates. But my ...
0
votes
3
answers
82
views
How to make a simple Boolean condition
What am I doing wrong with my code?
I'm trying to get it so when I run happy_home it comes out true when there is at least one cat and no dogs.
cat_count = 2
dog_count = 0
if cat_count > 0:
...
0
votes
1
answer
125
views
R. Display only TRUE values from a boolean expression?
Data science student here. New to R, in my first course. I've spent way too much time trying to figure out this exercise, so I figured I would ask someone on here.
I have created a dataframe built ...
2
votes
0
answers
46
views
The wonder of Boolean in python [duplicate]
The question is simple
>>> bull = False in [False] #Assigning value
>>> False == False in [False] #Note: Comparision is True
True
>>> False == bull #Que: Why not True?
False
...
3
votes
2
answers
104
views
Perl list in boolean (scalar) context in while loop
I'm staring at this code in perl LWP::Protocol.pm and I don't understand how the loop would ever exit:
while ($content = &$collector, length $$content) {
$content_size += length($$content);
...
4
votes
2
answers
81
views
Count conditions within each row in Pandas Dataframe
I have this dataframe:
Char1 Char2 Char3
0 2 2 3
1 2 3 3
2 2 3 3
3 2 2 2
I need to create three columns (_1, _2, _3), each of which ...
-1
votes
2
answers
43
views
How do I create a simplified logic circuit of this given [(A’B’)’ + (A’+ B’)’]’ ? and What is the simplified Boolean expression?
I have to draw the simplified logic circuit of this given [(A’B’)’ + (A’+ B’)’]’ and also get the simplified boolean expression
0
votes
1
answer
71
views
boolean expression evaluation in C++ [duplicate]
Say I have this C++ code (it's from a binary tree problem)
if(t->left != nullptr && t->left->data != t->data)
Isn't it problematic since I try to access possibly a nullpointer's ...
1
vote
1
answer
49
views
Boolean operation to combine the booleans in an input and a trigger
Here is some sample data with an "input" column and a "trigger" column. The "input" column is generally False but has True segments (e.g. one True segment in the sample ...
1
vote
1
answer
30
views
Distributivity of 'must' over 'should' in elasticsearch queries
I felt puzzled by this behavior while querying my index.
Whether you interpret it in a boolean fashion or as sets (OR being a union and AND being an intersection), I take for granted that X AND (Y OR ...
0
votes
0
answers
124
views
C++/C check and toggle a bool in single instruction
I am looking for a way in C++ bool type (or possibly C int), that checking (if statement) and editing the bool in a single instruction. Google search got me nowhere, maybe I am using wrong keywords.
...
-2
votes
1
answer
88
views
Boolean algebra how to complete missing expressions
For example, AB + AB' = A and ABC + ABC' = AB. When the user enters AB, how can I find the missing letter and give it the form it was before it was simplified? In fact, what we need to do is multiply ...
2
votes
1
answer
63
views
How to compare a value to a list of pairs in a list comprehension?
I need to create a list that is n long where each item is a Boolean. The item will only be True when x is in the range of one or more pairs of integers. For example, my current code is as follows:
l = ...
0
votes
1
answer
210
views
Python: condition to check that none of list's element is an empty list
I have a list of listA; each element of A is a list.
I want a condition (to use for a if statement) that return True if all the element of A are non empty and False otherwise.
How can I express this ...
0
votes
1
answer
413
views
Validating ID Number C#
I am working on this method that validates a student Id number. The credentials of the ID number are; the first character has to be 9, the second character has to be a 0, there can not be any letters, ...
-2
votes
1
answer
56
views
how this Ternary Operator work with this statemnt?
i just generate this methode to find max val in some matrix and somehowe i was able to change int val insdie Ternary Operator (java 8)
int max=0, indexToReturn=0;
int size= arr[0].length;
...
1
vote
1
answer
246
views
Why does ($false || $true) evaluate to False in Powershell 7+?
In Powershell 7.2 Write-Output ($false || $true) will output False. Why?
2
votes
1
answer
147
views
Why can't brackets in a simplified Boolean expression be separated by an AND?
Consider this map of (A ∧ D) ∨ (B ∧ D) ∨ (A ∧ ¬B ∧ C ∧ D):
The map is grouped into two sections, both of four squares.
Thus producing the simplified expression of (B ∧ D) ∨ (A ∧ D) as shown below.
...
0
votes
1
answer
53
views
Why is this boolean expression false?
When I run
boolean a = false;
boolean b = false;
boolean result = (a && (b || !a)) == a && b;
System.out.println(result);
I get false in Java. Why? This is equivalent to false == ...