OmniTools.ForLongTuples
Exported
OmniTools.ForLongTuples.foldl_longtuple Function
julia
foldl_longtuple(f, lt::LongTuple; init)Fold over the elements of a LongTuple in a compiler-friendly (unrolled) way.
Examples
julia
julia> using OmniTools
julia> lt = to_longtuple((1, 2, 3), 2);
julia> foldl_longtuple((x, acc) -> acc + x, lt; init=0)
6OmniTools.ForLongTuples.to_longtuple Function
julia
to_longtuple(normal_tuple; longtuple_size=5)Create a LongTuple from a normal tuple.
Arguments
normal_tuple: The input tuple to convertlongtuple_size: Size to break down the tuple into (default: 5)
Returns
- A LongTuple containing the elements of the input tuple
Examples
julia
julia> using OmniTools
julia> lt = to_longtuple((1, 2, 3), 2);
julia> lt[3]
3julia
to_longtuple(normal_tuple; longtuple_size=5)Arguments:
normal_tuple: a normal tuplelongtuple_size: size to break down the tuple into
Code
julia
function to_longtuple(tup::Tuple, longtuple_size=5)
longtuple_size = min(length(tup), longtuple_size)
LongTuple{longtuple_size}(tup...)
endOmniTools.ForLongTuples.to_tuple Function
julia
to_tuple(long_tuple)Convert a LongTuple to a regular tuple.
Arguments
long_tuple: The input LongTuple
Returns
- A regular tuple containing all elements from the LongTuple
Examples
julia
julia> using OmniTools
julia> lt = to_longtuple((1, 2, 3), 2);
julia> to_tuple(lt)
(1, 2, 3)Code
julia
function to_tuple(lt::LongTuple)
emp_vec = []
foreach(lt) do x
push!(emp_vec, x)
end
return Tuple(emp_vec)
end