How can I flatten a racket list recursively?

29 Views Asked by At

I'm using racket at college, and the teacher wants us to make like a flatten function of Racket, but recursively, and sincerely I don't know how can I enter a list containing other list to delete that parenthesis, anyone that can give me a idea of how can I start

I've tried a lot of different things in the else part, but it didn't get me the result I want, so I decided to leave the code at this point

(define (flat lst)
  (cond [(null? lst) '()]
        [(not (pair? lst)) (list lst)]
        [else (cons (flat (car lst)) (flat (cdr lst)))]))
0

There are 0 best solutions below