1

I have been given a struct to work with:

(struct Binding (id (value #:mutable)))

This struct represents a variable binding such as (set! x 3) where I would expect id = x and value = 3.

How do I create and initialize this struct? How do I get the values of id and value and to set the value of value?

1
  • 2
    Re: textbook request. Have you seen "How To Design Programs"? It's written by the authors of Racket, it's got five stars on Amazon, and best of all, it's available online at htdp.org. Commented Feb 28, 2011 at 16:53

1 Answer 1

4
> (struct Binding (id (value #:mutable)))
> (define b (Binding 'x 123))
> (Binding-id b)
'x
> (Binding-value b)
123
> (set-Binding-value! b 456)
> (Binding-value b)
456

(See also the documentation page on structs.)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.