I'm new to Racket/Scheme (just learning it at my university) and I want to create a record named flower
which has an attribute called flower-coordinates
which should accept a touple or something like that, aka. x and y coordinates in the form '(x y)
I am using DrRacket with the language preset: "Beginner: custom" which seems to simplify the language itself. I hope anyone knows that.
I've written following lines of code up until now:
(define-record flower
make-flower
flower?
(flower-name string)
(flower-waterlevel natural)
(flower-coordinates tuple)) ; <----- problem!
(define new_flower (make-flower "Blubb" 50 '(23 12)))
tuple
is not defined, which makes sense, since it does not exist in Racket but is there a way of how I could reference that here? As you might have noticed, I am a complete noob in Racket.
define-record
is provided by the deinprogramm
teaching language (Schreibe Dein Programm!), so I guess your "Language: Beginner - Custom" is based on that. Try, whether your language provides list-of
:
(define-record flower
make-flower
flower?
(flower-name string)
(flower-waterlevel natural)
(flower-coordinates (list-of natural)))
(define new-flower (make-flower "Blubb" 50 (list 23 12)))
If your language is Schreibe Dein Programm! - Anfänger (or it doesn't provide list-of
), you have to define a new record for coordinates:
(define-record coordinates
make-coordinates
coordinates?
(x natural)
(y natural))
(define-record flower
make-flower
flower?
(flower-name string)
(flower-waterlevel natural)
(flower-coordinates coordinates))
(define new-flower (make-flower "Blubb" 50 (make-coordinates 23 12)))