10 minutes ago, Don Green wrote:
> It is possible to create a cond test-expr that also serves as the then-body,
> however, this means that the expression would be executed twice.
> 
> This seems to be ill advised in principle.

`cond' can have one-expression clauses that serve both purposes:

  -> (cond [(printf "123\n")])
  123

It's convenient to use in rare cases, but I usually try to avoid the
temptation since it feels wartish...


> Question: If it is ill-advised to create a cond test-expression that also
> serves as the then body, then what function is recommend?
> 
> I am aware of the (cdr (or ... form.

(This looks like some assq use, which should benefit from the above.)

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!
____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to