Questions tagged [let]

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

In Lisp-like and functional languages, introduces a list of local variables, each (possibly optionally) with its initial value. It is illegal to refer to any of the new variables while calculating their initial values ( lets you do that), though in Haskell it is legal (its let is actually letrec).

LET is a special form in Common Lisp, Scheme, Clojure and other Lisp dialects which introduces a list of local variables as pairs of name-value bindings, for use within its body. For instance, in this expression:

(let ((variable1 (+ 1 1)))
  variable1)

variable1 gets bound to the 2 value, and the whole expression returns 2 as a result.

728 questions
0
votes
2 answers

Is the variable defined by a let mutable in Common Lisp?

In, for example this let in Common Lisp (let ((a 5)) (print a)) Is a mutable as with defparameter, or is a constant as is the case with defvar?
alan2here
  • 3,223
  • 6
  • 37
  • 62
0
votes
1 answer

About the key word 'let' in JavaScript

var funcs=[]; for(let i=0;i<3;i++){ funcs[i]=function(){ return i; } } alert(funcs[1]); alert(funcs[1]()); The window alert 2 times. The first one like this: function (){ return i; } The second one like this 1 But…
zyMacro
  • 675
  • 7
  • 14
0
votes
1 answer

Assign an object to a let keyword when outside of scope

At the moment, I am using a var that is assigned an object from another hook. I am wanting to change this to a let, but I keep stumbling across errors. Current setup: var tc; module.exports = { before(browser) { tc = new func()(x, y); //…
user860511
0
votes
1 answer

LET and SETF in commonLISP

From what my teacher told me, I should use let to declare local variables and setf to declare global variables. I'm tried running the following code: (let (state-list (problem-initial-state problem)) (print state-list)) and I get NIL. However,…
Rui Loureiro
  • 119
  • 9
0
votes
1 answer

Receiving strict mode warning while running node 4.4.7

I believe node v4.4.7 supports ES6. However node refuses to compile my program: user1-$ node -v v4.4.7 user1-$ node index.js event-service.js:85 let sql = 'SELECT * FROM group_events where id = ?'; ^^^ SyntaxError: Block-scoped…
runtimeZero
  • 26,466
  • 27
  • 73
  • 126
0
votes
1 answer

Can I use 'let' in jsx syntax?

I've tried to create some variables using es6 let in jsx syntax, but firefox gave me an error... I haven't problems when I using var Can I use let in jsx syntax and if it's impossible, can you explain me why?
0
votes
0 answers

Using let get unexpected indentifer

I found one interesting thing for me, but can't understand it. function getPaths(dir, ext) { return new Promise(function(resolve, reject) { execFile('find', [dir], function(err, stdout, stderr) { if (err) reject(err); let fullList…
0
votes
1 answer

how do i do asyncronous calls without let?

I found out yesterday that the iphone does not allow the use of let. This leaves me woundering how to deal with asyncronous calls like ajax and time outs. Bellow is an example code showing the difference. How can I make the var half function the…
0
votes
1 answer

let usage to call another function

I am lost with the following code trying to calculate square roots. The code is: (defn tempsqrt [x p i] (if (< i 2) p (tempsqrt x (+ (/ x (* 2 p)) (/ p 2)) (- i 1)))) (defn mysqrt [x] (let [i 10 p (/ x 5)] (tempsqrt x p…
0
votes
1 answer

How to define a constant in SML in a let binding way?

Is there a way to define a constant in SML in a let binding way. So basically what I'm asking is how to for example do constant x = 5, in the way below: let .... in ... end
Tracy Jackson
  • 11
  • 1
  • 2
0
votes
1 answer

What is going on in this let expression?

I am reading through this blog post about writing an API in Haskell with Scotty, and I came across the section on monad transformers. I understand the concept of monad transformers, but I cannot wrap my head around what's going on here: let r m =…
npj
  • 108
  • 6
0
votes
1 answer

Why can't I used a global variable as part of another global variable's definition in swift?

I don't understand why this is not allowed in Swift: let graphPointCircleDiameter: CGFloat = 5.0 let graphPointCircleDisplacement: CGFloat = graphPointCircleDiameter/2 I get the error: Instance member 'graphPointCircleDiameter' cannot be used on…
jacquelion
  • 149
  • 5
0
votes
1 answer

Getting around let arguments in Swift

Here's a simple playground example: class Foobar { var name = "" init(name:String) { self.name = name } func modifyName(modification:String) { self.name += modification } } let list = [Foobar(name:"I"),…
Travis Griggs
  • 21,522
  • 19
  • 91
  • 167
0
votes
1 answer

Swift "guard let" unwrap failed

Can't unwrap optional type with Swift 2.2, Xcode Version 7.3 (7D175) "guard let" failed But "guard var" works Please, help! What is going on here? EDIT1 let localPresenter = presenter let localDataSource = dataSource let configurator:…
adnako
  • 1,287
  • 2
  • 20
  • 30
0
votes
1 answer

Scheme: Convert from Let to Lambda

so I'm trying to experiment with some code and change between the two scheme expression methods of let and lambda. The code I have is as follows: (let splice ((l '()) (m (car s)) (r (cdr s))) (append (map (lambda (x) (cons m x))…