Mercurial > repos > public > sbplib_julia
comparison src/LazyTensors/lazy_tensor_operations.jl @ 625:1c512e796c6d feature/volume_and_boundary_operators
Allow split_tuple to split tuples containing different types.
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 31 Dec 2020 08:10:56 +0100 |
parents | 8f7919a9b398 |
children | 76e5682d0e52 |
comparison
equal
deleted
inserted
replaced
624:a85db383484f | 625:1c512e796c6d |
---|---|
329 E.g | 329 E.g |
330 ``` | 330 ``` |
331 split_tuple((1,2,3,4),Val(3)) -> (1,2,3), (4,) | 331 split_tuple((1,2,3,4),Val(3)) -> (1,2,3), (4,) |
332 ``` | 332 ``` |
333 """ | 333 """ |
334 function split_tuple(t::NTuple{N},::Val{M}) where {N,M} | 334 function split_tuple(t::NTuple{N,Any},::Val{M}) where {N,M} |
335 return slice_tuple(t,Val(1), Val(M)), slice_tuple(t,Val(M+1), Val(N)) | 335 return slice_tuple(t,Val(1), Val(M)), slice_tuple(t,Val(M+1), Val(N)) |
336 end | 336 end |
337 | 337 |
338 """ | 338 """ |
339 split_tuple(t::Tuple{...},::Val{M},::Val{K}) where {N,M,K} | 339 split_tuple(t::Tuple{...},::Val{M},::Val{K}) where {N,M,K} |
340 | 340 |
341 Same as `split_tuple(t::NTuple{N},::Val{M})` but splits the tuple in three parts. With the first | 341 Same as `split_tuple(t::NTuple{N},::Val{M})` but splits the tuple in three parts. With the first |
342 two parts having lenght `M` and `K`. | 342 two parts having lenght `M` and `K`. |
343 """ | 343 """ |
344 function split_tuple(t::NTuple{N},::Val{M},::Val{K}) where {N,M,K} | 344 function split_tuple(t::NTuple{N,Any},::Val{M},::Val{K}) where {N,M,K} |
345 p1, tail = split_tuple(t, Val(M)) | 345 p1, tail = split_tuple(t, Val(M)) |
346 p2, p3 = split_tuple(tail, Val(K)) | 346 p2, p3 = split_tuple(tail, Val(K)) |
347 return p1,p2,p3 | 347 return p1,p2,p3 |
348 end | 348 end |
349 | 349 |