aboutsummaryrefslogtreecommitdiff
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
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.
-rw-r--r--doc/ref/guile/util.texi4
-rw-r--r--module/calp/entry-points/tidsrapport.scm2
-rw-r--r--module/datetime/zic.scm8
-rw-r--r--module/hnh/util.scm8
-rw-r--r--module/vcomponent/recurrence/display/en.scm4
-rw-r--r--module/vcomponent/recurrence/display/sv.scm4
-rw-r--r--tests/test/util.scm5
-rwxr-xr-xtests/validate-html/run-validator.scm2
8 files changed, 17 insertions, 20 deletions
diff --git a/doc/ref/guile/util.texi b/doc/ref/guile/util.texi
index 95af9038..d61bd0ed 100644
--- a/doc/ref/guile/util.texi
+++ b/doc/ref/guile/util.texi
@@ -186,8 +186,8 @@ pairs of symbols and values.
@lisp
(kvlist->assq '(#:a 1 #:b "Hello"))
-⇒ ((a 1)
- (b "Hello"))
+⇒ ((a . 1)
+ (b . "Hello"))
@end lisp
@end defun
diff --git a/module/calp/entry-points/tidsrapport.scm b/module/calp/entry-points/tidsrapport.scm
index b5b9564f..a258cd73 100644
--- a/module/calp/entry-points/tidsrapport.scm
+++ b/module/calp/entry-points/tidsrapport.scm
@@ -93,7 +93,7 @@
(as-time
(datetime-difference (prop e 'DTEND)
(prop e 'DTSTART)))))
- (cadr group))))))
+ (cdr group))))))
instances)
diff --git a/module/datetime/zic.scm b/module/datetime/zic.scm
index ace3d991..470f6c07 100644
--- a/module/datetime/zic.scm
+++ b/module/datetime/zic.scm
@@ -298,16 +298,16 @@
(for-each (lambda (group)
(hashq-set! rules
(car group)
- (sort* (cadr group)
+ (sort* (cdr group)
(lambda (a b) (if (eq? 'minimum) #t (< a b)))
rule-from)))
- (group-by rule-name (car it))))
+ (group-by rule-name it)))
;; put zones in map
(awhen (assoc-ref groups 'zone)
(for-each (lambda (zone)
(hash-set! zones (zone-name zone) (zone-entries zone)))
- (car it)))
+ it))
;; resolve links to extra entries in the zone map
(awhen (assoc-ref groups 'link)
@@ -318,7 +318,7 @@
(if (not target-item)
(warning (G_ "Unresolved link, target missing ~a -> ~a") name target)
(hash-set! zones name target-item))))
- (car it)))
+ it))
(make-zoneinfo rules zones)))
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))
diff --git a/module/vcomponent/recurrence/display/en.scm b/module/vcomponent/recurrence/display/en.scm
index c711a75c..18d11dba 100644
--- a/module/vcomponent/recurrence/display/en.scm
+++ b/module/vcomponent/recurrence/display/en.scm
@@ -26,13 +26,13 @@
(list "every "
(add-enumeration-punctuation
(map (lambda (d) (list (week-day-name (cdr d))))
- (cadr group)
+ (cdr group)
)))]
[else
(list (number->string-ordinal (car group)) " "
(add-enumeration-punctuation
(map (lambda (d) (list (week-day-name (cdr d)) "en"))
- (cadr group))))])
+ (cdr group))))])
)
groups))))
diff --git a/module/vcomponent/recurrence/display/sv.scm b/module/vcomponent/recurrence/display/sv.scm
index 2bd70657..ee8fc3fd 100644
--- a/module/vcomponent/recurrence/display/sv.scm
+++ b/module/vcomponent/recurrence/display/sv.scm
@@ -31,7 +31,7 @@
(list "varje "
(add-enumeration-punctuation
(map (lambda (d) (list (week-day-name (cdr d))))
- (cadr group)
+ (cdr group)
)))]
[else
(list (number->string-ordinal
@@ -40,7 +40,7 @@
" "
(add-enumeration-punctuation
(map (lambda (d) (list (week-day-name (cdr d)) "en"))
- (cadr group))))])
+ (cdr group))))])
)
groups))))
diff --git a/tests/test/util.scm b/tests/test/util.scm
index 75d59801..d2fc2d81 100644
--- a/tests/test/util.scm
+++ b/tests/test/util.scm
@@ -127,7 +127,6 @@
(test-group "Arrows"
-
(test-equal "->" 9 (-> 1 (+ 2) (* 3)))
(test-equal "-> order dependant" -1 (-> 1 (- 2)))
(test-equal "->> order dependant" 1 (->> 1 (- 2))))
@@ -154,12 +153,12 @@
(assq-merge '((k 1) (v 2)) '((k 2))))
(test-equal "kvlist->assq"
- '((a 1) (b 2))
+ '((a . 1) (b . 2))
(kvlist->assq '(a: 1 b: 2)))
(test-equal "kvlist->assq repeated key"
- '((a 1) (b 2) (a 3))
+ '((a . 1) (b . 2) (a . 3))
(kvlist->assq '(a: 1 b: 2 a: 3))))
(test-equal "vector-last"
diff --git a/tests/validate-html/run-validator.scm b/tests/validate-html/run-validator.scm
index bd96c32d..0c4ee0bc 100755
--- a/tests/validate-html/run-validator.scm
+++ b/tests/validate-html/run-validator.scm
@@ -80,6 +80,6 @@ exec $GUILE -e main -s "$0" -- "$@"
(begin
(for-each (lambda (group)
(format #t "~a~%" (-> group car (assoc-ref 'url) car))
- (for-each display-entry (cadr group)))
+ (for-each display-entry (cdr group)))
(group-by-file filtered-data))
(exit 1)))))