Reputation: 3
I would like to declare three lists on which to do operations, but using define
their value does not change. So I thought I'd use let
but it gives me an error.
(let ((A '0)
(B '0)
(C '0)
)
)
I expect 3 lists but it gives me this error:
let: bad syntax (missing binding pairs or body) in: (let ((A (quote 0)) (B (quote 0)) (C (quote 0))))
Upvotes: 0
Views: 4208
Reputation: 15793
writing let
with no body is the same as defining a lambda function with no body.
(let ((A '0)
(B '0)
(C '0)
)
)
is the same as writing
(lambda(a b c) ) 0 0 0) ;; here it is not allowed to define function with no statement inside
('0 is evaluated to itself).
Upvotes: 1
Reputation: 48745
(let ((a 0) (b 0) (c 0))
;; a, b, c lives inside this let block
(list a b c)) ;; a body of the let that makes a list (0 0 0)
;; a, b, c from the let block no longer exist
The Scheme report expect you to use the binding for something. Thus after you have defined the bindings of the let it is expected that there is at least one expression inside it that does something. The let
is just syntax sugar for this:
;; anonymous lambda call
((lambda (a b c)
(list a b c)) ;; body of the lambda that makes list (0 0 0)
0 ; a
0 ; b
0); c
Now imagine what this is supposed to do:
;; anonymous lambda call
((lambda (a b c)
;; no body that does anything
)
0 ; a
0 ; b
0); c
Upvotes: 1
Reputation: 1028
You did it right but there was code missing
(let ((A '0)
(B '0)
(C '0)
)
you need code here
)
Upvotes: 0