0 Members and 1 Guest are viewing this topic.
'(1 2 3 4 5 6 7 8 9)
(1 3 5 7 9)
(vl-remove-if '(lambda (a / ) (= (rem a 2) 0) ) '(1 2 3 4 5 6 7 8 9))
no recursion needed...
( ( (lambda (rec / ) (eval (list 'lambda '(lst / ) (list rec rec 'lst) ) ) ) (lambda (rec lst / ) (if (not (null lst)) (cons (car lst) (rec rec (cddr lst)) ) ) ) ) '(1 2 3 4 5 6 7 8 9))( ( (lambda (rec / ) (list 'lambda '(lst / ) (list rec rec 'lst) ) ) (lambda (rec rec lst / ) (cond ((null lst) nil) ((zerop (rem (car lst) 2)) (rec rec (cdr lst))) ('default (cons (car lst) (rec rec (cdr lst)))) ) ) ) '(1 2 3 4 5 6 7 8 9))
(defun recursion (l v) (if l ;;; pass the truncated list of the second and remaining items and a list of response items (recursion (cddr l) (append v (list(car l)))) ;;; output the list of extracted items if l is nil v ))
(bar '(1 2 (3 4 5 6 7) 8 9))
(1 (3 4 5 6 7) 9)
Hello .If I have a list in a list it does not return the correct list .Code: [Select](bar '(1 2 (3 4 5 6 7) 8 9))it returns Code: [Select](1 (3 4 5 6 7) 9)But I expected to see this .Code: [Select](1 3 5 7 9)Can anyone give any example to iterate though list in a list please ?Many thanks experts
Can anyone give any example to iterate though list in a list please ?
(defun odd (l) (cond ((null l) nil) ((vl-consp (car l)) (append (odd (car l)) (odd (cdr l))) ) ((zerop (rem (car l) 2)) (odd (cdr l))) (T (cons (car l) (odd (cdr l)))) ))
(1 (3 5 7) 9)
I was in a hurry today and forgot to mention if it is possible to include the brackets from the sub-list . :ugly: Example : Quote(1 (3 5 7) 9)