I am new to lisp and I am trying to code a function that will turn a list with sub-lists such as (1 2 (3 (4)) 5) in to a list like this (1 2 3 4 5). The thing is, I have no idea how to put 2 orders in one condition. For example here is my code
(defun Func1 (x y)
(cond
((null x) y)
((listp (CAR x)) (Func1 (CDR x) (append y (CAR x) )) )
(T (Func1 (CDR x) (CONS (CAR x) y) ) ) ) )
Well, I know that I need to change the second condition, so if the first element of x is a list, then i will call the same function like (Func1 (CAR x) y) but if I do that i will only get the items of the sub-list and I am going to lose the other part of the list. So basiclly, my question is, how do I tell LISP that after it finishes with this line
((listp (CAR x)) (Func1 (CDR x) (append y (CAR x) )) )
it should continue executing the other line
(T (Func1 (CDR x) (CONS (CAR x) y) ) ) ) )