Skip to content

Commit aedff0a

Browse files
committed
add dissoc-in
1 parent 3fac7f9 commit aedff0a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/algorithm/hamt.lisp

+8
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#:contains-p
2323
#:difference
2424
#:dissoc
25+
#:dissoc-in
2526
#:enable-syntax
2627
#:filter
2728
#:from-pairs
@@ -535,6 +536,13 @@ Returns (values new-node inserted-p) where inserted-p is true for new insertions
535536
(node-dissoc (immutable-map-root map) hash 0 key nil))))
536537
(make-immutable-map new-root (1- (immutable-map-count map)))))
537538

539+
(defun dissoc-in (map keys)
540+
"Remove a key from a nested MAP structure, where KEYS is a sequence of keys."
541+
(destructuring-bind (k &rest ks) keys
542+
(if (null ks)
543+
(dissoc map k)
544+
(assoc map k (dissoc-in (get map k +empty+) ks)))))
545+
538546
(defun keys (map)
539547
"Return a list of all keys in the map"
540548
(mapcar #'car (seq map)))

0 commit comments

Comments
 (0)