Skip to content

Instantly share code, notes, and snippets.

@anton0xf
Created June 30, 2012 06:50
Show Gist options
  • Save anton0xf/3022709 to your computer and use it in GitHub Desktop.
Save anton0xf/3022709 to your computer and use it in GitHub Desktop.
CL-USER> (defun filtered (hash &optional (filter-condition t))
(let ((res '()))
(maphash #'(lambda (k v)
(if (funcall filter-condition k v)
(push v res)))
hash)
res))
CL-USER> (defparameter *hash* (make-hash-table))
CL-USER> (dotimes (i 10) (setf (gethash i table) i))
CL-USER> (filtered *hash*
#'(lambda (k v) (oddp k)))
(9 7 5 3 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment