if-statement

Regex in Apache 'if' directive … what's wrong here?

时间秒杀一切 提交于 2020-01-13 11:33:29
问题 (A possible bug in Apache is now suspected ... see below.) Here's the statements: (Apache 2.4) <IfDefine !SERVER_TYPE> Define SERVER_TYPE prod </IfDefine> <If "${SERVER_TYPE} !~ /prod|demo|test/"> <===error here=== Error "Define 'SERVER_TYPE' is hosed'" </If> Apache complains about the IF: Cannot parse condition clause: syntax error, unexpected T_OP_NRE, expecting '(' I can guess that T_OP_NRE refers to "negated regular-expression" i.e. "!~" but I can't for the life of me figure out what's

Switch seems slower than if

自作多情 提交于 2020-01-13 07:55:11
问题 I was curious as to the speed on switch , believing that it was "very" fast, but I have a test case that seems to show a single switch is about as fast as about 4 if tests, when I expected (no solid reason) it to be as fast as 1 test. Here's the two methods I wrote to compare switch with if : public static int useSwitch(int i) { switch (i) { case 1: return 2; case 2: return 3; case 3: return 4; case 4: return 5; case 5: return 6; case 6: return 7; default: return 0; } } public static int

Check if number is divisible by 24 [closed]

我怕爱的太早我们不能终老 提交于 2020-01-12 11:10:00
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I'd like to put up a if function, that will see if the variable is dividable by 24, if it's then it does the function else not, same logic however, I want to see if the output is a perfect number, e.g if we do 24/24 that will get 1, that's a perfect number. If we do 25/24 then it'll get 1.041 which is not a

Check if number is divisible by 24 [closed]

我是研究僧i 提交于 2020-01-12 11:08:49
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I'd like to put up a if function, that will see if the variable is dividable by 24, if it's then it does the function else not, same logic however, I want to see if the output is a perfect number, e.g if we do 24/24 that will get 1, that's a perfect number. If we do 25/24 then it'll get 1.041 which is not a

Greater than less than, python

北慕城南 提交于 2020-01-12 06:59:32
问题 I am doing a ranking type thing, what happens is I compare the score to the current score and if the score is lower then the current then the player has got a high score, but when using this code here print "Score = " + str(score) + ", Compared to = " + str(array[x]) if score < array[x]: #Do stuff here But even if score is 4 and array[x] is 2 the if statement is still done? Am I doing something wrong? My understanding is that if score 4 and array[x] is 2 then 4 is greater than 2 which means

Why does … == True return False in Python 3?

一曲冷凌霜 提交于 2020-01-12 04:48:09
问题 I am learning python, but I'm a bit confused by the following result. In [41]: 1 == True Out[41]: True In [42]: if(1): ...: print('111') ...: 111 In [43]: ... == True Out[43]: False <===== why this is False while '1 == True' is True in previous sample In [44]: if (...): <==== here ... just behaves like True ...: print('...') ...: ... According to the documentation, ... has a truth value of True. But I still feel the above code a bit inconsistent. ...And something more interesting: In [48]: 2=

C++ Beginner else statement not working [closed]

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-11 14:51:35
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I'm designing a simple RPG just to get me started in C++ coding, however my else statement is not working, and I feel my code is bulkier than it should be. Could you wonderful people give me some tips on how to improve my code and how to fix the else statement. I am aware of the "System("cls")" hatred across

How to make this if statement shorter?

折月煮酒 提交于 2020-01-11 14:36:07
问题 Can I make this statement shorter? if(abc=='value1' || abc=='value2' || abc=='value3') {//do something} to make it look similar to this: if(abc=='value1' || 'value2' || 'value3'){//do something} Thanks. 回答1: You have a couple options: Leave it as it is; Use an associative array/object; Use a switch statement. The second form is not valid Javascript syntax. (2) is something like: var abcOptions = { "value1" : true, "value2" : true, "value3" : true }; if (abcOptions[abc]) { ... } (3) is: switch

C language: if() with no else(): using braces fails

时光总嘲笑我的痴心妄想 提交于 2020-01-11 14:33:09
问题 I'm confused on need for braces after IF() expression. When using IF(){...}ELSE{...} I'm used to using braces around both IF and ELSE blocks. But when I use no ELSE block it works with no braces and fails with braces: works: IF()... fails: IF(){...} Example below, this is for a microcontroller #include "simpletools.h" int main() { while(1) { print("button = %d\n", input(3)); if(input(3) == 1) //works if no braces high(14); pause(50); low(14); pause(50); } //while } // main 回答1: A single

Get value from other column based on value of a column

浪尽此生 提交于 2020-01-11 13:12:04
问题 For each row in a data frame I want to copy a value from one column to another depending on a value in third column. I tried to do it with a combined for loop and if function: ## example condition <- c("1","2","2","1","2","","3","3") SZ01 <- c("1","1","1","1","1","","1","1") SZ02 <- c("2","2","2","2","2","","2","2") SZ03 <- c("3","3","3","3","3","","3","3") df <- data.frame(cbind(condition,SZ01,SZ02,SZ03), stringsAsFactors = FALSE) df$retribution <- NULL df$special_prevention <- NULL df