Skip to content

Commit 635bd41

Browse files
authored
Merge pull request #142 from yssamtu/change_tuple_of_arrays
support longer tuple
2 parents 7ea8fe2 + 37d4f26 commit 635bd41

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/primitives.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,26 @@ function tuple_of_arrays(a)
6868
t1,t2 = tuple_of_arrays(y)
6969
(x,t1,t2)
7070
end
71+
function take(a, ::Type{Tuple{A,B,C,D}} where {A,B,C,D})
72+
x, y = first_and_tail(a)
73+
t1, t2, t3 = tuple_of_arrays(y)
74+
(x, t1, t2, t3)
75+
end
76+
function take(a, ::Type{Tuple{A,B,C,D,E}} where {A,B,C,D,E})
77+
x, y = first_and_tail(a)
78+
t1, t2, t3, t4 = tuple_of_arrays(y)
79+
(x, t1, t2, t3, t4)
80+
end
81+
function take(a, ::Type{Tuple{A,B,C,D,E,F}} where {A,B,C,D,E,F})
82+
x, y = first_and_tail(a)
83+
t1, t2, t3, t4, t5 = tuple_of_arrays(y)
84+
(x, t1, t2, t3, t4, t5)
85+
end
86+
function take(a, ::Type{Tuple{A,B,C,D,E,F,G}} where {A,B,C,D,E,F,G})
87+
x, y = first_and_tail(a)
88+
t1, t2, t3, t4, t5, t6 = tuple_of_arrays(y)
89+
(x, t1, t2, t3, t4, t5, t6)
90+
end
7191
# this one is type instable, why? Previous methods for take are for circumvent this issue.
7292
function take(a,::Type)
7393
x, y = first_and_tail(a)

0 commit comments

Comments
 (0)