How we can achieve variables that we defined in the (local ...) syntax in Scheme?
For example in this code below,
(define (erkan x)
(local
((define y 10))
(* x y)))
How can I directly get the value of y ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Either this is a strange question, or you didn’t phrase it right… Your sample code uses
y, so it does have access to it. Maybe you’re trying to get just the value ofy:Or maybe you want to create a kind of an “object thing” — this is possible, but involves more advanced code. Here’s a quick example just to show you how it’s done, (but if you’re going through HtDP, you’re better off leaving this for later).
(Note BTW that this is not proper Scheme, but the teaching student dialects used in HtDP.)