Code: Select all
((4 5 6) (d e f) (h i j) (5 5 5 5)) )
Thanks in advance!(6 f j 5)
Code: Select all
((4 5 6) (d e f) (h i j) (5 5 5 5)) )
Thanks in advance!(6 f j 5)
Code: Select all
(defun getAllLastElems(listOfLists)
(mapcar (lambda (list-elem)
(last list-elem)
) listOfLists)
)
Code: Select all
(mapcan #'last '((4 5 6) (d e f) (h i j) (5 5 5 5)))
Code: Select all
(defun mylast(x)
(if (and (listp x) (null (cdr x)) ) (car x)
(mylast (cdr x))))
(defun eachlast(x)
(if (null x) x
(progn
(cons (mylast (car x))
(eachlast (cdr x))))))
Hello, I make an error when writing this last post. The function last return a list not a value(defun getAllLastElems(listOfLists)
(mapcar (lambda (list-elem)
(last list-elem)
) listOfLists)
)
Code: Select all
(last '(a d 6)) --> (6)
That work effiziently.(defun getAllLastElems(listOfLists)
(mapcar (lambda (list-elem)
(car (last list-elem))
) listOfLists)
)