Reputation:
I have the given struct :
(define-struct clr ( r g b a)
and I want to have a list out of it:
(list (list r)(list g)(list b)(list a)
My current code:
(define clrTolist
(lambda (clr)
(map list (list clr))))
(clrTolist (make-clr 0 0 0 0))
That is the result i'm getting :
list (list (make-clr 0 0 0 0)))
I don't want the structure name to be shown on my end list.
Upvotes: 1
Views: 91
Reputation: 33
You can "access" single values from struct by using this syntax:
id-field
So in your case
clr-r myred
will return specific value of r for element myred
You want to create a list, consisting of all values of your element so just try
(list (clr-r clr) (clr-g clr) (clr-b clr) clr-a clr))
Make sure to understand structs and its definitions. I recommend this Chapter from HtdP https://htdp.org/2003-09-26/Book/curriculum-Z-H-9.html#node_chap_6
Upvotes: 1