Get current index from foreach loop
How do you get the index of the current iteration of a foreach loop?
Are dark energy and zero-point energy the same thing? According to Quantum Mechanics is it possible that the famous  and  are the same thing that drives the accelerated expansion of the universe or maybe related to each other? The  is the difference between the distances travelled by two waves meeting at a point. Given the path difference, how does one calculate the phase difference? What would be the quickest way to construct a Python binding to a C or C++ library?  (I am using Windows if this matters.) How do I run Command & Conquer Gold on Windows 7 64-bit (in XP mode)? I downloaded the first Command &amp; Conquer game  and burnt some CDs. I couldn't get the Setup.exe program to run in Windows 7 64-bit, as it must need some old DLLs. So I ran up the Windows XP Mode virtual machine, and was able to install it fine.   However, when I try to run the program, I just get an empty message box with an "OK" button. I've set the compatibility to Windows 95, and checked all of the options in the Compatibility tab, but it's not running. I also downloaded the patch suggested by EA, which is an updated version of the THIPX32.DLL file (copied into the C&amp;C installation folder).  Has anyone managed to get this working? This is not a duplicate question because I am looking for an explanation directed to a general audience as to the mistakes (if any) in  (reproduced below). (Numberphile is a YouTube channel devoted to pop-math and this particular video has garnered over 3m views.)   By general audience, I mean the same sort of audience as the millions who watch Numberphile. (Which would mean, ideally, making little or no mention of things that a general audience will never have heard of - e.g. Riemann zeta functions, analytic continuations, Casimir forces; and avoiding tactics like appealing to the fact that physicists and other clever people use it in string theory, so therefore it must be correct.)  Numberphile's Proof.  The proof proceeds by evaluating each of the following:  $S_1 = 1 - 1 + 1 - 1 + 1 - 1 + \ldots$   $S_2 = 1 - 2 + 3 - 4 + \ldots $   $S = 1 + 2 + 3 + 4 + \ldots $   "Now the first one is really easy to evaluate ... You stop this at any point. If you stop it at an odd point, you're going to get the answer $1$. If you stop it at an even point, you get the answer $0$. Clearly, that's obvious, right? ... So what number are we going to attach to this infinite sum? Do we stop at an odd or an even point? We don't know, so we take the average of the two. So the answer's a half."   Next:  $S_2 \ \ = 1 - 2 + 3 - 4 + \cdots$  $S_2 \ \ = \ \ \ \ \ \ \ 1 - 2 + 3 - 4 + \cdots$  Adding the above two lines, we get:  $2S_2 = 1 - 1 + 1 - 1 + \cdots$  Therefore, $2S_2=S_1=\frac{1}{2}$ and so $S_2=\frac{1}{4}$.  Finally, take  \begin{align} S - S_2 &amp; = 1 + 2 + 3 + 4 + \cdots           \\ &amp; - (1 - 2 + 3 - 4 + \cdots)          \\ &amp; =   0 + 4 + 0 + 8 + \cdots           \\ &amp; = 4 + 8 + 12 + \cdots           \\ &amp; = 4S \end{align}  Hence $-S_2=3S$ or $-\frac{1}{4}=3S$.  And so $S=-\frac{1}{12}$. $\blacksquare$ The indexer into Dictionary throws an exception if the key is missing.  Is there an implementation of IDictionary that instead will return default(T)? I know about the TryGetValue() method, but that's impossible to use with LINQ. Would this efficiently do what I need?: myDict.FirstOrDefault(a =&gt; a.Key == someKeyKalue);  I don't think it will as I think it will iterate the keys instead of using a Hash lookup. C's strtok() and read only string literals char *strtok(char *s1, const char *s2)      repeated calls to this function break string s1 into "tokens"--that is   the string is broken into substrings,   each terminating with a '\0', where   the '\0' replaces any characters   contained in string s2. The first call   uses the string to be tokenized as s1;   subsequent calls use NULL as the first   argument. A pointer to the beginning   of the current token is returned; NULL   is returned if there are no more   tokens.   Hi,   I have been trying to use strtok just now and found out that if I pass in a char* into s1, I get a segmentation fault. If I pass in a char[], strtok works fine.   Why is this?  I googled around and the reason seems to be something about how char* is read only and char[] is writeable. A more thorough explanation would be much appreciated. A "failed to fetch" error occurs when apt-get update is run. How do I fix this? If there is one noble left in line and you play "fled to England" to discard it (thus, ending the day) do you collect a noble from the new day? Why isn't sizeof for a struct equal to the sum of sizeof of each member? Why does the sizeof operator return a size larger for a structure than the total sizes of the structure's members? Calculate $\lim\limits_{x\to4} \frac {\sqrt {1+2x}-3} {\sqrt x -2}$ After I just learned there are ways to cancel out $0$s in the divisor of fractions onto limits I looked back at a task where I gave up when I got the result $\lim\limits_{x\to4} \frac {\sqrt {1+2x}-3} {\sqrt x -2}$ so I tried to find a way to get the $0$ out here, as well. Am I just not seeing the solution or is there no way to do it? Why does Lang describe a field as a union and compositum of its subfields in this manner? I am reading Serge Lang's Algebra, revised 3rd edition, and on page 226, the author makes the following definitions and observations:   If $E,F \subset L$, the compositum of $E$ and $F$ in $L$ is defined to be the smallest subfield of $L$ containing both $E$ and $F$. It is denoted $EF$. If $k \subset E$ and $\alpha_1,\dots,\alpha_n \in E$, then $k(\alpha_1,\dots,\alpha_n)$ is defined to be the smallest subfield of $E$ containing $k$ and $\alpha_1,\dots,\alpha_n$. Observe that $$ E = \bigcup k(\alpha_1,\dots,\alpha_n), $$ where the union is taken over all finite families $\{ \alpha_1,\dots,\alpha_n \}$ of elements of $E$. The compositum of an arbitrary family of subfields of a field $L$ is defined as the smallest subfield of $L$ containing all fields in the family. $E$ is finitely generated over $k$ if there is a finite family $\{ \alpha_1,\dots,\alpha_n \}$ of elements of $E$ such that $E = k(\alpha_1,\dots,\alpha_n)$. Observe that $E$ is the compositum of all its finitely generated subfields over $k$.   My question is regarding the two observations (point nos. 3 and 6). It appears to me that it is enough to take union (and compositum) over all subfields generated by a single element. For example for point no. 3, I can write $$ E = \bigcup_{\alpha \in E} k(\alpha) $$ because $E$ is clearly contained in the RHS, and each $k(\alpha)$ is contained in $E$ and hence so is the union, implying that $E$ contains the RHS. Similarly for point no. 6.  So, why does Lang emphasise to take the union and compositum over all finitely generated subfields? Is there some perspective that he wishes to emphasise that I am missing? Any help in understanding this will be appreciated. Let $f:\mathbb{R}\to\mathbb{R}$ continuous such that $\lim_{x\to\infty}f(x+1)-f(x)=l$.  How can I prove that $\dfrac{f(x)}x$ converges for $x\to+\infty$ ?  I am just trying to prove the convergence, not that it converges to $l$ (that part be deduced immediately by Stolz-Cesaro and the sequential characterization of limits) Conditional clause (then) In this first instance the main clause only stands alone if you  omit (then).  But in the other example it clearly has a main clause. So would this be classed as an embedded main clause as it only works as a independent clause if it's adjusted and or if it's joined with a dependent clause.  If I have enough money, then I will buy a new car.  If it rains, the picnic will be cancelled.  The picnic will be cancelled if it rains. I'd like to know if the following problem of elementary linear algebra is already solved / solvable.  For two (singular) $n\times n$ matrices $P$ and $Q$, if $\det(\lambda P+\mu Q)=0$ for any $\lambda,\mu\in\mathbb{R}$, what are conditions on $P$ and $Q$? Degree of minimum polynomial at most $n$ without Cayley-Hamilton? Identifying records in MC to delete I'm trying to delete a large number of records from SFMC to avoid being charged extra. I've run several different SQLs to help identify the records I don't need, but when I run the Contact Count report, it still shows approx 100K billable contacts and approx 60K distinct email addresses.  Here are the SQLs I've tried:   No Opens in past 5 days Leads/Contacts not in SFDC  SubscriberKey as Email Address Leads/Contacts where SubscriberKey is Empty Unspecified records (DE populated by MC Support)    These efforts reduced the count a good amount, but not as much as I was expecting.   Has anyone else gone through this process before and if so, what queries can you share that might help my case? Output of getent group How to access folder named "x y" (x space y) using Ubuntu Bash script in Windows? A ring without the Invariant Basis Number property