Skip to content

Commit 9a6d517

Browse files
dehannmateuszbaran
andauthored
Update src/array_partition.jl
Co-authored-by: Mateusz Baran <[email protected]>
1 parent f9e7d61 commit 9a6d517

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/array_partition.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,4 +504,10 @@ function Base.convert(::Type{ArrayPartition{T,S}}, A::ArrayPartition{<:Any,<:NTu
504504
)
505505
end
506506

507-
Base.length(::Type{<:ArrayPartition{F,T}}) where {F,T <: Tuple} = T.parameters .|> length |> sum
507+
@generated function Base.length(::Type{<:ArrayPartition{F,T}}) where {F,N,T <: NTuple{N,StaticArray}}
508+
sum_expr = Expr(:call, :+)
509+
for param in T.parameters
510+
push!(sum_expr.args, :(length($param)))
511+
end
512+
return sum_expr
513+
end

0 commit comments

Comments
 (0)