aboutsummaryrefslogtreecommitdiff
path: root/module/hnh
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2023-02-21 03:21:43 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2023-09-11 19:58:54 +0200
commitc26324e29043423387c3041e86d8cbe5cd4102b2 (patch)
tree6395e01b19572bbc22487115e52cadd1f39fafcf /module/hnh
parentFix seeding of UUIDs. (diff)
downloadcalp-c26324e29043423387c3041e86d8cbe5cd4102b2.tar.gz
calp-c26324e29043423387c3041e86d8cbe5cd4102b2.tar.xz
Change `kvlist->assq` and `group-by` to return pairs.
Each value in the return of group-by must have exactly two values, so cons pairs (instead of lists) is much better.
Diffstat (limited to 'module/hnh')
-rw-r--r--module/hnh/util.scm8
1 files changed, 3 insertions, 5 deletions
diff --git a/module/hnh/util.scm b/module/hnh/util.scm
index a6581158..bbb1a5ec 100644
--- a/module/hnh/util.scm
+++ b/module/hnh/util.scm
@@ -338,7 +338,8 @@
(define (kvlist->assq kvlist)
(map (lambda (pair)
- (cons (keyword->symbol (car pair)) (cdr pair)))
+ (cons (keyword->symbol (car pair))
+ (cadr pair)))
(group kvlist 2)))
(define* (assq-limit alist optional: (number 1))
@@ -351,10 +352,7 @@
(for value in lst
(let ((key (proc value)))
(hash-set! h key (cons value (hash-ref h key '())))))
- ;; TODO change this 'list' to 'cons'.
- ;; It will give a "proper" alist, and also allows the output to work
- ;; with assq-merge
- (hash-map->list list h)))
+ (hash-map->list cons h)))
;; (split-by '(0 1 2 3 4 2 5 6) 2)
;; ⇒ ((0 1) (3 4) (5 6))