- Code: Select all
((4 5 6) (d e f) (h i j) (5 5 5 5)) )
how can i have the last element so that my out put would be
(6 f j 5)
Thanks in advance!
((4 5 6) (d e f) (h i j) (5 5 5 5)) )
(6 f j 5)
(defun getAllLastElems(listOfLists)
(mapcar (lambda (list-elem)
(last list-elem)
) listOfLists)
)
(mapcan #'last '((4 5 6) (d e f) (h i j) (5 5 5 5)))
(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))))))
(defun getAllLastElems(listOfLists)
(mapcar (lambda (list-elem)
(last list-elem)
) listOfLists)
)
(last '(a d 6)) --> (6)
(defun getAllLastElems(listOfLists)
(mapcar (lambda (list-elem)
(car (last list-elem))
) listOfLists)
)
Users browsing this forum: Bing [Bot] and 3 guests