I'm having trouble wrapping my head around a way to use recursion to create a list and then returning that list for the base case. Specifically, I'm entering two 32 bit numbers (x1 and x2) into an ALU and evaluating them bit by bit (via ALU1) and then creating a list of the resulting number. My base case for this recursion algorithm is (null? x1) but at this point, how do I access the resulting list? I know lists in scheme are immutable, so I can't just create an empty list and append the resulting list to it. Any help? This is my first go at functional programming, so thanks in advance.
(define ALU-helper
(lambda (selection sub x1 x2 carry-in n)
(if (null? x1)
(________?)
(cons
(ALU1 selection sub (car x1) (car x2) carry-in n)
(ALU-helper selection sub (cdr x1) (cdr x2) carry-in (- n 1))))))