bug-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#45570: [PATCH] system: Assert, that user and group names are unique.


From: Danny Milosavljevic
Subject: bug#45570: [PATCH] system: Assert, that user and group names are unique.
Date: Sat, 2 Jan 2021 02:16:01 +0100

Hi Leo,

I agree that this is a good idea.

Please use (ice-9 match) instead of car and cdr.

Something among these lines would be more transparent:

    (define (find-duplicates list accessor)
      (match list
        (() '())
        ((head . tail)
         (if (member head tail accessor) ; (srfi srfi-1) member
             (cons head (find-duplicates tail accessor))
             (find-duplicates tail accessor)))))

(find-duplicates users
                 (lambda (a b)
                   (string=? (user-account-name a)
                             (user-account-name b)))

(I think one could also use srfi-1 delete-duplicates and then compare the
lengths.  Then the entire thing is a one-liner--the only complication is
to find the duplicates again after doing it (for the error message))

Attachment: pgpc7sALmz87p.pgp
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]