fork download
  1. (defun ht-list (&rest list)
  2. (cons list (last list)))
  3.  
  4. (defun add-at-head (element ht-list)
  5. (push element (car ht-list))
  6. ht-list)
  7.  
  8. (defun add-at-tail (element ht-list)
  9. (setf (cddr ht-list) (cons element nil)
  10. (cdr ht-list) (cddr ht-list))
  11. ht-list)
  12.  
  13.  
  14. (let ((ht (ht-list 'm 'i 't 'm)))
  15. (loop
  16. for i from 0 to 20
  17. do (funcall (if (oddp i)
  18. (function add-at-head)
  19. (function add-at-tail))
  20. i ht)
  21. (print ht)
  22. finally (return ht)))
  23.  
Success #stdin #stdout 0.01s 25536KB
stdin
Standard input is empty
stdout
((M I T M 0) 0) 
((1 M I T M 0) 0) 
((1 M I T M 0 2) 2) 
((3 1 M I T M 0 2) 2) 
((3 1 M I T M 0 2 4) 4) 
((5 3 1 M I T M 0 2 4) 4) 
((5 3 1 M I T M 0 2 4 6) 6) 
((7 5 3 1 M I T M 0 2 4 6) 6) 
((7 5 3 1 M I T M 0 2 4 6 8) 8) 
((9 7 5 3 1 M I T M 0 2 4 6 8) 8) 
((9 7 5 3 1 M I T M 0 2 4 6 8 10) 10) 
((11 9 7 5 3 1 M I T M 0 2 4 6 8 10) 10) 
((11 9 7 5 3 1 M I T M 0 2 4 6 8 10 12) 12) 
((13 11 9 7 5 3 1 M I T M 0 2 4 6 8 10 12) 12) 
((13 11 9 7 5 3 1 M I T M 0 2 4 6 8 10 12 14) 14) 
((15 13 11 9 7 5 3 1 M I T M 0 2 4 6 8 10 12 14) 14) 
((15 13 11 9 7 5 3 1 M I T M 0 2 4 6 8 10 12 14 16) 16) 
((17 15 13 11 9 7 5 3 1 M I T M 0 2 4 6 8 10 12 14 16) 16) 
((17 15 13 11 9 7 5 3 1 M I T M 0 2 4 6 8 10 12 14 16 18) 18) 
((19 17 15 13 11 9 7 5 3 1 M I T M 0 2 4 6 8 10 12 14 16 18) 18) 
((19 17 15 13 11 9 7 5 3 1 M I T M 0 2 4 6 8 10 12 14 16 18 20) 20)