<p dir="auto">We have a <code class="notranslate">unique</code> function that produces a new collection similar to its argument, but with each item only occurring once (in order of first appearance). There should be a corresponding <code class="notranslate">unique!</code> function that removes recurrences of items and returns this modified collection. Note that for performance, at least on dense arrays, resizing of the array should only occur at end when you know the final size to shrink the array to. Part of <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="204934755" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/20402" data-hovercard-type="issue" data-hovercard-url="/JuliaLang/julia/issues/20402/hovercard" href="https://github.com/JuliaLang/julia/issues/20402">#20402</a>.</p>
<p dir="auto">When looking into <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="32603905" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/6708" data-hovercard-type="issue" data-hovercard-url="/JuliaLang/julia/issues/6708/hovercard" href="https://github.com/JuliaLang/julia/issues/6708">#6708</a>, I noticed that the <code class="notranslate">sprand</code> function seems to generate sparse matrices with slightly the wrong density.  For example:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; mean([nfilled(sprand(100,10,0.1)) for i=1:100])
99.81

julia&gt; mean([nfilled(sprand(100,10,0.1)) for i=1:1000])
99.833

julia&gt; mean([nfilled(sprand(100,10,0.1)) for i=1:10000])
99.7546

julia&gt; mean([nfilled(sprand(100,10,0.1)) for i=1:100000])
99.72917

julia&gt; mean([nfilled(sprand(100,10,0.1)) for i=1:1000000])
99.722943"><pre class="notranslate">julia<span class="pl-k">&gt;</span> <span class="pl-c1">mean</span>([<span class="pl-c1">nfilled</span>(<span class="pl-c1">sprand</span>(<span class="pl-c1">100</span>,<span class="pl-c1">10</span>,<span class="pl-c1">0.1</span>)) <span class="pl-k">for</span> i<span class="pl-k">=</span><span class="pl-c1">1</span><span class="pl-k">:</span><span class="pl-c1">100</span>])
<span class="pl-c1">99.81</span>

julia<span class="pl-k">&gt;</span> <span class="pl-c1">mean</span>([<span class="pl-c1">nfilled</span>(<span class="pl-c1">sprand</span>(<span class="pl-c1">100</span>,<span class="pl-c1">10</span>,<span class="pl-c1">0.1</span>)) <span class="pl-k">for</span> i<span class="pl-k">=</span><span class="pl-c1">1</span><span class="pl-k">:</span><span class="pl-c1">1000</span>])
<span class="pl-c1">99.833</span>

julia<span class="pl-k">&gt;</span> <span class="pl-c1">mean</span>([<span class="pl-c1">nfilled</span>(<span class="pl-c1">sprand</span>(<span class="pl-c1">100</span>,<span class="pl-c1">10</span>,<span class="pl-c1">0.1</span>)) <span class="pl-k">for</span> i<span class="pl-k">=</span><span class="pl-c1">1</span><span class="pl-k">:</span><span class="pl-c1">10000</span>])
<span class="pl-c1">99.7546</span>

julia<span class="pl-k">&gt;</span> <span class="pl-c1">mean</span>([<span class="pl-c1">nfilled</span>(<span class="pl-c1">sprand</span>(<span class="pl-c1">100</span>,<span class="pl-c1">10</span>,<span class="pl-c1">0.1</span>)) <span class="pl-k">for</span> i<span class="pl-k">=</span><span class="pl-c1">1</span><span class="pl-k">:</span><span class="pl-c1">100000</span>])
<span class="pl-c1">99.72917</span>

julia<span class="pl-k">&gt;</span> <span class="pl-c1">mean</span>([<span class="pl-c1">nfilled</span>(<span class="pl-c1">sprand</span>(<span class="pl-c1">100</span>,<span class="pl-c1">10</span>,<span class="pl-c1">0.1</span>)) <span class="pl-k">for</span> i<span class="pl-k">=</span><span class="pl-c1">1</span><span class="pl-k">:</span><span class="pl-c1">1000000</span>])
<span class="pl-c1">99.722943</span></pre></div>
<p dir="auto">does not seem to be converging to 100.</p>