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))
|
(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 (deduplicate-derivations derivations)
|
||||||
(define sorted-derivations
|
(define sorted-derivations
|
||||||
(sort derivations
|
(sort derivations
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,8 @@
|
||||||
#:export (quote-string
|
#:export (quote-string
|
||||||
value->quoted-string-or-null
|
value->quoted-string-or-null
|
||||||
exec-query->vhash
|
exec-query->vhash
|
||||||
two-lists->vhash))
|
two-lists->vhash
|
||||||
|
deduplicate-strings))
|
||||||
|
|
||||||
(define (quote-string s)
|
(define (quote-string s)
|
||||||
(string-append "'" s "'"))
|
(string-append "'" s "'"))
|
||||||
|
|
@ -29,3 +30,16 @@
|
||||||
vlist-null
|
vlist-null
|
||||||
l1
|
l1
|
||||||
l2))
|
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…
Add table
Add a link
Reference in a new issue