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
1 answer

Cannot assign to a value if it's a let constant - ERROR

Here is my code : var firstNumber: Double var secondNumber: Double var result: Double var delegate: ComputeDelegate! init(delegate: ComputeDelegate){ self.delegate = delegate } func add(result: Double) -> Double { result = firstNumber…
Dani Turc
  • 39
  • 2
  • 11
0
votes
1 answer

I have some difficult in understanding Scheme Source Code

The following is the sample code i downloaded for the problem: A counter increments by one, modify it for passing as argument the value used for incrementing. E.g., (let ((c (create-counter))) (+ (c) (c) (c) (c))) => 6 (let ((c (create-counter 2)))…
kp2349
  • 107
  • 1
  • 14
0
votes
0 answers

Declaring multiple variables locally and use them to do something

Suppose we have a list of pairs, ex. '((a . true) (b . false)) How do I declare it within a function and use the variable to do something else? (say using it to evaluate boolean expressions like (a and b)) Currently I have (define foo2 (λ…
Chase
  • 93
  • 10
0
votes
1 answer

Correct syntax of let ... in and where clauses in Haskell

I am trying to declare local variables (is this the right term in the case of haskell?) in haskell using where and let-in clauses. However whenever my clauses are longer than a single line I always get some parse errors: > letExample :: Int -> Int >…
gen
  • 9,528
  • 14
  • 35
  • 64
0
votes
2 answers

Check the value of a constant in Swift

So I'm coding my first app, yeah, from scratch and I never done anything like it before so please bear with me. I wanna take the randomised value of the first constant and use it to determine the content shown on screen through a label upon a view…
0
votes
2 answers

Lisp: How to use let function to combine 2 lists into 1 list?

I want to create a function that could read my 2 input lists and combine what are inside the lists in to 1 lists, which allows me to use this 1 list for another function. I have tried to use let function (defun sumup(p1 p2) (let ((sum…
mesue
  • 23
  • 3
0
votes
4 answers

Swift 2.0 and let warnings

I have a problem in swift 2.0 here is the current block of code that I write: let URL = NSURL(string:"www.google.com") and then I get the following warning:"initialization of immutable value URL was never used, consider replacing with assignment…
Jonathan Meguira
  • 1,860
  • 2
  • 12
  • 15
0
votes
2 answers

Using "let" to assign a tuple to a value in sml

Im trying to write a function that does the following, takes in : [ #"t" ,#"h" ,#"e" ,#" " ,#"c" ,#"a" ,#"t" ] The following is the output: ( [#"t" ,#"h" ,#"e" ] , [#" " ,#"c" ,#"a" ,#"t" ] ) so far I have.. fun isLetter c = #"a" <= c andalso c…
James
  • 1,259
  • 1
  • 10
  • 21
0
votes
1 answer

Subtract two dates with 'let' variable then average()?

Attempting to subtract two dates from one another to figure out the number of days, then execute .Average() on the 'let' variable avgConversion. I encounter the following error; LINQ to Entities does not recognize the method 'System.TimeSpan…
JReam
  • 898
  • 2
  • 13
  • 28
0
votes
2 answers

Why does Xcode keeps insisting on using let rather than var?

With one of the recent Xcode updates it keeps telling my to try and use "let" rather than "var". Why? I would have thought "var" would be the best to use and to only use "let" in specific situations.
HeeHeeHaha
  • 139
  • 1
  • 1
  • 8
0
votes
1 answer

line statement using a macro variable

I want to what does the .(dot) meant in the following sas line statement: (line &ls.*"_";) I know the ls is a macro variable but what does the dot mean? option pageno=1 nodate center; %let ls=68; %let ps=20; proc report data=class2 LS=&ls…
Anne Ortiz
  • 133
  • 1
  • 1
  • 5
0
votes
1 answer

Nested Let syntax in haskell confusion

main = let sumSquares = sum (map (^2) [1..100]) squaredSum = sum [1..100] ^ 2 in sumSquares - squaredSum New to Haskell, so I've been going back through Project Euler. I know my solution is sound, and it works when I don't…
user4933255
0
votes
0 answers

What's the difference between LexicalEnvironment and VariableEnvironment in ES6?

There was a similar question Clarity on the difference between “LexicalEnvironment” and “VariableEnvironment” in ECMAScript/JavaScript posted on SO two years ago, but it was based on ES5. I'm learning ES6 now and encountered some fun facts. For…
leslie.zhang
  • 381
  • 4
  • 14
0
votes
2 answers

How to understand specific F# syntax

At the end of this statement: let (a,b,c) = (1,2,3) in printfn "%i,%i" a b;; , there's a b;; What's the usage of the ending "a" and "b", are they parameter of some function call, or, are they a return value(tuple) of previous function? If so, what…
vik santata
  • 2,989
  • 8
  • 30
  • 52
0
votes
1 answer

OrientDB - LET variable in where

I have a query very similar to this: SELECT FROM Post LET $category = (SELECT EXPAND(out('PartOf')) FROM $current), $poster = (SELECT EXPAND(in('Posted')) FROM $current) WHERE $poster <> #18:1 AND $poster IN (SELECT EXPAND(out('IsUser')) FROM…
Daro Govergun
  • 117
  • 2
  • 12