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
3 answers

Haskell - List Comprehension - get Input-Elements

I have some problem with list comprehension, if the input is a list. In these all III excercises it's not allowed to use: map, filter and concat!!! Part I Requirements: A funktion f1 gets a list xs of tripels (a, b, cs) where a and b are of type…
John
  • 429
  • 3
  • 8
  • 20
0
votes
1 answer

eval scheme function with quote

I am trying to evaluate a formula in scheme: (define formula '(if (or (equal? '?country 'United-States) (equal? '?country 'England)) #t #f)) (define (eval-formula formula) (eval `(let ([?country…
0
votes
1 answer

let in strange behavior

I have the following program: mnr = [0,1,2,3,4,5,6] :: [Int] name = "Max Mustermann" :: String kzn = "e53X" :: String t1 = ("p1",(take 2.tail)mnr, (take 3.words.(let no n= name;in no))"No"); {-result: t1 == ("p1",[1,2],["Max","Mustermann"])…
sherif
  • 2,282
  • 19
  • 21
0
votes
1 answer

value not of type array

I have created a function that is supposed to have lexical variables of type ARRAY: (defun give-rank-vec (dir-1 dir-2 file-1 file-2) (let* ((cm-size (array-dimension (Swc (make-ff-array dir-1 file-1) …
category
  • 2,113
  • 2
  • 22
  • 46
0
votes
1 answer

undefined variable in let*

For some reason, when I try to C-c C-k the program containing the code: (defun give-rank-vec (file-1 file-2) (let* ((cm-size (array-dimension (Swc (make-ff-array file-1) (make-ff-array file-2)) …
category
  • 2,113
  • 2
  • 22
  • 46
0
votes
1 answer

basic Clojure syntax

Let's say I have a macro, inside the macro I have this let: let[ elements# //stuff// #newlist (for [e# elements#] (if (number? e#) (**add e# to #newlist**))) ] Since I am having a really hard time finding proper information on the really…
Deragon
  • 305
  • 1
  • 4
  • 13
0
votes
1 answer

haskell nested let in lambda

I must miss something but I can't see why this contrived example doesn't work: test1 :: Int test1 = let g = \s -> s + s f = \u -> let h = \t -> t + t h' = \v -> v + v in g (h (h' u)) …
cfchou
  • 1,239
  • 1
  • 11
  • 25
0
votes
2 answers

Iteratively create local variables?

I have created a function that takes an arbitrarily long list of numbers as an argument. From this list, I wish to create matrices locally using let. The matrices will have rows and columns based on the number sequence inside the list. For example,…
category
  • 2,113
  • 2
  • 22
  • 46
0
votes
2 answers

Learning Lisp. Can't seem to get a value from one function and use it within another

I'm trying to find the maximum number within a list, then do something with it: (defun maxList (l) (if (= (length l) 1) (first l) (if (> (first l) (maxList (rest l))) (first l) (maxList (rest l)) …
Kalec
  • 2,681
  • 9
  • 30
  • 49
0
votes
2 answers

Scheme ill-formed special form let

I am trying to write a scheme program which is Dijkstra's Shortest Algorithm. In a procedure when I am relaxing the edges I get the error that ;Ill-formed special form: (let (...) ()) Code of my procedure is, (define relax-over-edge (lambda…
KlaatuSama
  • 21
  • 2
0
votes
2 answers

javascript let not working in various browsers

let doesnt't work in some browsers. Not in their interpeters/ web consoles either. Why? (originally I thought there was an inconsistency b/t the browser interpeter and the jsFiddle, but it turns out not to be true, just bad tests on my part.)
user420667
  • 6,552
  • 15
  • 51
  • 83
-1
votes
1 answer

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 code of 50 variables names ! As all my…
amiens80
  • 21
  • 2
-1
votes
3 answers

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 to declare count it works. I don't know why is this…
-1
votes
1 answer

let and const keyword giving error in typescript after compilation. Where as var works fine

I am very new to typescript i am trying to work out watcing a tutorial. I am face this issue when i use const and let. After compilation ts file shows some error mark. But getting output when using node filename.js. Same code when using var does not…
-1
votes
1 answer

How do I use variable in a query selector - js?

What am I doing wrong? there are 7 pictures with pre-made IDs from "img1" to "img7" function changeWidth() { let b = 50 let k = 0 let l = `"#img${(k + 1)}"`; for (let k = 0; k < 7; k++) …