Questions tagged [conditional-statements]

"In computer science, conditional statements, conditional expressions and conditional constructs are features of a programming language which perform different computations or actions depending on whether a programmer-specified boolean condition evaluates to true or false. Apart from the case of branch prediction, this is always achieved by selectively altering the control flow based on some condition." -- Wikipedia

Read on Wikipedia

19093 questions
4
votes
2 answers

matlab conditioned matrix assignment

i have a question about matrix assignment. say i have three matrices A, B and C, and i want to assign the elements of matrix C to the elements of A and B according to the rule C[i,j] = A[i,j] if abs(C[i,j] - A[i,j]) < abs(C[i,j] - B[i,j]) …
nos
  • 19,875
  • 27
  • 98
  • 134
4
votes
2 answers

stop and split generated sequence at repeats - clojure

I am trying to make a sequence that will only generate values until it finds the following conditions and return the listed results: case head = 0 - return {:origin [all generated except 0] :pattern 0} 1 - return {:origin nil :pattern…
user945754
4
votes
2 answers

Ternary statement with multiple arguments

I have a dictionary defined as: Dictionary typeLookup = new Dictionary(); I want to add a key/value to the dictionary based on what language the user has selected, which in my case is found with:…
CptSupermrkt
  • 6,844
  • 12
  • 56
  • 87
4
votes
3 answers

Assigning values in a sequence to a group of consecutive rows leaving some rows empty

I'm trying to group several consecutives rows (and assigning them the same value) while leaving some of the rows empty (when a certain condition is not fulfilled). My data are locations (xy coordinates), the date/time at which they were measured,…
sblazquez
  • 41
  • 2
4
votes
4 answers

Alternative for multiple if statements

My code contains a lot of multiple if statements. Is there any other way to get rid of these statements. For example suppose I have the following conditions if(t1 >= 1 && t2 == 0 && t3 == 0) $('div.b_class').fadeIn(); if(t1 == 0 && t2 >= 1 && t3 ==…
Alonso
  • 251
  • 2
  • 7
  • 11
4
votes
2 answers

SEO friendly conditional loading using javascript

I am planning to make a responsive+mobile first web design. So here is my plan: Making a mobile first website. Using Javascript to load desktop or big screen HTML However, I have a problem here. From my knowledge, the HTML content which I will…
Umair Cheema
  • 403
  • 2
  • 6
  • 14
4
votes
1 answer

Drupal db_select(), how can I use two db field in condition?

I have a problem with a drupal db_select. Here is my code : $query = db_select('node', 'n'); $query->addField('n', 'nid', 'nid'); $query->addField('cfs', 'entity_id', 'feature_support_id'); $query->addField('fpffs', 'entity_id',…
yburon
  • 151
  • 2
  • 11
4
votes
5 answers

What happens when you compare two of the same type objects using ==, >, <, etc, in Java?

Possible Duplicate: Difference Between Equals and == For example, if I have MyClass foo = new MyClass(); MyClass bar = new MyClass(); if (foo == bar) { // do something } if (foo < bar) { // do something } if (foo > bar) { // do…
trusktr
  • 44,284
  • 53
  • 191
  • 263
4
votes
2 answers

Magento Have terms and conditions if customer buys certain products

I would like to display the terms and conditions (agreements.phtml) only if the customer purchases certain products. For example, some of our products require a prescription. It a customer purchases one of these, we would like the terms to…
user1694820
  • 43
  • 1
  • 3
4
votes
2 answers

How to test using conditional defines if the application is Firemonkey one?

I use DUnit. It has an VCL GUITestRunner and a console TextTestRunner. In an unit used by both Firemonkey and VCL Forms applications I would like to achieve the following: If Firemonkey app, if target is OS X, and executing on OS X ->…
Gad D Lord
  • 6,620
  • 12
  • 60
  • 106
4
votes
1 answer

SSIS Conditional Split NULL

I need to detect whether either of two values are null, and if not, whether they differ. The condition I have in my split is (ISNULL(ModuleLevelId) && !ISNULL(LEV_CODE)) || (!ISNULL(ModuleLevelId) && ISNULL(LEV_CODE)) || (ISNULL(LEV_CODE) ? 0 -…
pwmusic
  • 4,739
  • 4
  • 23
  • 14
4
votes
2 answers

Performance of conditional join

I have a question about perf of the following query: DECLARE @detail_level INT = 1, @DETAIL_1 INT = 1, @DETAIL_2 INT = 2, @DETAIL_3 INT = 4 SELECT mtbl.*, CASE WHEN @detail_level & @DETAIL_1 <> 0…
4
votes
2 answers

How to conditionally select which table and column on a per row basis?

In the returned results on a query to a 'Links' table I want to also add an extra column that shows a 'DisplayName' value that is selected from a JOIN conditional on the value of the 'toTable' per row. In addition sometimes that 'DisplayName' value…
johowie
  • 2,475
  • 6
  • 26
  • 42
4
votes
2 answers

Stop code until a condition is met

How can you create a function or component etc that will stop all running code until a condition is met? For example the same way as a JOptionPane will do, if I have this for example: JOptionPane.showInputDialog(null, "Hello", "Title", 1); Within…
zeddex
  • 1,260
  • 5
  • 21
  • 38
1 2 3
99
100