I want to run a function if a cell value is "Smartphone". I have tried a few ways of writing this but it keeps failing and can not figure out the right way to type it.
function ifTest(event){
if(SpreadsheetApp.getActiveSheet().getRange("B11").getValue() = "Smartphone"){ // mobile phone check
emailMobileRequired(); // Launches the script
}
}
You need to use two equal signs instead of one to compare two values and test for equality. (read more: http://www.w3schools.com/js/js_comparisons.asp)
In javascript one equal sign is an assignment operator. The expression result on the right is assigned to the variable on the left. (read more: http://www.w3schools.com/js/js_operators.asp)
Related
My beam/dataflow job starts with a single static entry passed in like this:
Pipeline p = Pipeline.create(options);
PCollection<String> initValue = p.apply(Create.of("MyStringValue"));
However when I run it (on DataflowRunner), the Create node produced by that statement emits multiple values. The longer I wait, the more times it emits the single value:
This doesn't appear to be an artefact as later in the pipeline I get duplicate/triplicate/.. elements. Beam also logs a warning:
Can't verify serialized elements of type BoundedSource have well defined equals method. This may produce incorrect results on some PipelineRunner
How do I make my Create.of with one value emit just one value to the pipeline?
Do I need to attach an equals method or point it towards the equals method for String values (if so, how)!?
Im using maple Im in worksheetmode I tried using Maple Input and 2D Input and I want to transpose my Matrix A:
A := `<|>`(`<,>`(1, .5, -2), `<,>`(.5, 9/4+b, 5+3*b), `<,>`(-2, 5+3*b, 18+9*b+4*a));
B:= Transpose(A);
When I exectute the sheet I dont get the translated values, there are the same as the input. So my matrix looks like the same as my input matrix plus the function term.
You can see a picture in the following link: Why arent the functions executed?
Meanwhile B:=A^+ is doing it the right way and I get a transposed Matrix. But also other functions only return the function body instead the needed values...
If you are using 2D Input mode (the default) then the extra space you've got between Transpose and the bracketed (B) is interpreted as multiplcation. Get rid of such a space.
Also, either load the package at the start of your document like,
with(LinearAlgebra):
before calling the Transpose command from that package, or call it with it's full name like,
LinearAlgebra:-Transpose(B);
So I have a chapel issue i can't seem to figure out. I have a queue that one can set size. The only thing is is that it's setting size and filling the queue with a bunch of 0s (which make's sense). I'm trying to fill the queue with null rather than numerical values so later on when I work on the add method I can check if queue is null. I have attached an image of how everything is set up. Let me know if you guys have any guidance or ideas.
The error that i'm getting is:
error: type mismatch in assignment from string to int(64)
I must be doing it the wrong way here.
The error you are seeing is about the line:
elements[i] = 'nil';
'nil' is a string, not the nil value, which is written as just nil without any quotes. Assigning a string to a slot in an array of int(64) doesn't work, so the compiler issues an error.
In Chapel only classes can have a nil value though, so you'll need to use a different way to keep track of which positions in the elements array are filled.
One way to do that would be to add two new integers to your class that keep track of the first and last positions containing valid values. As you add values to the queue the last position increases, and as you remove values the first position increases. When either of those values passes the end of the array, it wraps around back to the front. If last ever catches first, then the array is full. If first ever catches last then the array is empty.
A few other things I think should be corrected in your code are:
use semaphore.chpl; Use statements work with module names, not filenames, so this should probably be use semaphore;.
If I'm understanding your intent here, this code is trying to set the size of the elements array to 5.
var elementsDomain: domain(1);
var elements: [elementsDomain] eltType = 5;
The array's domain controls the size of the array, so the way to set the array size is through the domain:
var elementsDomain: domain(1) = {0..#5};
var elements: [elementsDomain] eltType;
elementsDomain = (0..capacity - 1); is setting elementsDomain to a range literal value. This works since the domain is 1-dimensional, but to make it more clear, you can set it to a domain literal value instead: {0..capacity - 1}.
I know there are solutions to evaluate math formulas with AS3: Using MathParser, or port it to JavaScript and many others.
But what if I want to manually evaluate a math formula, without using any built libraries?
It should be able to solve this: 1+(2*5+(9-6)/(5-2))+(6/2)*5
This is how I intend to go about it:
Seperate the string literal with left and right brackets.
Sort the result with its priority (by scanning the string from left to right, every
time it sees a left bracket then priority increases. Every time it sees a right bracket
then decreases).
Calculate the results from the one with the highest priority.
However, I have not been able to successfully implement it yet.
Transform your expression into Reverse Polish Notation using the Shunting-yard algorithm and evaluate it. There's a good example in the second article.
I am just trying to use the OR function in Excel for analyzing some string variables. Instead of using a character count to verify whether someone anwered correctly, I would like to use the or function to accept more than one answer as correct.
For instance, return 1 if cell = "she was always there" or "she was there always".
How would I do this?
=IF(OR(A1="this",A1="that"),1,0)
IF takes three values:
The logical test
The value if true
The value if false
Each value can take other functions as it's argument. In this case, we use an OR function as the logical test. The OR can take any number of arguments (I'm sure there is a limit but I've never seen it). Each OR argument takes the form of a logical test and if any of the logical tests are TRUE, then the result of the OR is TRUE.
As a side note, you can nest many functions to create complex tests. But the nesting limit seems to be set at 7. Though there are tricks you can use to get around this, it makes reading the function later very difficult.
If you can live with "TRUE" or "FALSE" returns, then you don't need the IF function. Just:
=OR(A1="she was always there",A1="she was there always")
I found that by Googling "EXCEL OR FUNCTION"
http://office.microsoft.com/en-us/excel-help/or-function-HP010062403.aspx