conditional-statements

Excel - programm cells to change colour based on another cell

自作多情 提交于 2019-12-01 05:27:35
问题 I am trying to create a formula for Excel whereby a cell would change colour based on the text in the previous cell. So for example if cell B2 contains the letter X and then B3 is Y, I would like B3 to turn green. Equally, if B2 contains X and B3 contains W I would like B3 to turn red. Any ideas much appreciated! 回答1: Select cell B3 and click the Conditional Formatting button in the ribbon and choose "New Rule". Select "Use a formula to determine which cells to format" Enter the formula: =IF

Using Conditional Statements to Change the Color of Data Points

风流意气都作罢 提交于 2019-12-01 03:51:37
问题 I have a data set, which I have used to make a scatter plot and I would like to assign three different colors to the data points within three different regions, based on their x values. Data points with x-values < 3 I want to appear red Data points with x-values (3,1549) I want to appear black Data points with x values >1549 I want to appear purple Here is my code for the scatterplot and accomplishing the first two parameters, how might I implement the third parameter, so that the last region

is it possible to have a conditional field in an anonymous type

我是研究僧i 提交于 2019-12-01 03:23:47
i have some code that looks like this and creates a list from an existing collection var items = items.ConvertAll(r => new { description = FormatDescription(r), start = r.Milestone.HasValue ? r.Milestone.Value.ToString("yyyy-MM-ddTHH:mm:ssZ") : DateTime.Today.ToString("yyyy-MM-ddTHH:mm:ssZ"), classname = "significance" + r.SignificanceLevel, As you can see, right now if i dont have a start date (r.Milestone) then i put in today's date. What i really want to do if say: if i have a r.Milestone.Hasvalue show that date, if i dont have a value DONT HAVE THE START DATE field in the anonymous type at

How to run custom action based on condition?

断了今生、忘了曾经 提交于 2019-12-01 02:45:27
问题 I'm trying to run a custom action (delete a certain file) based on the windows version. I know how to check for the windows version: <Condition Message="Windows version xxx required..."> <![CDATA[Installed OR (VersionNT >= 600)]]> </Condition> However, I do not want to display a message, but delete a file. I can't find an example on how to use such a condition to run oder not to run a custom action! 回答1: You need to specify the condition inside the Custom element which runs your custom action

Summing first 2 elements in a Python list when the length of the list is unknown

家住魔仙堡 提交于 2019-12-01 02:34:13
I am working on the following Python list exercise from codingbat.com: Given an array of ints, return the sum of the first 2 elements in the array. If the array length is less than 2, just sum up the elements that exist, returning 0 if the array is length 0. Examples: sum2([1, 2, 3]) → 3 sum2([1, 1]) → 2 sum2([1, 1, 1, 1]) → 2 My solution below works: def sum2(nums): if len(nums)>=2: return nums[0] + nums[1] elif len(nums)==1: return nums[0] return 0 But I wonder if there's any way to solve the problem with fewer conditional statements. There is. Two elements of the solution - builtin function

Optional binding of nil literal vs. variable that is nil in Swift

老子叫甜甜 提交于 2019-12-01 01:31:15
In Swift, why does var x: Int? = nil if let y: Int? = x { ... } behave differently from if let y: Int? = nil { ... } My understanding of why the first case succeeds suggests that the second should as well, so I must not really be understanding. The latter is not failing because of an invalid assignment, nor because of optional chaining; and otherwise it seems the same as the former. Why does the latter fail, and how is it different from the former. Exactly at what point, and for what reason, is the second optional binding abandoned? rintaro if let y: Int? = nil { ... } is equivalent to if let

Condition give the effect of having multiple wait-sets per object?

▼魔方 西西 提交于 2019-12-01 01:23:30
I am reading about Condition in java.util.concurrent.locks.Condition . Condition factors out the Object monitor methods (wait, notify and notifyAll) >into distinct objects to give the effect of having multiple wait-sets per object, by combining them with the use of arbitrary Lock implementations. Can somebody explain me this? How this is a benefit over normal synchronization blocks or method? One Lock can be associated with many Conditions. Lock is an "object", each condition is a "waiting set". This allows for independent conditions sharing critical section. For example, consider bounded

Conditional summation in Crystal Reports

假装没事ソ 提交于 2019-12-01 01:20:27
I have some rows with a price and quantity and I'm looking to sum only the prices where the quantity > 5 itemname price Qty ---------------------------------- apple 20 2 watermelon 10 3 bango 22 6 hashesh 3 9 Given the above data, the sum I'd like to get is 22+3=25. How do I write a formula to do this? Siva create a formula field named calculation to the side of quantity and enter the following text: // {@calculation} If quantity>5 then price else 0 now take the sum of {@calculation} . suppress both detail in the report. Take the sum and place in the footer of the required column. 来源: https:/

Rails 4 / Bootstrap 3: how to display a different navigation bar on different pages?

穿精又带淫゛_ 提交于 2019-11-30 23:08:56
Here is the _header.html.erb of our Rails 4 app, made with Bootstrap 3 components: <header class="navbar navbar-fixed-top navbar-inverse"> <div class="container"> <nav> <div class="col-xs-4"> <%= link_to "APP NAME", root_path, id: "logo" %> </div> <div class="col-xs-4 text-center"> <ul class="nav navbar-nav navbar-center"> <li><%= link_to "Features", features_path %></li> <li><%= link_to "Pricing", pricing_path %></li> <li><%= link_to "Blog", '#' %></li> </ul> </div> <div class="col-xs-4"> <ul class="nav navbar-nav navbar-right"> <% if current_user.try(:admin?) %> <li><%= link_to "Users",

Declaring an implicitly typed variable inside conditional scope and using it outside

感情迁移 提交于 2019-11-30 21:27:30
In the simplified code below, if(city == "New York City") { var MyObject = from x in MyEFTable where x.CostOfLiving == "VERY HIGH" select x.*; } else { var MyObject = from x in MyEFTable where x.CostOfLiving == "MODERATE" select x.*; } foreach (var item in MyObject) { Console.WriteLine("<item's details>"); } The variable MyObject is not accessible outside conditional block. How can I iterate outside the if..else ? Let's clarify your confusing question. The problem is that you have two local variables, each of which has the same "unspeakable" type -- a sequence of anonymous type. I would change