This is what I have so far:
(define (graycode n) (let ((e1 "0")) (let ((e2 "0")) (let ((e3 "1")) (let ((e4 "1")) (cond((equal? n 0) (list '())) ((equal? n 1) (list 0 1)) (else((graycode (- n 1) (string-append e1 "0")(string-append e2 "1")(string-append e3 "0")(string-append e1 "1") (list '(e1 e2 e3 e4)))))))))))
Just know I have tried this multiple ways, with 2 lists, with one list. Now I am just trying strings and then putting them in a list once they are changed. If I wasnt at such a loss, I wouldn't have posted here. Honestly though, I do no know what to do next.
Here is the best way I have researched to obtain the gray code sequence: The base case is 1 bit, which results in ( 0 1). To go to n = 2, reflect the bits (it becomes (1 0)), concatenate that list with the original list to get (0 1 1 0) . Then prepend 0 to the original list and the 1 to the reflected list, resulting in ( 00 01 11 10).
However, I figured instead of just prepending you can append then put that value onto a list. This recursive suggestion was given to me by a good mentor of mine at my college.
What do you think?