Questions tagged [let]
In Lisp-like and functional languages, introduces a list of local variables, each (possibly optionally) with its initial value.
745
questions
1
vote
2
answers
23
views
SAS creating global macro and printing it
I am new to SAS environment. I just want to create a global this month variable and print it & use it
in the where condition of data step. My test codes are below:
%macro vars();
%...
1
vote
1
answer
314
views
angular 18 - @let syntax in templates
The Angular team just implemented the new @let syntax in templates. According to this comment it's implemented in this commit, which should already be released in version 18.0.2
I updated my NX ...
1
vote
0
answers
6
views
Is there an R function that minimise a bivariate function f
I need to write a code that using the R function constrOptim, minimise an bivariate function. Please tell me what is wrong in the constrOptim , went i run the code i have this warning message
"...
0
votes
0
answers
43
views
SwiftUI view running twice
I have a view that draws some lines and filled circles. But to know the position of these lines I need to dynamically calculate them as they are being drawn.
I have two issues.
The first is that for ...
0
votes
1
answer
31
views
How to fix SwiftUI: Initializer for conditional binding must have Optional type, not 'ChatMessage' [duplicate]
I am a beginner in SwiftUI and I am trying to create a chat app with firestore. I have this issue and I looked many articles but I can't fix it. I'd be very happy if you help me! Thank you!
My Code:
...
1
vote
1
answer
35
views
Why does declaring a variable without a keyword result in a SyntaxError for var and const, but not for let in JavaScript? [duplicate]
Declaring variable in JS without keyword.
I get SyntaxError when I declare variable like var = 1 or const = 1. But I don't get this error when i declare like let = 1. Why is this happening?
var = ...
2
votes
2
answers
154
views
Performance increase using `let`?
Compare the following two snippets:
expensiveFunction :: [Integer] -> [Integer -> Bool]
expensiveFunction [] = [const False]
expensiveFunction (x:xs) =
let temp = expensiveFunction xs
in [...
0
votes
0
answers
48
views
How to find out how many of each 2, 3 and 4 required to fit in 100 using excel?
I want to determine the numbers or counts of each 2, 3, and 4 required to fit in 100.
I got the formula in Excel which can only return the numbers for two given variables i.e. 2, 3. I want to try for ...
4
votes
1
answer
149
views
How to programmatically expand the let* family of functions in racket
Context
This question is tangentially related to a homework assignment, but I am not looking to have someone do my work for me.
I have an assignment where we are discouraged from overuse of let, let*, ...
1
vote
2
answers
77
views
Trying to get names from a box on the right to automatically appear in another box when a different box has a value in it
hope the title wasn't too confusing.
this is my project:
I'm trying to figure out how to get the names on the right (NICK-GL) to stack on top of each other at the bottom, when one of the mon-fri ...
2
votes
2
answers
76
views
Set variables declared through let* as ignorable
I am trying to write a macro that would generate code that looks like:
(defun test ()
(let* ((_ (exp1))
(_ (exp2))
...
(_ (expn)))))
The (expn) calls might be ...
2
votes
1
answer
89
views
LET with LOOP construct in Common Lisp
I have the following code:
(let (liste (loop for item from 1 to 20 collect item))
(format t "~{~a~}~" liste))
However portacle complains: The variable FOR is unbound. Why?
0
votes
0
answers
39
views
consC in Seasoned Schemer
The seasoned schemer on page 131 and 132 has the below definition of consC and deep.
(define consC
(let ((N 0))
(lambda (x y)
(set! N (add1 N))
(cons z y))))
(define deep
(lambda (...
1
vote
1
answer
262
views
Non-state variable inside SwiftUI View
I just rewatched Demistify SwiftUI and noticed that some of the examples use variable properties inside a SwiftUI View, without using the @State property wrapper. For example (around 19.04):
struct ...
-2
votes
1
answer
94
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 ...
1
vote
1
answer
119
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("...
-4
votes
2
answers
83
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 = {
...
4
votes
1
answer
336
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 # (...
2
votes
1
answer
38
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....
3
votes
2
answers
100
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?
0
votes
1
answer
47
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
...
1
vote
1
answer
35
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' - ...
0
votes
2
answers
100
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);
...
4
votes
5
answers
261
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 '...
-3
votes
1
answer
28
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 ...
2
votes
2
answers
160
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 ...
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 ...
2
votes
2
answers
227
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 ...
1
vote
1
answer
204
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 ...
1
vote
1
answer
155
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....
0
votes
0
answers
31
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 ...
1
vote
1
answer
42
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))
...
0
votes
0
answers
37
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&...
0
votes
1
answer
69
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 ...
1
vote
3
answers
463
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 ...
0
votes
0
answers
40
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....
-1
votes
1
answer
23
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 ...
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 ...
1
vote
1
answer
73
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 ...
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:...
0
votes
1
answer
49
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....
0
votes
3
answers
197
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 ...
1
vote
2
answers
131
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)
...
2
votes
1
answer
82
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
...
0
votes
0
answers
24
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 ...
-1
votes
3
answers
93
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 ...
0
votes
1
answer
137
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 ...
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
...
1
vote
0
answers
241
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 (...
0
votes
1
answer
245
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 ...