conditional-statements

Matching a pattern with `match()` with extra condition

痴心易碎 提交于 2019-12-13 05:52:02
问题 Expanding on a previous question (R: gsub of exact full string with fixed = T). [With huge thanks to everyone who helped there. Special thanks to @MrFlick] I need to change "32 oz" to "32 ct" but only if extra condition "3" is met, not in any other case. exact_orig = c("oz" ,"32 oz") exact_change = c("20 oz","32 ct") exact_flag = c("1" ,"3") fixedTrue<-function(x,y) { m <- match(x, exact_orig) n <- match(y, exact_flag) x[!is.na(m) & n[!is.na(n)]]<- exact_change[m[!is.na(m)] & n[!is.na(n)]] x

How to raise or decrease a display number variable in AS3 with a condition?

泄露秘密 提交于 2019-12-13 04:22:10
问题 I've got, in my Toolbar.as class, a simple variable (4-digit number) displayed in a dynamic text box, like that : var number = 9999; useText.text = String(number); trace(number); In my puzzle class I have a condition and I would like to decrease the number if it's true. How can I do that ? For exemple, I've got, in my Puzzle.as class : if (inv.containsItem("rock")) { toolbar.useText.text = "String(number)" - 100; } But it doesn't work (I know that I have to change the "String(number)" - 100

Excel - How to COPY/MOVE Unique Value With 2 Conditions?

∥☆過路亽.° 提交于 2019-12-13 03:50:42
问题 trying 1 conditions and it's works INDEX($E$7:$E$13;SMALL(IF($H$7:$H$12="Not Paid";ROW($H$7:$H$12)-ROW($H$7)+1);1)) trying 2 conditions and not working INDEX($E$7:$E$13;SMALL(IF($H$7:$H$12="Not Paid";$G$7:$G$12="Debit";ROW($H$7:$H$12)-ROW($H$7)+1);1)) Please Help! 回答1: This works. {=INDEX($E$7:$E$13; SMALL(IF($H$7:$H$12 & $G$7:$G$12 = "Not PaidDebit"; ROW($H$7:$H$12)-ROW($H$7)+1); 1) )} 来源: https://stackoverflow.com/questions/52502464/excel-how-to-copy-move-unique-value-with-2-conditions

Select with condition

旧时模样 提交于 2019-12-13 03:44:07
问题 I need some help about select with condition, right now I'm doing this: GROUP_CONCAT( CASE WHEN glpi_tickets.users_id_lastupdater = glpi_users.id THEN CONCAT(glpi_users.firstname, ' ', glpi_users.realname) END SEPARATOR '<br>') AS last_updater I select firstname and realname when users_id_lastupdater = id I guess there is a better way to do this? 回答1: group_concat seems like overkill for this. You could just use max() : max(CASE WHEN glpi_tickets.users_id_lastupdater = glpi_users.id THEN

How to do intersection with condition in C#?

有些话、适合烂在心里 提交于 2019-12-13 03:00:02
问题 I have a question about intersection or rather collision detection with condition. I am doing a collision detection between a bar(Image) and a ball(Image). The bar can be moved up and down upon user's response on dragging the bar. The collision detection codes are as below. public bool Intersects(Rect barRectangle, Rect blueBallRectangle) { barRectangle.Intersect(blueBallRectangle); if (barRectangle.IsEmpty) { return false; } else { return true; } } In private void OnUpdate(object sender,

purrr pmap to read max column name by column name number

北战南征 提交于 2019-12-13 02:49:35
问题 I have this dataset: library(dpylr) Problem<- tibble(name = c("Angela", "Claire", "Justin", "Bob", "Gil"), status_1 = c("Registered", "No Action", "Completed", "Denied", "No Action"), status_2 = c("Withdrawn", "No Action", "Registered", "No Action", "Exempt"), status_3 = c("No Action", "Registered", "Withdrawn", "No Action", "No Action")) I want to make a column that has everyone's current status. If the person has ever completed the course, they are completed. If they were ever exempt, they

How to make an if statement with JSONT

早过忘川 提交于 2019-12-13 01:25:18
问题 How can I check a property for a specific value?? IE: The JSONT version of if(someProperty == someValue){ //Do some stuff } 回答1: The control-of-flow syntax for if is: {.if pagination} // Do some stuff {.end} But if you're looking to do if/equals then: {.equal? @index 1} // Do some stuff {.end} That said, it appears that JSONT is a forked language without an active community working on any particular implementation so the syntax will vary. In this case, I'm referring to Squarespace's

Prolog removing IF THEN ELSE

天涯浪子 提交于 2019-12-13 01:13:31
问题 I would like to reformat my code without the if then else condition. Is there an easy way to do this? This is just an exemple of code. I think using IF-THEN-ELSE in prolog is weird :\ And I'm looking to get something more recursive cases. Like pattern matching rules(Param1, Param2) :- ( A -> B, C, D, ( E -> F ; G, H ) ; I ). Edit: Edited my code to look like more what it should look 回答1: The general translation scheme for pred(X):- ( A -> B ; C -> D ; G ). pred(Y):- Q. is pred(X):- pred1(X).

how avoids deadlock condition

北战南征 提交于 2019-12-13 00:15:53
问题 I try to write a program like a compiler. In this case I must simulate these codes of SQLPL (this one can be just for example). For example in command prompt I want to do these: c:\> sqlplus .... Enter User-Name:(here we must enter username) xxxx Enter password:(same up)yyyyy ... sql>(now I want to send my sql command to shell)prompt "rima"; "rima" [<-output] sql> prompt "xxxx" sql> exit very simple. I try to use this code: ProcessStartInfo psi = new ProcessStartInfo( @"sqlplus"); psi

Detecting steady-state by calculating ODE values in ODE function in Matlab

只愿长相守 提交于 2019-12-12 18:24:42
问题 I have a system of ODE equations which I want to solve, but there is a tricky part that when the system reaches steady-state, I would like to change the value of one (or more) parameters. For example, consider the following: function dydt = diff(t,x,params) F = params(1); G = params(2); dydt = zeros(2,1); dydt(1) = F*x(1) - G*x(1)*x(2); dydt(2) = (F-G)*x(2); end I would like my code to work such that when the system has reached steady-state, the value of F is changed to 10 and the value of G