OneTwoMany.jl
This package provides utility functions for accessing the second element, as well as the first, second and remaining elements, of iterable objects:
A function
getsecond(x)
: Julia provides the functionsfirst
andlast
, but notsecond
(except forDates.second
, which is about seconds in time).last
can be used to access the second element of aTuple
with two elements or aPair
, butgetsecond
is clearer semantically. With tuples, it is also safer in cases where the upstream code that generates the tuple might change and generate longer tuples in the future.Two functions
first_and_rest
andfirst_second_rest
to get both the first (two) element(s) and the rest of an iterable object.Two functions
firstarg
andsecondarg
to get that simply return their first, resp. second, argument.