summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNic Ferier <nic@ferrier.me.uk>2013-06-12 11:19:20 +0100
committerNic Ferier <nic@ferrier.me.uk>2013-06-12 11:19:20 +0100
commitf77f75b774297b89dd70f58f6d3765615e1b2d1d (patch)
treead98fdc7965056c2b4f7ce433fa1d17fabd1c174
parentb227839532b7858ad5b70733dcfadf0653ce2e7f (diff)
add a bunch of accessor functions to replace use of aget
-rw-r--r--kv.el20
1 files changed, 20 insertions, 0 deletions
diff --git a/kv.el b/kv.el
index 070bacd..5577169 100644
--- a/kv.el
+++ b/kv.el
@@ -63,6 +63,26 @@ key."
hash)
store)))
+(defun kva (key alist)
+ "Retrieve the value assigned to KEY in ALIST.
+
+This uses `assoc' as the lookup mechanism."
+ (cdr (assoc key alist)))
+
+(defun kvaq (key alist)
+ "Retrieve the value assigned to KEY in ALIST.
+
+This uses `assq' as the lookup mechanism."
+ (cdr (assq key alist)))
+
+(defun kvaqc (key alist)
+ "Retrieve the value assigned to KEY in ALIST.
+
+This uses first the `assq' and then `assoc' as the lookup
+mechanism."
+ (cdr (or (assq key alist)
+ (assoc key alist))))
+
(defun kvassoc= (key value alist)
"Is the value assocd to KEY in ALIST equal to VALUE?