(define (getFirstFew lst)
(cond
((= (read) 0) '()) ;returns nothing
(else(cons (car lst)(getFirstFew (cdr lst)(- (read) 1))))))
That is my code above. So i'm trying to write a procedure that will get the first x elements (user gets to choose what x gets to be) from a list. For example, input 4 with (getFirstFew '(1 6 2 4 5)) will result in '(1 6 2 4).
My current problem with this is that with using read two times, it gets called twice and then breaks the program. Is there a way for me to store whatever the user inputs into a variable and then use that variable throughout the program? Or is there another solution to this problem?