vendredi 18 octobre 2019

lisp: properly calling a function with 2 parameters which depend on each other

Let's say, I want to call function foo, which requires 2 arguments a and b. (foo a b).
And in some use cases, the values of those parameters depend on each other, like this:

(let (a
      b)
  (if (something-p)
      (progn 
        (setq a 'a1)
        (setq b 'b1))
    (progn
      (setq a 'a2)
      (setq b 'b2)))
  (foo a b))

Is there a (lisp) pattern for this kind of problem? (Or do I need to write my own macro for that?)

Aucun commentaire:

Enregistrer un commentaire