Posted on Leave a comment

Lisp of the Day

REPEAT

(repeat int expr)

Loop through an expression a set number of time.

Repeat is one of my most commonly used functions when dealing with selection sets. Instead of using a while function, I will repeat the expression the length of the selection set. This will detour from the possibility of having an infinite loop by some strange means either forgetting to change the counter variable or something not modifying correctly.

(repeat (sslength (setq ss (ssget))))

(setq c 0)
(repeat 4 (setq c (1+ c))) returns 4

Leave a Reply