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:
parent
101caddecc
commit
21b07b07a9
2 changed files with 15 additions and 14 deletions
|
@ -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
|
||||
|
|
|
@ -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)))))
|
||||
|
|
Loading…
Reference in a new issue