I wrote a big program that use car and cdr, and do:
(map car (append (map caddr lists) (map cadr lists))
When lists is list of lists in the next format ((a (b) (c)) (d (e) (f))...(x (y) (z)))
When I did it I got one list (b c e f... y z)
(Note: b,c,…y,z is a list of numbers; a,d…x is a symbol)
But now, I found that b,c,…,y,z can be also empty list, and It gives the next error:
car: expects argument of type <pair>; given ()
What can I do?
Have you tried filtering away empty lists before your
map? Something like this:The fundamental issue is that
()is not a pair whilecaronly acts on pairs. The simplest solution is just to get rid of everything that isn’t a pair before mappingcaronto the list; this is what(filter pair? ...)does.