From c26324e29043423387c3041e86d8cbe5cd4102b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 21 Feb 2023 03:21:43 +0100 Subject: 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. --- module/calp/entry-points/tidsrapport.scm | 2 +- module/datetime/zic.scm | 8 ++++---- module/hnh/util.scm | 8 +++----- module/vcomponent/recurrence/display/en.scm | 4 ++-- module/vcomponent/recurrence/display/sv.scm | 4 ++-- 5 files changed, 12 insertions(+), 14 deletions(-) (limited to 'module') 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)))) -- cgit v1.2.3