Questions tagged [let]

In Lisp-like and functional languages, introduces a list of local variables, each (possibly optionally) with its initial value.

Filter by
Sorted by
Tagged with
-6 votes
0 answers
20 views

How to use while() loop in JavaScript? Printing a code for nth element of Fibonacci series is possible with while loop? [closed]

My problem is to print nth element in fibonacci series using while loop in java script without using recursion. As I am a beginner I was not able to solve this problem. I tried it by declaring two ...
Utkarsh Raj's user avatar
-2 votes
1 answer
89 views

Which function is executed if both has same variable names n declared?

let foo = function(){ console.log(1); } setTimeout (foo,1000); foo = function(){ console.log(2); } I got the output as 1. But I need to know why because let can be reinitialized so its ...
sujithrakumaran's user avatar
1 vote
1 answer
53 views

Excel VBA Setting Item as the Default for the Class Property Get and Let

I created this class to experiment with it. My goal is to see if I can read/write data in this format: x = AppInventory(r,c): AppInventory(r,c) = x x = AppInventory("A1"): AppInventory("...
Mark Main's user avatar
-3 votes
2 answers
75 views

How do i get rid of "" in output? (Javascript)

With this code i want to achieve output name: Gunnar but I get { name: 'Gunnar' }, how do I remove the '' around Gunnar in the output? let keyName = "name"; let value = "Gunnar"; let person = { ...
Matilda123's user avatar
4 votes
1 answer
86 views

Difference between `function` and `let` blocks in Julia?

In Julia, is there any difference at all between these to two three ways of creating a function: With keyword function function g1(x) # compute something, store it in `result` return result # (...
Olivier Verdier's user avatar
2 votes
1 answer
33 views

Scopes captured by an EventListener include all let variables but not var variables?

I have the following code for attaching an event listener to a html element. I understand that the callback for this event listener forms a closure with its lexical environment. var submit = document....
Ends of Invention's user avatar
3 votes
2 answers
91 views

Under any Scheme standard, is (let (x y z) x) valid code?

In both Emacs Lisp and Common Lisp, the following returns nil (let (x y z) x) yet in every Scheme that I've tried, it throws an error. Has the above been acceptable under any Scheme standard?
J. Mini's user avatar
  • 1,982
0 votes
1 answer
44 views

In 'The Scheme Programming Language' what is this strange 'let' form in '(reverse)'? [duplicate]

From The Scheme Programming Language, written by R. Kent Dybvig, I see this definition of reverse: procedure: (reverse list) returns: a new list containing the elements of list in reverse order ...
durandaltheta's user avatar
1 vote
1 answer
30 views

IIFE strange behavior linked to variables declared with let or var

I try to understand why the variable 'Permissions' will be typeof 'function' when Permissions declared with var but typeof 'object' when declared with let (which is the excepted behavior) With 'var' - ...
Edi's user avatar
  • 13
0 votes
2 answers
47 views

Javascript compiler error in Chrome's console

I was doing some javascript coding in chrome's console. When I do: console.log(x); let x; It gives "ReferenceError: x is not defined" But when I run the below code: let x; console.log(x); ...
Akrit's user avatar
  • 99
4 votes
5 answers
182 views

Why does "setf" not work when using "let"?

The behavior of setf when combined with let is confusing to me. Here, setf isn't changing the second value of my list. (defun to-temp-field (lst) (let ((old-value (nth 2 lst)) (new-value '...
Antonio Solana's user avatar
-3 votes
1 answer
27 views

JavaScript- let showing name instead of value [closed]

I am a beginner and Started learning JavaScript today. I tried from a tutorial: let a = 1 console.log('a') Now,when I run it, the answer should be the value which is 1, but it shows me the name ...
Australia Account's user avatar
2 votes
2 answers
135 views

Semantics of `let` assignment in Nim

Semantics of let assignment in Nim I was recommended the Nim programming language and started reading through the Tutorial 1, the Manual and even the memory model (in particular the section about ...
Federico's user avatar
  • 582
0 votes
0 answers
33 views

Is there a logic error in the LET variables definition type? [duplicate]

There is a code between the 1st log and the 2nd log. I assign the validate variable to the s variable using the let definition type. console.log(validate); // 1. log let s = validate; if (s.location ...
Berke Türk's user avatar
2 votes
2 answers
77 views

How to use “Let” Aggregate options in mongo-go-driver?

Trying to use mongo-go-driver SetLet in the aggregate options to pass user variables defined earlier in my function into my aggregation pipeline. Trying to parse the documentation for this… SetLet ...
Tyler's user avatar
  • 91
1 vote
0 answers
67 views

Script Scope in JS

I was going through Lexical environment and environment record / scope in JS. I know difference (partly) between var and let (one being block scoped, while one being functional scope) and also the let ...
Sourish Mukherjee's user avatar
1 vote
1 answer
42 views

Let block not working, giving "Only safe (?.)..." error

My parent variable is nullable, and haves a getWidth function. I want to call getWidth only if parent is not null, so I did this let function: return parent.let { it.getWidth() * (perWidth / 100....
NullPointerException's user avatar
0 votes
0 answers
27 views

Substituion of a Let(name, bound, body)-Expression (pseudo code)

one of my tasks in my studies is to consider which of those possibilities of that pseudo-code is right. I have to take care about variable shadowing and variable capturing. Here's following task: (let ...
Opticpeak's user avatar
1 vote
1 answer
38 views

Why TSPL's letrec example can be run in ChezScheme with only let?

In TSPL 3.2 we find: (letrec ((even? (lambda (x) (or (= x 0) (odd? (- x 1))))) (odd? (lambda (x) (and (not (= x 0)) ...
wang kai's user avatar
  • 1,725
0 votes
0 answers
35 views

variable in scheme let expression inexplicably not bound [duplicate]

I get an error that dataInput is not bound. I don't know why. It seems like a valid let expression. Please explain. Thanks very much! (define imageList "/home/perry/dir_image_search_list&...
Trenton J's user avatar
0 votes
1 answer
45 views

let in and the use of ; vs ;;

I have this chunk of code below. I'm a bit confused as to how the let in syntax should work. I was under the assumption that the let in let you use that variable in the scope of in. Although, I don't ...
null's user avatar
  • 17
1 vote
3 answers
297 views

Are (let) and (lambda) equivalent in Common Lisp

I'm reading On Lisp by Paul Graham, trying to better understand the functional style of programming. In Chapter 3, he mentions that functional programs "work by returning values" rather than ...
myselfesteem's user avatar
0 votes
0 answers
28 views

Solr - using result value from ''let"

When I call solr using curl: curl "http://localhost:8983/solr/colection/select?q="*:*"&rows=5&fl=$result&let=(result:ceil(mul(dist(2,v0_d,v1_d,v2_d,0.01595742627978325,0....
Sérgio's user avatar
-1 votes
1 answer
22 views

how to build a expression with a lot of variables having the same name pattern?

i have 50 variables in my system script. All have the same kind of naming like : $case_un $case_deux $case_trois ... $case_fourthy I need to build a expression with all of them without writing the ...
amiens80's user avatar
0 votes
1 answer
22 views

There is a div I made contains the number of 8

I'd like to make a countdown to make this number decrease to reach 0 and then stops, I tried to made this by setInterval, but it doesn't work I don't where the problem is because there's no error let ...
Abdelrahman Reyad's user avatar
1 vote
1 answer
61 views

Re-declaring arrow function [duplicate]

tried to re-declare an arrow function-- (Check code) Why is it giving error when var can be redeclared. I made an arrow function using var then tried re-declaring it using let as var can be ...
leo_00's user avatar
  • 13
0 votes
0 answers
18 views

JS bind function doesn't get value of object defined using var keyword

Output of both these snippet is different. Snippet 1: var name={ firstname:'abc', lastName:'xyz' } let pname= function(){ console.log(this.firstname+' '+this.lastName); } pname.call(name); OUTPUT:...
Akshay's user avatar
  • 41
0 votes
1 answer
39 views

how do I toggle a part of code that has an if-else statement?

if i have a certain part of code I want to be flipped on and off, and I have a line of code that does that, why doesn't it want to work? let b = Math.floor(Math.random() * 10) let a = Math.floor(Math....
5pac31nvad3r's user avatar
0 votes
3 answers
118 views

Is there a way to edit values in list after %let in SAS

I created a macro variable: %let hi = ('g', 'c', 'v', 'd'); I want to put this list in code but need to add %% for each value, looks like this('%g%', '%c%', '%v%', '%d%'). is there a way i can get the ...
Irine's user avatar
  • 3
1 vote
2 answers
110 views

Getting value in a let-binded list (Common Lisp)

In below situation, I want to get same results for a and (car b) like (10 10). But just symbol A is shown as a result of (car b). Can we get 10 with like (something (car b)) code? (let* ((a 10) ...
LMB's user avatar
  • 13
2 votes
1 answer
81 views

Why in some cases some come works when pattern matching via case-of, but not via a let binding?

I'm trying to understand singletons. As an exercise I'm manually defining an instance of SingKind for a custom List type: data List a = Nil | Cons a (List a) data SList :: List a -> Type where ...
Blue Nebula's user avatar
0 votes
0 answers
22 views

What is execution context of of globally declared let ,const and Arrow Function In JavaScript [duplicate]

In Global Execution the declaration of var and regular function is executed on the top. But I don't understand how the execution happened to let, const & and arrow functions when are declared ...
Muhamamd Faad's user avatar
-1 votes
3 answers
54 views

I am trying to increase the count variable using this, but let is creating problem , whereas var works fine

I am trying to understand how "this" keyword works and trying to increase the count variable using a function. But If i use let to declare count, count does not increase , but if i use var ...
Dhruv Bhatnagar's user avatar
0 votes
1 answer
64 views

Is the "let" keyword required when declaring the index variable in a for-loop?

Sorry if this is very basic. I'm new to Javascript and can't seem to find an answer anywhere. I realized while coding that I've been omitting the let keyword from my for loops. But in all the ...
Capra Irata's user avatar
0 votes
0 answers
27 views

why the parameter in javascript ii is NaN when i run the code below in google chorme? [duplicate]

It's a small game of guess number but why the parameter in javascript ii is NaN when i run the code below in google chorme? ii should be already a int type because i use the parseInt method ...
zfing's user avatar
  • 3
1 vote
0 answers
141 views

Chrome extension: open new tab as mobile device

I've made for myself a Chrome extension in order to perform automatically Bing Searches. This code works perfectly. I would like to extends this function adding the automatic search as mobile device (...
Steve's user avatar
  • 406
0 votes
1 answer
128 views

Vim: Easy way to convert recorded macro into let

I want to save a certain macro permanently so that I can replay it in future sessions. For instance, I record the macro which surrounds selected words with ** (like **this text is strong**): Switch ...
Culip's user avatar
  • 559
-3 votes
3 answers
110 views

JS calling ID by variable

Hi All First data: let NewDivForGame_0 = document.createElement('div'); let NewDivForGame_1 = document.createElement('div'); let NewDivForGame_2 = document.createElement('div'); and so on....
KimL's user avatar
  • 1
1 vote
0 answers
86 views

`let` inside a refinement type

I have a Liquid Haskell refinement type that looks like this: {-@ addDigit :: c : Bool -> x : Digit -> y : Digit -> { v : (Bool, Digit) | fst v = ((x + y + if c then 1 else 0) &...
Cactus's user avatar
  • 27.1k
0 votes
1 answer
77 views

translating a let as lambda

From page 69 of R⁷RS I know what I can substitute a let with a lambda: (let (a 10) something) ; is equivalent to (lambda (a) something) 10 So I took this (from SICP): (define new-withdraw (let ((...
gobbolo22's user avatar
2 votes
2 answers
234 views

Repeat values n times where n could also be 0.5

I saw the following question on here regarding repeating values: List number of lessons including half lessons based on Number of lessons and lesson name This question needed an older Excel version, I ...
P.b's user avatar
  • 10.7k
0 votes
0 answers
25 views

In what moment does variable declaration occur? [duplicate]

As I understand it, all code is executed in 2 stages: initial code scan (compilation) and code execution. However, it's still not entirely clear to me at what stage the declaration of variables occurs....
Nikita's user avatar
  • 1
0 votes
0 answers
14 views

Let in javascript is block scope. So how did this code does work? [duplicate]

Let is block scope . But I have found this codes output wired. how the let declared in window can be accessed in another function? let wind ="something blah blah"; function trial(){ console....
Mubasshir Miraj's user avatar
5 votes
1 answer
894 views

Can't pass a range to a lambda using Let and Makearray functions

Referring back to this question, I wish to create a running total in an array, but starting afresh in each row of the array 1 2 3 4 5 6 7 8 resulting in 1 3 6 10 5 11 18 26 One solution is to ...
Tom Sharpe's user avatar
  • 31.5k
0 votes
1 answer
139 views

Why will this switch statement only work with a single case?

Why will this switch statement not work? It will only work when I remove all but one (any) of the cases. It seems to get the values correctly and match them up to the correct case but when there is ...
domo's user avatar
  • 27
1 vote
1 answer
197 views

Calculate production capacity per product/day up to goal

I have the following data. Available resources data per day: A B C D E F G H I J K L M N 2 resources day 3 1 2 3 4 5 6 7 8 9 10 11 12 4 empl.1 8 8 4 2 2 4 4 8 8 5 empl.2 8 4 4 8 4 8 6 ...
P.b's user avatar
  • 10.7k
1 vote
0 answers
216 views

Performance problem with INDEX function and names introduced inside LET/LAMBDA

Excel's INDEX function shows strange behaviour when the object being indexed is a name introduced in a LET construct or a parameter of a LAMBDA. The behaviour is consistent on Windows and Mac. Suppose ...
JohnB's user avatar
  • 13.4k
0 votes
2 answers
331 views

data is not defined when using let in react

I am trying to dynamically use data in my jsx, so when I use let to declare a variable called "data", and change its values in different cases, it says data is not defined during ...
jimzhou's user avatar
  • 61
1 vote
1 answer
56 views

declare variable using let give different output than declare using var in JavaScript? [closed]

I have declare variable x using let. In the output of this program , the value of x is not visible. but when I declare x using var , I can see the output of this line . var x = "5" + 2 + 10; ...
varsha goyal's user avatar
1 vote
1 answer
104 views

Including additional table columns into Let function constructed table with the ability to sort based on column value Excel

I have the following function giving a list of available staff after a specified date set in T2 =LET(uniqueEmployees,UNIQUE(AllStaffProjectAllocationTbl[Employee]), maxDatePerEmployee,BYROW(...
Automation Monkey's user avatar

1
2 3 4 5
15