Skip to main content
2 of 4
added 1 character in body
gigiair
  • 2.3k
  • 1
  • 10
  • 15

You can do it using this macro

(defmacro normalize-list(l n)
  "empties the list l when its size reaches N"
  `(if(>=(length ,l),n)(setq ,l '())))

Examples

(setq slist'(foo bar baz)) ;->(foo bar baz)

(normalize-list slist 5);->nil

slist ;->(foo bar baz)

(normalize-list slist 3);->nil

slist;->nil
gigiair
  • 2.3k
  • 1
  • 10
  • 15