Help reducing a Lisp function -


i have lisp function returns either max of 2 values, or min of 2 values. right code has relatively complex expressions evaluate value1 , value2.

(defun treemax (bilist &optional ismin)   (cond     ;; compute minimum     (ismin (min (complex_expression_1) (complex_expression_2)))     ;; compute maximum     (t (max (complex_expression_1) (complex_expression_2))))) 

the problem here complex_expression_1 , complex_expression_2 take many many lines of code. not repeat them. there more efficient way of calling this?

essentially i'm trying unary-if on functions rather values. if familiar c or variants, concept i'm looking is:

((ismin ? min : max) complex_expression_1 complex_expression_2) 

whereby conditionally select function send arguments to. make sense?

(defun treemax (bilist &optional ismin)     (funcall (if ismin #'min #'max)               (complex_expression_1)               (complex_expression_2))) 

Comments

Popular posts from this blog

Delphi Wmi Query on a Remote Machine -