fork download
  1. ;; copy-list
  2. (defun our-copy-list(lst)
  3. (reduce #'(lambda (x f) (cons x f)) lst :from-end t :initial-value nil))
  4.  
  5. ;; remove-duplicates
  6. (defun our-remove-duplicates(lst)
  7. (reduce #'(lambda (x f) (adjoin x f)) lst :from-end t :initial-value nil))
  8.  
  9. ;; find-if
  10. (defun our-find-if(fn lst)
  11. (reduce #'(lambda (x f) (if (funcall fn x) x f)) lst :from-end t :initial-value nil))
  12.  
  13. ;; some
  14. (defun our-some(fn lst)
  15. (reduce #'(lambda (x f) (or (funcall fn x) f)) lst :from-end t :initial-value nil))
  16.  
  17. ;; テスト
  18. ;; copy-list
  19. (defparameter *lst* (list 1 (list 2 3)))
  20. (defparameter *clst* (our-copy-list *lst*))
  21. (eq *clst* *lst*)
  22. (equal *clst* *lst*)
  23.  
  24. ;; our-remove-duplicates
  25. (our-remove-duplicates '(a b c b d d e))
  26.  
  27. ;; our-find-if
  28. (our-find-if #'evenp '(3 1 4 1 5 9))
  29.  
  30. ;; our-some
  31. (our-some #'integerp '(1 3 b 2.7))
  32. (our-some #'integerp '(a 3.1 b 2.7))
  33.  
Success #stdin #stdout 0.02s 27796KB
stdin
Standard input is empty
stdout
Standard output is empty