don't use lambda

Daniel García

Usenet Archive
Joined
Jul 16, 2003
Messages
3
Reaction score
0
Is some way of not using the function lambda there?

(mapcar (function (lambda (a) (apply 'p_ess_normal a))) lis2)

p_ess_normal is my own function

(mapcar 'apply ........)

Daniel Garcia
 
Have you tried
(mapcar 'p_ess_normal lis2)

??

Without the function or the data, that's a guess.
 
no, lis2 is a list of list, p_ess_normal have 3 arguments and apply use the argument in the list

(setq lis2 (list (list ar1 ar2 ar3) (list ar11 ar12 ar13) ......))

apply is necesary

Daniel Garcia
 
Tony,
Very, very nice use of transposition!

Daniel,
Here are two other methods (packaged).
Tony's method is the second one and
probably the cleverest.

;;Recursive method
(defun listproc1 (fun lst)
(cond
((null lst) nil)
((cons (apply fun (car lst))
(listproc fun (cdr lst))))))

;;Tony's transposition method
(defun listproc2 (fun lst)
(apply 'mapcar
(cons fun
(apply 'mapcar (cons 'list lst)))))

;;Iterative method
(defun listproc3 (fun lst / result)
(foreach n lst
(setq result (cons (apply fun n) result))
)
(reverse result))

;;To run any of them: (listproc# 'yourfunction datalist)

And if you do not need the results returned in list form:

(foreach n datalist (apply 'yourfunction n))
 
Thanks a lot

Doug Broad said:
Tony,
Very, very nice use of transposition!

Daniel,
Here are two other methods (packaged).
Tony's method is the second one and
probably the cleverest.

;;Recursive method
(defun listproc1 (fun lst)
(cond
((null lst) nil)
((cons (apply fun (car lst))
(listproc fun (cdr lst))))))

;;Tony's transposition method
(defun listproc2 (fun lst)
(apply 'mapcar
(cons fun
(apply 'mapcar (cons 'list lst)))))

;;Iterative method
(defun listproc3 (fun lst / result)
(foreach n lst
(setq result (cons (apply fun n) result))
)
(reverse result))

;;To run any of them: (listproc# 'yourfunction datalist)

And if you do not need the results returned in list form:

(foreach n datalist (apply 'yourfunction n))
 

Latest threads

Back
Top