Create range higher to lower [duplicate] - rust

This question already has answers here:
How to make a reverse ordered for loop?
(2 answers)
Closed 12 months ago.
I want to create range x..y where x > y. For eg 5..-10.
5..-10 produces empty range https://doc.rust-lang.org/std/ops/struct.Range.html
I created this questions to share my solution and potentially someone will come with better idea.

We can create valid range y..x (since x > y) and then reverse it
(y..x).rev()
this will produce desired range

Related

How to create a function in excel for sum of cubes or higher powers? [duplicate]

This question already has an answer here:
Implement p-mean in excel
(1 answer)
Closed 3 years ago.
I'm trying to implement p-means, as laid out in this question
If p=2, I can do SQRT(SUMSQ(data)).
If p=3, I need to do CBRT(**SUM OF CUBES**(data))
And so on. The first part is easy to scale, I can just raise the whole thing to 1/N. But how would I implement sum of cubes, fourth powers, etc. ?
"But how would I implement sum of cubes, fourth powers, etc."?
With SUMPRODUCT:
If your data is in A1:A3 for example:
=SUMPRODUCT(A1:A3^3)
=SUMPRODUCT(A1:A3^4)
etc.
I'd ditch the use of SUMSQ here and just use SUMPRODUCT all around.
Scott's answer to another question of mine is what I ended up using:
=(SUM(IF(ISNUMBER(E2:E99),E2:E99^3))/COUNT(E2:E99))^(1/3)
This is an array formula (ctrl + shift + enter or it won't work).

Excel - how to get sumproduct of adjacent cells in one row [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I have a row of values and want to get the product of the first pair, the product of the second pair and so on, then sum the products.
For example, for:
5 | 10 | 2 | 5 | 3 | 6
I would expect the result to be 78 (50 + 10 + 18)
This formula achieves the correct result:
=SUMPRODUCT(--(MOD(COLUMN(C19:V19)-COLUMN(C19)+1,2)=0),C19:V19,--(MOD(COLUMN(B19:U19)-COLUMN(B19)+1,2)=0),B19:U19)
However I can't stager the ranges like that (C19:V19 and B19:U19). I need to only use C19:V19 (which is where the actual data is) in the formula. It's just staggered here so that the second part of the formula picks up the odd cells and the first part picks up the evens.
I need to figure out an equivalent forumula that just uses C19:V19.
As part of that attempt I've reach this point:
=SUMPRODUCT(--(MOD(COLUMN(C19:V19)-COLUMN(C19)+1,2)=0)*C19:V19,--(MOD(COLUMN(C19:V19)-COLUMN(C19)+1,2)=1)*C19:V19)
Which would correctly pick up the odds and evens, but will always multiply each product out to 0.
I'm struggling to come up with another method. Does anyone have any suggestions?
This works : =SUMPRODUCT(OFFSET(C1:H1;0;1)*(C1:H1);--(MOD(COLUMN(C1:H1)-COLUMN(C1);2)=0))
The OFFSET shifts your array one position to the right, then you multiply with the original array, and then you have to only sum the uneven positions, which is done with the SUMPRODUCT and the array you create with the --MOD()
I just used the 6 numbers you put in your question in C1:H1, so you have to change this reference with C19:V19.

Finding the Smallest Non-Negative Integer Not in a Given List [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am attempting to write a program in Excel that finds the smallest non-negative integer not in a given list and places it into a cell. The list will contain only non-negative integers. I can do this if the values in the list have an upper bound quite easily using a series of if statements, but the list can (and will) contain arbitrarily large values. I am quite new to using Excel, so I would greatly appreciate it if you could provide a formula I could simply place into the cell (i.e. no macros, if possible). Thank you in advance for any assistance you can provide on this topic.
Examples:
List = {0,1,2,3,4}, Output = 5
List = {0,1,2,4,7}, Output = 3
List = {1,2,3,4,7}, Output = 0
Given your edited question then assuming you will have at least one integer missing in the range 0 to 99 try this formula where List is in A1:A5
=SMALL(IF(COUNTIF(A1:A5,ROW(INDIRECT("1:100"))-1)=0,ROW(INDIRECT("1:100"))-1),1)
confirmed with CTRL+SHIFT+ENTER
This version will also give you the same result without "array entry"
=LOOKUP(2,1/(COUNTIF(A1:A5,100-ROW(INDIRECT("1:100")))=0),100-ROW(INDIRECT("1:100")))
See example below showing the outcome for each of your example lists:
MIN(A:A) will get you the smallest number in column A - just subtract 1 (or any number really) to get a number smaller than any of those (or use MAX to get largest). Update the formula as necessary based on where your data is. If the result needs to be an integer, just ROUNDDOWN it.

Is the a similar command within Excel that performs the same as the 'floor' command within MATLAB [duplicate]

This question already has answers here:
Excel formula to do the same as x=(b/N)*(-floor(N/2):floor(N/2)) in MATLAB
(2 answers)
Closed 8 years ago.
The 'floor' command in MATLAB is defined as "Round towards minus infinity.
floor(X) rounds the elements of X to the nearest integers
towards minus infinity."
Is there a similar command within Excel, or does anyone know how to perform the same action within Excel?
yes, you can use =INT(A1) formula. It rounds a number (from A1 cell) down to the nearest integer. Here is documentation.

What does <> mean in excel? [duplicate]

This question already has answers here:
What does <> mean?
(5 answers)
Closed 8 years ago.
Google doesn't understand <> so that failed thus asking here.
What does '<>' (less than followed by greater than) mean in Excel? For example:
=SUMPRODUCT((E37:N37>0)*(E37:N37<>"")*(E37:N37))
What's happening here?
It means "not equal to" (as in, the values in cells E37-N37 are not equal to "", or in other words, they are not empty.)

Resources