Mercurial > repos > public > sbplib_julia
comparison src/LazyTensors/tuple_manipulation.jl @ 1226:ea5b4fca85e0 refactor/LazyTensors/tuple_manipulation
Add an example in the docstring to split_tuple
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Sat, 18 Feb 2023 21:55:55 +0100 |
parents | 6567e38b05ca |
children | 06b983f0d236 |
comparison
equal
deleted
inserted
replaced
1225:6567e38b05ca | 1226:ea5b4fca85e0 |
---|---|
71 """ | 71 """ |
72 split_tuple(t, szs) | 72 split_tuple(t, szs) |
73 | 73 |
74 Split the tuple `t` into a set of tuples of the sizes given in `szs`. | 74 Split the tuple `t` into a set of tuples of the sizes given in `szs`. |
75 `sum(szs)` should equal `lenght(t)`. | 75 `sum(szs)` should equal `lenght(t)`. |
76 | |
77 E.g | |
78 ```julia | |
79 split_tuple((1,2,3,4,5,6), (3,1,2)) -> (1,2,3),(4,),(5,6) | |
80 ``` | |
76 """ | 81 """ |
77 function split_tuple(t, szs) | 82 function split_tuple(t, szs) |
78 if length(t) != sum(szs; init=0) | 83 if length(t) != sum(szs; init=0) |
79 throw(ArgumentError("length(t) must equal sum(szs)")) | 84 throw(ArgumentError("length(t) must equal sum(szs)")) |
80 end | 85 end |