Questions tagged [boolean-logic]

An algebraic system developed by George Boole. Uses operations such as "And", "Or" and "Not" on Binary True/False values. It may be used to accomplish complex tasks.

Boolean logic is a two-element boolean algebra, a formalism that gives algebraic semantics for classical propositional logic.

1775 questions
0
votes
1 answer

C#: Assign test result directly to variable

Is it possible to assign the result of a test directly to a variable? I want to do something like c = ( a == b ) instead of if ( a == b ) { c = true; } else { c = false; } Is this possible?
Marco Frost
  • 780
  • 3
  • 12
  • 25
0
votes
1 answer

Rails - do a logic operation on each row of an activerecord result

I have a model that has a column of type Boolean. It's possible to retrieve "on the fly" (without iterating all the result) the result of a logic calculus? For example: data = Model.limit(10) # I would like to know if each data.column is true # the…
damoiser
  • 6,058
  • 3
  • 40
  • 66
0
votes
2 answers

Jquery: create a javascript method called 'containsBlanks' that returns true if any inputs with class 'required' has an empty string in, false if not

I can't seem to quite figure this one out; not sure if I'm even providing a test condition; Also, "blanks" variable is to hold the value of the elements with the".required" class during the loop. function containsBlanks(){ var blanks = new…
0
votes
2 answers

Python nested lists and recursion problem

I posted this question under an alter yesterday not realising my account was still active after 9 months, sorry for the double post, i've fixed an error in my example pointed out by jellybean and i'll elaborate further on the context of the…
FlyingToaster
  • 19
  • 1
  • 3
0
votes
2 answers

Lucene Solr using complex filters

I am currently having a problem with specifying filters for Lucene/Solr. Every solution I come up with breaks other solutions. Let me start with an example. Assume that we have the following 5 documents: doc1 = [type:Car, sold:false,…
Ammar
  • 5,070
  • 8
  • 28
  • 27
0
votes
2 answers

Logic operators in JS. What do they mean?

I found some piece of code which contains following loop: for (var i = 0; i < 3; i++) { tabMap['tab' + i] = { element : null }; i && (tabMap['tab' + i].left = 'tab' + (i - 1)); //?? i < 2 && (tabMap['tab' + i].right = 'tab' + (i + 1));…
sunpietro
  • 2,059
  • 4
  • 24
  • 42
0
votes
1 answer

How does boolean "&" and "&&" works for bit comparison?

PORTB = 0b11001011; PORTC = 0b00111011; if(PORTB & PORTC) { //do something } //will this "if" comes out to be true?how compiler will check it? PORTB = 0b11001011; PORTC = 0b00111011; if(PORTB && PORTC) { //do something …
shafeeq
  • 141
  • 1
  • 3
  • 14
0
votes
1 answer

Javascript create a function that returns a boolean value based on certain parameters

Thanks for taking the time to look at my problem. What I'm trying to do is create a javascript function that tests whether a sting is a particular length and also whether each element of that string can be found in another string. The function then…
user2430969
  • 1
  • 1
  • 1
0
votes
1 answer

Is it beneficial to include implicit constraints when computing boolean satisfiability?

Let's say you have a boolean function that takes two numbers (in binary) and returns true if they equal sixteen: 01000 + 01000 = 10000 8 + 8 = 16 -> true 00110 + 01000 = 01110 6 + 8 = 14 -> false In this example, the…
Chris
  • 1,501
  • 17
  • 32
0
votes
0 answers

Does order of parameters in logical operators matters equality?

I am constructing a class that will contain a logical expression: public enum LogicalOperator { And, Or }; public class LogicalExpression { public LogicalOperator Operator { get; private set; } public List Expressions { get; private…
kseen
  • 359
  • 8
  • 56
  • 104
0
votes
3 answers

Excel 2010: Inserting AND operator into function that returns true if referenced cell has value

As best I can tell, IF([cell],TRUE,FALSE) is always returning TRUE if [cell] contains a value, but I can't find any documentation on this sort of truth-value test in Excel 2010. I don't know what it's called, and all the documentation I can find…
Chris
  • 19
  • 8
0
votes
0 answers

Is there a system for realizing digital logic functions without branches?

I was going to ask this on Electric Engineering, but decided it's more related to programming. With digital logic, we can reduce truth tables to minimized functions using Karnaugh diagrams or Boolean algebra. On a CPU, these functions can of…
Toerndev
  • 715
  • 1
  • 6
  • 21
0
votes
2 answers

Language: Python(vers3.3); If statements inside while and if statements

My program is unable to go into the last of my if/else statement. My code: def main_prog(): while True: data_dict = {'123': 'viksun', '111': ['tord'], '333': ['test']} # Data storage. print (data_dict) # Track-print …
0
votes
1 answer

Logical error in my Python program?

I am attempting to write a simple program that will simulate a number of rock paper scissors games, and return the number of wins each item has, based on a number of games the user puts in to simulate. However, it only prints out the number of…
DanielAden
  • 133
  • 1
  • 4
  • 11
0
votes
1 answer

Boolean Logic & gate delays

Assuming 2 gate-delays for a Sum or Carry function, estimate the time for ripple-through carry addition for adders with the following word lengths:- i) 4-bit ii) 8-bit iii) 16-bit In my notes I have written: "delay is the word width times each bit…
Joe Austin
  • 557
  • 7
  • 24
1 2 3
99
100