function make_withdraw(balance) {     return function(amount) {         if (balance &gt;= amount) {             balance = balance - amount;             return balance;         } else {             return "Insufficient funds";         }     } }  var W1 = make_withdraw(100); W1(50); // 50 W1(60); // "Insufficient funds" W1(40); // 10       function w(amt){ var b= 100; if(b&gt;=amt){b=b-amount;return b;}else{return alert("error!");}} w(10); //90 w(10); //90     Why by assigning balance the W1 function can keep track of balance, while w function cannot?
How would you explain JavaScript closures to someone with a knowledge of the concepts they consist of (for example functions, variables and the like), but does not understand closures themselves?  I have seen  given on Wikipedia, but unfortunately it did not help.
Indefinite integral $\int(\sin x)^2/(x\cdot\cos x-\sin x)^2\,dx$ How to find the antiderivative of $\dfrac{(\sin x)^2}{(x\cdot\cos x-\sin x)^2}$? I know that series theory can solve the problem. But I wish to solve the problem by the antiderivative way. The numerator and denominator divide the $x^2$ at the same time, don't they? If I have bought 3 tickets for the same flight, can I bring three times the cabin allowance allowed per ticket?  The way I see it I am doing the airline a favor  Related: Is hyperref really the best way to add metadata to a TeX file? So I know one of hyperref's features is that it can add metadata to you PDFs. This is a nice feature and if you're putting stuff online, it's good to include metadata.  But is the hyperref package really the best way to do it? I mean, if you're using hyperref anyway, that's fine. But if you don't want hyperrefs in your document, it seems weird to include the package, and then turn off pretty much all its functionality. And given that hyperref is a shorthand for "package conflict nightmare", is seems insane that you should have to deal with it just for the sake of some metadata.  So I have two questions.   Is there a good reason that hyperref includes this functionality which is apparently unrelated to its primary purpose? Is there a better (smaller, less conflicty, easier...) option to include metadata in my PDFs? Class moderncv moving footer I am using documentclass moderncv to style my resume, and I'd like to put the information that normally goes at the bottom of the document, such as phone number and email, to the space next to the name aligned on the left of the document. I'm a beginnner user, so I'd love to get some enlightenment on this.  \documentclass[11pt,letterpaper,sans]{moderncv}  % moderncv themes \moderncvstyle{casual} \moderncvcolor{blue} \usepackage[scale=0.75]{geometry}  % personal data \firstname{John} \familyname{Doe} \mobile{+1~(234)~567~890}  % content  \begin{document} \makecvtitle \pagestyle{empty}  \section{Education} \cventry{1998-2007}{Degree}{Institution}{City}{\textit{Grade}}{Description}   \section{Computer skills}  \thispagestyle{plain} \end{document}    Simply put, I want to move \mobile from the bottom to the top left. Suppose that we don't know logarithm, then how we would able to calculate $\sqrt x$, where $x$ is a real number? More generally, is there any algorithm to calculate $\sqrt [ n ]{ x } $ without using logarithm? More simple techniques would be nice.  Here is a simple technique used to approximate square roots by :  For example: $\sqrt {78}\approx 8\frac { 14 }{ 17 } $ , where $8$ is the nearest integer root of $78$, $14 = 78 - 8^2$, $17 = 2 \times 8 + 1$.  if $n=2^k$ we can use the method above.   For example, for $k=2$ Lets calculate $\sqrt [ 4 ]{ 136 } $: $$\sqrt [ 4 ]{ 136 } =\sqrt { \sqrt { 136 }  } \approx \sqrt { 11\frac { 136-{ 11 }^{ 2 } }{ 11\times 2+1 }  } =\sqrt { 11\frac { 15 }{ 23 }  } \\ \sqrt { 11\frac { 15 }{ 23 }  } \approx 3\frac { 11\frac { 15 }{ 23 } -{ 3 }^{ 2 } }{ 3\times 2+1 } =\frac { 544 }{ 161 } =3.38\\$$ The exact result is$$ \sqrt [ 4 ]{ 136 } =3.4149\cdots$$ The method approximates well, but it is working for only $n=2^k$ as I know. I'm a bit surprised from my US Visa. I plan to go to a conference on 3rd of April. Amazingly though, the visa expiration date is written as April 3rd.  So what does that mean. Can I enter the US on April 3rd? or should I enter one day earlier? Let's say I have a node type "Article" which has a field "File" which is set to handle public files. A lot of articles and files get added.  Now the specs suddenly change and the "Article" will move behind a login and therefore also the attached files must be changed to be not publicly accessible anymore.  I already found out  pretty easily by reimporting the manually updated field.storage.node.field_file.yml config. But: this only affects new files that will be added after the switch. It doesn't work for existing files. They still are accessible publicly. Many thousand existing files would need to be manually reuploaded to also make them private.  Does anybody of you have solved that in D8 before? If so, then how?  As all I can think of right now is to programmatically query all "Article" nodes, then foreach through all nodes, get the files, temporarily store them somewhere else, empty the field out, then try to reupload the files programmatically (probably my next question) and then resave each node.  Does that sound reasonable? Or can you think of any other approach that might work here (in D8)? Why sometimes evidence is said to be too complex to compute and other times is negelected cause it is fixed? How to fill in the Schengen visa application form when going to several countries? I will be traveling to France, Italy and Germany with France being my main destination. So I am applying in the French consulate for Schengen visa. I will be traveling on my own and will be staying in hotels.  I had some doubts with regards to filling the application form for Schengen visa.    Q22- Member State(s) of destination: Should I fill in all three of my destinations ? Q31 Surname and first name of the inviting person(s) in the Member State(s). If not applicable, name of the hotel(s) or temporary accommodation(s) in the Member State(s) : This field has barely a line of space to enter. Should I just enter the hotel name in France (my main destination) ?  Q32 Surname and first name of the inviting person(s) in the Member State(s). If not applicable, name of the hotel(s) or temporary accommodation(s) in the Member State(s): Same problem as Q31. Very little space. Should I just enter address of the one hotel I entered in earlier Q ? Is there a converter that will convert LaTeX to HTML? I have tried several services but the LaTeX diagrams and some of the maths came out weird.  I actually converted the Latex to PDF without a problem. Then I used  to convert from PDF to HTML. The square root signs did not appear properly and some of the Cartesian coordinate plane diagrams had nothing on them except the grid.   \documentclass[12pt,a4paper]{report} \usepackage{amssymb} \usepackage{amsthm} \usepackage{amsmath} \usepackage{pstricks,pst-plot} \usepackage{pst-eucl} \addtolength{\hoffset}{0.2cm} \addtolength{\textwidth}{1.1cm} \addtolength{\textheight}{1.0cm} \addtolength{\voffset}{-0.7cm} \linespread{1.3} \begin{document}  If $x$ is non-positive then $x \leq -\sqrt{\frac{1}{2}}$     $\hspace{30 mm} $     (6)\\  (4) and (6) tell us that\\  (4)  $-1 \leq x \leq 0$  \\  (6)  If $x$ is non-positive then $x \leq -\sqrt{\frac{1}{2}}$\\  Therefore $-1 \leq x \leq -\sqrt{\frac{1}{2}}$\\  \vspace{50 mm}  \begin{align*} \psgrid[unit=2cm](0,0)(-2,-2)(2,2) \pnode(-1.8,.87){b}\uput[50](b){b} \pnode(-1.8,1.8){a}\uput[50](a){a} \psset{linecolor=green} \psline[linewidth=1pt](-1.8, 0)(-1.8,4) \psset{linecolor=green} \psline[linewidth=1pt](-1.8, 0)(-1.8,-4) \psset{linecolor=blue} \psellipticarc(0,0)(2,2){0}{180} \psset{linecolor=red} \psline[linewidth=1pt,linestyle=dashed,dash=2pt](-2,2)(-1.41,1.41) \psset{linecolor=red} \psline[linewidth=1pt](-1.41,1.41) \psset{linecolor=red} \psline[linewidth=1pt]{-&gt;}(4,-4) \psset{linecolor=red} \psline[linewidth=1pt]{-&gt;}(-2,2)(-4,4) \end{align*}  \end{document}   PDF output:    PDF->HTML output: How to make a sound once a process is complete? I have started a long process through a terminal. Is it possible to make the Ubuntu terminal make a sound once the process is complete? This way, I don’t need to keep checking, but will instead be notified through a sound. Difference between cp -r and cp -R (copy command) How can I make hibernate my desktop in UEFI with Secure boot on.  I used command "sudo pm-hibernate" to make hibernate my desktop but my machine did nothing (my desktop is booted up on UEFI with Secure boot on). But, if I boot my desktop on UEFI with Secure boot off, Hibernation is normal.  Sorry for my English, thanks, I'm not sure if this is possible architecturally, but when judging whether to set a bounty and how much it should be, it would be nice to see the impact based on our previous questions. If you're not visiting the site throughout the day, there is no way to tell how effective that bounty might be--particularly for increasing traffic. There is a similar question with adding and removing tags that increase the visibility in the right places, and the effect on views that may have. Suppose Alice chooses a random Prime $p$ and a random private Key $a \in \mathbb{Z}^*_p$. By accident, she also chooses a random number $g \in \mathbb{Z}^*_p$, which is not a generator of $\mathbb{Z}^*_p$ and therefore  $$\langle g\rangle \subset \mathbb{Z}^*_p$$  as opposed to $\langle g\rangle = \mathbb{Z}^*_p$, which would yield a valid key. Alice then computes $A \equiv g^a \pmod{p} $ and publishes the Tuple $(p,g,A)$ as her public key.  Bob now encrypts a message $M$ using Alices public key by computing  $$C_1 = g^b \pmod{p}$$ $$C_2 = M \cdot A^b \pmod{p}$$  Is it possible for an attacker (Eve) to distinguish a “real” ciphertext $(C_1,C_2)$ from a random ciphertext $(Z_1,Z_2) \stackrel{$}{\longleftarrow} \mathbb{Z}^*_p$ with significant advantage (say $Adv \geq \frac12$)?    Edit: I guess it should be enough to show, that the ciphertext cannot be random, if  $$\langle g \rangle \neq \langle C_1 \rangle \quad(\text{or $Z_1$, respectively})$$  But how can Eve check for this property efficiently? Can someone point me in the right direction here?    Edit: A real-world situation where this flaw occurred How to replace ${} placeholders in a text file? $f: \mathbb{R} \to \mathbb{R}$ that takes each value in $\mathbb{R}$ twice Does there exist a continuous function $f: \mathbb{R} \to \mathbb{R}$ that takes each value in $\mathbb{R}$ exactly two times? Where are the outliner toggles in 2.8? Suppose $X$ is a real-valued random variable and let $P_X$ denote the distribution of $X$. Then $$ E(|X-c|) = \int_\mathbb{R} |x-c| dP_X(x). $$  of $X$ are defined as any number $m \in \mathbb{R}$ such that $P(X \leq m) \geq \frac{1}{2}$ and $P(X \geq m) \geq \frac{1}{2}$.  Why do the medians solve $$ \min_{c \in \mathbb{R}} E(|X-c|) \, ? $$ Quantum computers are known to be able to crack  a broad range of cryptographic algorithms which were previously thought to be solvable only by resources increasing exponentially with the bit size of the key. An example for that is .  But, as far I know, not all problems fall into this category. On , we can read     Researchers have developed a computer algorithm that doesn’t solve problems but instead creates them for the purpose of evaluating quantum computers.   Can we still expect a new cryptographic algorithm which will be hard to crack using even a quantum computer? For clarity: the question refers to specifically to the design of new algorithms.