Reputation: 27
I was wondering how I can combine certain lists together in Scheme.
In Particular, I want to combine together a list, such as:
(list 20 (list 10 (list 5 0)))
into something like:
(list 20 10 5 0)
Something simple would be appreciated. Thanks.
Upvotes: 1
Views: 305
Reputation: 235984
In Racket, there's a built-in function that does exactly what you need, it's called flatten
:
(define lst (list 20 (list 10 (list 5 0))))
(flatten lst)
=> '(20 10 5 0)
Upvotes: 1