I write a wrong expression sum(A14+A15:A19). Actually the right way for me is A14+sum(A15:A19). Curiously, the former can run as well with no error. So I spent much time to check the adequate result and find the odd phenomenon.
Besides, when I input the expression in the row 20,21 , error appears. Is that a bug? What's the meaning?
Thanks.
The sum function takes in parameters separated by ,s (not +s).
It's a little counterintuitive, since you're trying to add things together, but instead of =sum(A14+A15:A19) try = sum(A14,A15:A19).
All that being said, I assume there's a reason why you wouldn't simplify the whole thing and use =sum(A14:A19).
Related
I'd like to use part to handle expressions of different length but have not been able to find anything in the documentation that addresses how to determine the number of parts of an expression.
I do have an upper bound for the number of parts so, in this particular case, I could loop over the terms until I get an error; however, I was wondering if there is a more direct method?
I can't believe this, but it appears length does the trick.
I assumed it was limited to lists because it returns an error for single numbers, because they are atoms. Apparently my brain decided "doesn't work with atoms" to mean "only work with lists."
However, this does mean that neither part nor length will work if the expression only has one part, so that case has to be handled separately.
I would still be interested in knowing if there is a solution that will work in all cases, so I won't mark this as the answer, just yet.
I am using =MODE(B1:F85) to get the MODE, how do I get which is the second most frequent value after 10?
Thanks
This should return the second most frequent value:
=ArrayFormula(MODE(IF((B1:F85=MODE(B1:F85)),"",B1:F85)))
As an aside, I think the fact you need to use "" in the second argument, rather than omitting the argument altogether, is (in my opinion) a low-grade bug, which I will report. Nevertheless, the above formula should still work even if the behaviour was changed accordingly.
I use == and != a lot in my code and I was wondering which is quicker in objective c so that I can make my app as fast as possible.
Situation
I have a variable which is one of two things and I want the quickest method to see which one it is
Thanks in advance
You should not worry about this level of detail for performance reasons, unless you've identified a performance issue.
However, wondering to satisfy an inquiring mind is a different matter! :-) The answer is they are identical.
A comparison is usually compiled as an instruction which sets condition flags; this could be a specific comparison instruction or something like an arithmetic instruction which sets condition codes; followed by a conditional jump which tests the condition flags - and a test for "equal" is the same cost as for "not equal", just a different setting of those condition flags.
This also means that statements such as if([some method call]) ... and if(![some method call]) ... have the same cost - the "not" operator produces no extra code.
You can test yourself.
Check current milliseconds before and after operating.
I guess there's no differences..
If you really need to know,
you could make a lot of operating with loop.
then you will get the answer.
This is silly. You would have to execute millions of iterations of code using the 2 versions of if statement in order to even detect a difference in speed. This is a triviality, and not worth worrying about.
As the other poster said, == and != should take exactly the same amount of time for non-floatingpoint values. For floating point, there might be some differences, since for an equal comparison the processor has to first normalize the 2 floating point values, then compare them, and normalizing is relatively time-consuming. I don't know if testing for non-equality if slower than equality. IT's unlikely but not impossible.
I'm trying to make z3 (I'm using z3py) to simplify some formulas for me (so that I can have more or less human-readable output). Using ctx-solver-simplify tactic seemed a good choice for me since in a couple of passes it would produce nice compact formulas. But soon I've run into a situation when the output of ctx-solver-simplify does not seem to be equivalent to the original formula (it looks more like being satisfiability-equivalent or so). Also, it might be the case that I'm not dealing with tactics correctly.
Here's what I was trying to do: http://rise4fun.com/Z3Py/g5sX. So, I construct a formula Set2 (everything before the definition of Set2 is just a setup needed to define it) which has a particular satisfying assignment. After applying ctx-solver-simplify, I get a single formula (as a goal) for which this assignment is not satisfying. So what am I dong wrong?
Am I wrong assuming that ctx-solver-simplify would produce an equivalent formula?
Am I handling the tactics and their output in the wrong way?
Anything else?
Thanks.
I have been looking into this, but have so far been unable to reproduce the bug directly
with our current branch. A bug in the context simplifier was fixed a little while ago, and it could
be manifesting itself with the online version of Z3.
There are still a few things I can do to double check if we can reproduce the bug
and I will update this post with what I find.
I'm writing a little scripting language just for a bit of fun and the learning of the codes :P
I would just like your opinions/suggestions. I have an idea but I don't want to include something that people are going to want to spit on. I plan on making this language open source once, soon.
Does anybody think that it would be cool to have something like:
[Foreach] Uppercase Letter s
in Case-Insensitive Word SallySawtheSeafiShandateit:
Count++.
s.Highlight: True.
RunOnce.ProtectedMethod.ActivateProtectedMethod: IsTrue.
[Protected Method.LockTo: [Foreach]].IsTrue
StatusBar.Message: Match for s was found. Total: Count..
RunOnce.ProtectedMethod.Disable.
Explanation: What the above actually does is it searches through a string of text "SallySawtheSeafiShandateit" and highlights every single match. But when it finds the very first match for "s", it runs a method called "IsTrue", and sets the statusbar text to "match was found...". And then deactivates the RunOnce method so it may no longer be accessed, since there's no need for it to be run again.
This might not be the best example, but I think you get the idea. There have been plenty of times where I've needed to do something only once in a foreach loop, but couldn't, without writing a whole bunch of other code.
I figure, atleast this way, everything can be done in just two methods.
Please be brutally honest. :)
Thank you
This just seems like an over-complication of the following structure (in java style):
boolean ranOnce = false;
for (char c : string.toCharArray()) {
if (c != 's') continue;
if (!ranOnce) {
// do stuff once
ranOnce = true;
}
// do other stuff
}
It just seems like extreme over-engineering to me, when a single boolean and an if condition do the trick.
Hm. For this sort of situation I'd normally just use a flag variable and a conditional.
I'd reconsider "runOnce" -- it's a little ambiguous. Does it run the first iteration, the last iteration, somewhere in the middle? From what I can tell it looks like yours runs in the very first iteration, but then again what use would displaying the total count be in the first iteration? You'll know it's just "1".
For my money, I think I'd actually use two keywords that fired events/methods/etc at the first iteration and at the last iteration, respectively.