I was trying to define a data structure initialization function like \'(() ()), so that I can generate many of it later.
Right after I defined it, the init function
Make your init
function return (list '() '())
instead of '(() ())
. This will cause it to return a new list each time it's called.
Literal data, like '(() ())
, is immutable. That means that trying to mutate it using set-car!
has undefined behaviour. The reason for this is that implementations are allowed to return the same instance of the literal data each time it's evaluated, so in this case, with your original code, each call to init
was actually returning the same list.