Help for this page

Select Code to Download


  1. or download this
    (defun pick-new (lst el)
      (if (eql (car (car lst)) el)
          (cons (cons el (car lst)) (cdr lst))
    ...
    
    (defun pack (lst)
      (reverse (reduce #'pick-new lst :initial-value nil)))
    
  2. or download this
    (defun pick-new (lst el)
      (cons (cons el (when (equal el (caar lst)) (pop lst))) lst))
    
    (defun pack (lst)
      (reverse (reduce #'pick-new lst :initial-value nil)))
    
  3. or download this
    ;;With loop:
    
    ...
    (defun pack(lst &optional g)
      (if (not lst) (reverse g) 
          (pack (cdr lst) (cons (cons (car lst) (when (equal (car lst) (ca
    +ar g)) (pop g))) g)))))