I wanted to write a function that reverses all the sub-lists in a list (but only the sublists of the top level). I tried to figure out if I could just filter the list and do the reverse before using map by doing
(filter list? (reverse '((1 2) 9 (16 5) 64))), but that just reverses to ((16 5) (1 2)).
I am looking for an output like: ((2 1) 9 (5 16) 64)).
I am supposed to use map and reverse, but I just couldn’t get there to start with.
It’s simple, you just need to ask if each item is a list before trying to reverse it:
filterwon’t work in this case, as you’re interested in processing all the elements in the input list, even though only the actual lists need to be reversed.