Function: cond

cond is a special form defined in eval.c.

Signature

(cond CLAUSES...)

Documentation

Try each clause until one succeeds.

Each clause looks like (CONDITION BODY...). CONDITION is evaluated and, if the value is non-nil, this clause succeeds: then the expressions in BODY are evaluated and the last one's value is the value of the cond-form. If a clause has one element, as in (CONDITION), then the cond-form returns CONDITION's value, if that is non-nil. If no clause succeeds, cond returns nil.

Probably introduced at or before Emacs version 1.5.

Source Code

// Defined in /usr/src/emacs/src/eval.c
{
  Lisp_Object val = args;

  while (CONSP (args))
    {
      Lisp_Object clause = XCAR (args);
      val = eval_sub (Fcar (clause));
      if (!NILP (val))
	{
	  if (!NILP (XCDR (clause)))
	    val = Fprogn (XCDR (clause));
	  break;
	}
      args = XCDR (args);
    }

  return val;
}