[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Avoiding combinatorics



Try this...

(DEFUN DPL? (X)
  (IF (ATOM X) ()
    (DO ((L  (CDR X) (CDR L))
	 (FLAG NIL)
	 (LL (CDR X) (CDDR LL)))
	((NULL LL) T)
      (IF (OR (ATOM LL) (ATOM (CDR LL)))
	  (RETURN NIL) ; bad format
	(IF FLAG (IF (EQ L LL) (RETURN NIL)) ;circular
	  (SETQ FLAG T))))))