I've been looking over this and I can add "something" to the end of the list, but the issue I'm arriving at is adding, specifically, the first element of a list to the end of that same list.
For example:
{1, 2, 3, 4} becomes {1, 2, 3, 4, 1}.
Here is the code that I'm having problems with:
(define (copy-first-to-end lst)
(cond [(empty? lst)
(cons (first lst) empty)]
[else (cons (first lst)
(copy-first-to-end (rest lst)))]))
The issue with this code is that, for the empty? condition, the answer calls (first lst) but because it is recursive, the first element of this list is empty. Since scheme is dynamically typed, I can't store the first element anywhere (at least I don't think I can).
How can I get this to work, using only the basic list functions? (e.g., cons, cons?, empty? first, last, rest)