if-statement

R - How to turn a loop to a function in R

Thank you for your reading. I often find that I need to apply a function to slices of my data, and then bind the outputs. I usually build a loop for that purpose, but I am sure I am doing it wrong, and that in R I should be using a different way of thinking. Can you please help me learn a better way to do this? With thanks, adam r...

Generator in if-statement in python

Or How to if-statement in a modified list. I've been reading StackOverflow for a while (thanks to everyone). I love it. I also seen that you can post a question and answer it yourself. Sorry if I duplicate, but I didn't found this particular answer on StackOverflow. How do you verify if a element is in a list but modify it in the sa...

Change color of text in UITableViewCell based on the text

I'm trying to change the text of a custom UITableViewCell based on whether the text says Closed or not. However, when the text is Closed, the color will not change. Here is a code snippet. http://pastie.org/1078690 Thanks. ...

javascript If statement, looking through an array

Mind has gone blank this afternoon and cant for the life of me figure out the right way to do this: if(i!="3" && i!="4" && i!="5" && i!="6" && i!="7" && i!="8" && i!="9" && i!="2" && i!="19" && i!="18" && i!="60" && i!="61" && i!="50" && i!="49" && i!="79" && i!="78" && i!="81" && i!="82" && i!="80" && i!="70" && i!="90" && i!="91" && i...

advanced cfif statement

How would I create this statement in CF? <cfif (not isdefined("URL.room") or #URL.room# EQ "") and (not isdefined("URL.system" or #URL.system# EQ "") and (not isdefined("URL.date") or #URL.date# EQ "")> Obviously the parentheses don't work, but illustrate what I am trying to accomplish. What is the syntax for this? EDIT: ...

How to get Soundfilenames from an NSArray and play?

Hello, I want to play several audiofiles (*.wav) by touching the appropriate UImageViews. Each touching an UIImageView changes an "triggernumber" - wich view is selected. The audiofile names are stored in an array. But I can't figure out how to write a method to get the names and play the right sounds without using a select case method w...

Check that no variables have been passed

I have one file index.php, I am trying to include splash.php when no variable is passed and display.php when any variable is passed. This is what i have so far but i want to make it universal for all variables instead of just "query". if (!isset($_REQUEST['query'])) { include("splash.php"); } else { include("display.php"); } ...

what's faster - the if statement or a call of a function?

hi, i'm writing an interesting program, and every performance hit is very painful for me. so i'm wondering what is better - to make an extra "if" statement to reduce a number of function calls, or to avoid those "if" adn get more funciton calls. the function is virtual method, that overrides IEqualityComparer's method Equals, all it does...

Looking to write a 4-way temperature converter objective-c console program

As some of you may have seen me experimenting with a program converting from Fahrenheit to Celsius and visa versa in Objective-C based off of console input and output. I'm just doing this to better learn the language and I think its a good way to demonstrate some of the things I've been exposed to. So, anyway, I am looking to incorpora...

if loop: x not in VS not x in

This is a strange question but here goes: I've noticed that both of these work the same: if x not in list and if not x in list. Is there some sort of difference between the two in certain cases? Is there a reason for having both, or is it just because it's more natural for some people to write one or the other. Which one am I more ...

validating json string using javascript...

I have this json string {"Table" : [{"subject" : "No Records are there to Display"}]}. If i receive this data i want to alert NO Records Found. Any suggestion. Note: My key field may vary accordingly (ie) here it is Subject and some more like Details,Description. ...

Updating every row in a table with IF Statement conditions

Hi everyone, this one has me stuck fast. Data: Month Total Impact Forecast ------------------------------------------------ 2010-04-01 45792.0000 1.0000 NULL 2010-05-01 51789.0000 1.0000 NULL 2010-06-01 58228.0000 1.0000 NULL 2010-07-01 52956.5217 1.0000 NULL 2010-08-01 53600....

JavaScript If statement condition with no operator? What does it do?

I am used to if statements having a condition where ( x < y ) or ( x == y ). But in cases where there is no operator, what does the if statement check exactly? i.e. in the example below if (window.XMLHttpRequest)... what's the condition? Thanks. if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new ...

jQuery if statement for finding element ID

I have a group of tabs that have hidden content which display when the tab is clicked. The jQuery looks like this: jQuery(document).ready(function($){ var sections = $('.section').hide(); $('.tablink').click(function(e){ e.preventDefault(); sections.hide(); $($(this).attr('href')).show(); $(this).clos...

Using variables to check for error condition in Javascript

Hi all, I have a personal simple jQuery validation script. It works when the submit button is clicked and sets up a variable: $errors = false; Then there are series of if statements that check for textbox values and conditions, and if conditions are not met, variable $errors is set to true. The script works except for one thing. If a...

Why does VS think this statement is always true?

Hi I have this if statement - if (!((main.property == 1)||(main.property == 2))) { ... } main.property is a byte which is either 0, 1, 2 or 98. Visual studios says that this statement is always true but I can't see why? If the property is 1 or 2 shouldn't this be false. Thank you in advance. Edit: Added code file1.cs private...

C# if statement shorthand operators (? :) results in unreachable code

Why do I get this warning in C# with Visual Studio 2010? "Unreachable expression code detected" from the following code (DateTime.Now underlined in green squiggly): public DateTime StartDate { get { DateTime dt = (DateTime)ViewState["StartDate"]; return ((dt == null) ? DateTime.Now : dt); } } ...

if else if..causing heavy load on processor

i have a code from book like this : <script type="text/javascript"> <!-- start hiding javascript var randomNo = 0; var gameOver = false; var keepPlaying = true; var guess = ""; var msg = "I'm thinking of a number between 1 to 10, can you guess it?"; var reply = ""; while ...

mysql select from one or another table

Thanks, for your help, I posted a simplified version of my problem but I really didn't understand how to apply the left join in the big one that is this: SELECT d.type, d.item , if(d.type='I', a.name, b.name) as name, if(d.type='I', c.price,0) as price, if(d.type='I',if(d.taxes='yes', (c.priceWith...

need to translate specific t-sql case in pl/sql

Can anyone tell me how to translate the following T-SQL statement: SELECT fileld1 = CASE WHEN T.option1 THEN -1 ELSE CASE WHEN T.option2 THEN 0 ELSE 1 END END FROM Table1 AS T The point is I need to validate two diff...