Skip to content

Instantly share code, notes, and snippets.

Gerhard Aigner laborg

Block or report user

Report or block laborg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@laborg
laborg / gist:f9af0f5c2def4edfa410c5522afbff1d
Created Sep 10, 2018
Explicit implementation of uniquifying algorithms
View gist:f9af0f5c2def4edfa410c5522afbff1d
# Implementation bodies for unique and unique!
function _unique(itr, f::Union{Nothing, Callable} = nothing)
T = @default_eltype(itr)
y = iterate(itr)
y === nothing && return T[]
x, st = y
R = !isconcretetype(T) && IteratorEltype(itr) == EltypeUnknown() ? typeof(x) : T
f === nothing && return __uniquify(itr, R[], Set{R}(), st, x)
fx = f(x)
return __uniquify(itr, R[], Set{typeof(fx)}(), st, x, f, fx)
You can’t perform that action at this time.