I’m trying to create a list by adding a number to an existing list. The problem is that the existing list is not necessarily actually a list. It could be either an empty list ((list )), just a number, or an actual list.
Basically, I need something like append but it has to be able to handle this case:
(append 1 2) and generate a list (list 1 2)
In addition to the typical case:
(append (list 1 2) 3)
Using append for the first case gives me the error append: expected argument of type <proper list>; given 1
Is there something like append that can handle both of these cases? Or is there some other way to do this?
Thanks!
Try this simple program and tell me if it solve your issue:
References: flatten