Permalink
Browse files

alist->filter-keys function

  • Loading branch information...
1 parent 24a493c commit 4210b1f1732ac35ee32fb15056c0cc8689539714 @nicferrier committed Sep 14, 2012
Showing with 9 additions and 1 deletion.
  1. +9 −1 kv.el
View
10 kv.el
@@ -4,7 +4,7 @@
;; Author: Nic Ferrier <nferrier@ferrier.me.uk>
;; Keywords: lisp
-;; Version: 0.0.3
+;; Version: 0.0.4
;; Maintainer: Nic Ferrier <nferrier@ferrier.me.uk>
;; Created: 7th September 2012
@@ -87,6 +87,14 @@ HASH-TABLE-ARGS are passed to the hash-table creation."
"Sort ALIST by value with PRED."
(sort alist (lambda (a b) (funcall pred (cdr a) (cdr b)))))
+(defun kvalist->filter-keys (alist &rest keys)
+ "Return the ALIST filtered to the KEYS list.
+
+Only pairs where the car is a `member' of KEYS will be returned."
+ (loop for a in alist
+ if (member (car a) keys)
+ collect a))
+
(defun kvdotassoc-fn (expr table func)
"Use the dotted EXPR to access deeply nested data in TABLE.

0 comments on commit 4210b1f

Please sign in to comment.