We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 60cfc95 commit 2303e11Copy full SHA for 2303e11
src/algorithm/hamt.lisp
@@ -17,6 +17,7 @@
17
(:export #:+empty+
18
#:immutable-map
19
#:assoc
20
+ #:assoc-in
21
#:contains-p
22
#:difference
23
#:dissoc
@@ -422,6 +423,16 @@ Returns (values new-node inserted-p) where inserted-p is true for new insertions
422
423
(make-immutable-map new-root (+ (immutable-map-count map)
424
(if inserted 1 0))))))
425
426
+(defun assoc-in (map keys value)
427
+ "Associate VALUE in a nested MAP structure, where KEYS is a sequence of keys."
428
+ (if (null keys)
429
+ value
430
+ (let ((k (car keys)))
431
+ (assoc map k
432
+ (assoc-in (get map k +empty+)
433
+ (cdr keys)
434
+ value)))))
435
+
436
(defun reduce (function map &optional (initial-value +empty+))
437
"Reduce over key-value pairs in the map"
438
(cl:reduce (lambda (acc pair)
0 commit comments