let

Does 'let' override a global declaration and throws a ReferenceError?

孤者浪人 提交于 2019-12-29 06:14:28
问题 I was going through the Difference between var and let documentation example and was testing that when an undeclared variable is invoked, the global scope automatically provides a declaration for it (that's why the following snippet does not throw an error in any of the variables): x = 3; console.log(x); (function() { y=x+39; })() console.log(y); However, when one variable is declared with let after the assignment in the same global scope: x=3; let x = 42; console.log(x); One of the following

How to implement let as a lambda function in Scheme

半世苍凉 提交于 2019-12-25 14:46:33
问题 As an exercise I am trying to define let as a lambda function something like this: (define let_as_lambda (lambda (var) (lambda (value body) (var body) val))) And I am hoping to call it like this: ((let_as_lambda a) (3 (+ a 2))) However there is no way to pass an unbound variable (in this case "a") as an argument to a function. (I know it looks a little strange but I need let_as_lambda(var) to return a function.) Can anyone show me how to do this? Any advice is appreciated. In fact, just using

Vim - How to search and reaplace based on search [duplicate]

南楼画角 提交于 2019-12-25 04:07:28
问题 This question already has an answer here : VIM - Replace based on a search regex (1 answer) Closed 5 years ago . What i would like to do : Every time i find something based on s[w|l].*[0-9]\.\* replace the end of that string\search .* with %s/\.\*/\\\\\.\.\*/g Already tried with standard search and replace, but couldn't do it. Thanks 回答1: Just wrap your search pattern in escaped parentheses \(\) , and use a backreference \1 in the replacement string: :%s/\(s[w|l].*[0-9]\)\.\*/\1\\\\.*/g You

'let' Keyword in Firefox 43.0.2 not working

Deadly 提交于 2019-12-24 16:03:44
问题 I have read where the 'let' keyword is working now in Firefox, and that the use of specifying the version in the script tag is no longer necessary. HOWEVER, despite adding strict mode, I am still getting the Firefox error: I'd tried block scoping strict mode, using the version in the script tag and nothing seems to be working. Any ideas on what may cause this persistent error for the 'let' keyword in Firefox? Or anything I may be able to eliminate as a cause? Thanx!!! 回答1: According to the

Racket - implementing the let* function using macro

﹥>﹥吖頭↗ 提交于 2019-12-24 01:54:54
问题 I need to implement my_let* using defmacro which works similarly to let*, but while let* is expanded to a series of nested let calls (behind the scenes), my_let* needs to be expanded to a single let call, and use the define statement to define the arguments i get. an example of using my_let*: (my_let* ((a 2) (b 3) (c (+ a b))) (+ a b c)) and the return value of this code should be 10. just as if it was use let*. the code above will be expanded in my_let* to the following: (let () (define a 2)

'number' is never reassigned. Use 'const' instead. (prefer-const)

≡放荡痞女 提交于 2019-12-24 00:18:38
问题 Why in this case eslint 4.17.0 i have error number is never reassigned. Use 'const' instead. (prefer-const). Why i need to use const? Please, explain me i can't understand. let test = { 'number': 1, 'string': 'asd', }; test.number = 99; console.log(test.number); // output: 99 ecmascript { "parser": "babel-eslint", "env": { "browser": true }, "extends": [ "google" ], "rules": { "prefer-const": 2 }, "parserOptions": { "ecmaVersion": 6, "sourceType": "module" } } eslint problem [eslint] 'test'

Avoid expansion of * in bash builtin function let

£可爱£侵袭症+ 提交于 2019-12-22 08:40:41
问题 I have a problem with a bash script. I have to use the operator * to multiplicate. Instead the script bugs me with expansion and using as operator the name of the script itself. I tried with single quotes but it doesn't work :( Here's the code #!/bin/bash -x # Bash script that calculates an arithmetic expression # NO PRECEDENCE FOR OPERATORS # Operators: + - * if [ "$#" -lt "3" ] then echo "Usage: ./calcola.scr <num> <op> <num> ..." exit 1 fi result=0 op=+ j=0 for i in "$@" do if [ "$j" -eq

Scheme Confusing of Let and Let*

微笑、不失礼 提交于 2019-12-22 07:56:15
问题 (let ((x 2) (y 3) (let ((x 7) (z (+ x y))) (* z x))) With the code above, why is the answer 35, not 70? In the second let , x is 7 so z should be 7 + 3 = 10, and then the result should be 7 * 10 = 70. I know got another is let* I am very confusing between this 2. The sample is grabs from google. I already google but just can't get it. 回答1: x is still bound to the outer let when calling (+ x y) . 回答2: To expand on Leppie's answer: if you had written (let ((x 2) (y 3)) (let* ((x 7) (z (+ x y)))

Using the “let” kewword in a LINQ Query with EF 4.3

江枫思渺然 提交于 2019-12-22 05:59:15
问题 I have simple LINQ problem that I can't figure out. I have a table Users and a table Employees . One User can have 0...n employees. I'd like to do something like this: var result = from u in context.users where u.UsrId = 2 let e = u.Employees.First() select new { UserId = u.UsrId, FirstName = e.FirstName }; That does not work of course becasue the First() call is illegal. First() can only come at the end of a select . What also did not work is to select the employee in a previous query like

Why no destructing in def form?

时光怂恿深爱的人放手 提交于 2019-12-21 07:25:55
问题 In a let form (Clojure here) I can doing something like (let [[u s v] (svd A)] (do-something-with u v)) where svd returns a list of length three. This is a very natural sort of thing to do, so why isn't that we don't we have (def [u s v] (svd A)) and its various generalizations as the default behavior of the def form? I don't see how this would interfere with anything that def is already doing. Can someone who understands the Zen of Lisp or Clojure explain why def does not support binding