link: avoid duplicate entries when merging lists

Otherwise we might store entries we had already heard previously.
This commit is contained in:
Fang 2020-03-04 21:22:04 +01:00
parent 396d13ee1a
commit 353f61cdd3
No known key found for this signature in database
GPG Key ID: EB035760C1BBA972

View File

@ -43,13 +43,15 @@
~| path ~| path
(woad (slav %ta i.path)) (woad (slav %ta i.path))
:: ::
:: zip sorted a into sorted b, maintaining sort order :: zip sorted a into sorted b, maintaining sort order, avoiding duplicates
::TODO stdlib ::
++ merge-sorted ++ merge-sorted-unique
|* [sort=$-([* *] ?) a=(list) b=(list)] |* [sort=$-([* *] ?) a=(list) b=(list)]
|- ^- ?(_a _b) |- ^- ?(_a _b)
?~ a b ?~ a b
?~ b a ?~ b a
?: =(i.a i.b)
[i.a $(a t.a, b t.b)]
?: (sort i.a i.b) ?: (sort i.a i.b)
[i.a $(a t.a)] [i.a $(a t.a)]
[i.b $(b t.b)] [i.b $(b t.b)]
@ -60,7 +62,7 @@
::TODO we would just use +cury here but it don't work ::TODO we would just use +cury here but it don't work
|= [a=^pages b=^pages] |= [a=^pages b=^pages]
^+ a ^+ a
%+ merge-sorted %+ merge-sorted-unique
|= [a=page b=page] |= [a=page b=page]
(gth time.a time.b) (gth time.a time.b)
[a b] [a b]
@ -68,7 +70,7 @@
++ submissions ++ submissions
|= [a=^submissions b=^submissions] |= [a=^submissions b=^submissions]
^+ a ^+ a
%+ merge-sorted %+ merge-sorted-unique
|= [a=submission b=submission] |= [a=submission b=submission]
(gth time.a time.b) (gth time.a time.b)
[a b] [a b]
@ -76,7 +78,7 @@
++ notes ++ notes
|= [a=^notes b=^notes] |= [a=^notes b=^notes]
^+ a ^+ a
%+ merge-sorted %+ merge-sorted-unique
|= [a=note b=note] |= [a=note b=note]
(gth time.a time.b) (gth time.a time.b)
[a b] [a b]
@ -84,7 +86,7 @@
++ comments ++ comments
|= [a=^comments b=^comments] |= [a=^comments b=^comments]
^+ a ^+ a
%+ merge-sorted %+ merge-sorted-unique
|= [a=comment b=comment] |= [a=comment b=comment]
(gth time.a time.b) (gth time.a time.b)
[a b] [a b]