2
0
Fork 0
mirror of git://git.savannah.gnu.org/guix/data-service.git synced 2023-12-14 03:23:03 +01:00

Extract out deduplicate-strings to the utils module

This commit is contained in:
Christopher Baines 2019-03-24 10:49:49 +00:00
parent 101caddecc
commit 21b07b07a9
No known key found for this signature in database
GPG key ID: 5E28A33B0B84F577
2 changed files with 15 additions and 14 deletions

View file

@ -519,19 +519,6 @@ ORDER BY derivations.system DESC,
(exec-query conn query))
(define (deduplicate-strings strings)
(pair-fold
(lambda (pair result)
(if (null? (cdr pair))
(cons (first pair) result)
(if (string=? (first pair) (second pair))
result
(cons (first pair) result))))
'()
(sort strings
(lambda (a b)
(string<? a b)))))
(define (deduplicate-derivations derivations)
(define sorted-derivations
(sort derivations

View file

@ -5,7 +5,8 @@
#:export (quote-string
value->quoted-string-or-null
exec-query->vhash
two-lists->vhash))
two-lists->vhash
deduplicate-strings))
(define (quote-string s)
(string-append "'" s "'"))
@ -29,3 +30,16 @@
vlist-null
l1
l2))
(define (deduplicate-strings strings)
(pair-fold
(lambda (pair result)
(if (null? (cdr pair))
(cons (first pair) result)
(if (string=? (first pair) (second pair))
result
(cons (first pair) result))))
'()
(sort strings
(lambda (a b)
(string<? a b)))))