Skip to content

Commit 3b9352d

Browse files
committed
generic map
1 parent 2b5922a commit 3b9352d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/blockedtuple.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ Base.length(bt::AbstractBlockTuple) = length(Tuple(bt))
3737

3838
Base.lastindex(bt::AbstractBlockTuple) = length(bt)
3939

40+
function Base.map(f, bt::AbstractBlockTuple)
41+
return unspecify_type_parameters(typeof(bt)){blocklengths(bt)}(map(f, Tuple(bt)))
42+
end
43+
4044
# Broadcast interface
4145
Base.broadcastable(bt::AbstractBlockTuple) = bt
4246
struct AbstractBlockTupleBroadcastStyle{BlockLengths,BT} <: Broadcast.BroadcastStyle end
@@ -97,8 +101,6 @@ BlockedTuple(bt::AbstractBlockTuple) = BlockedTuple{blocklengths(bt)}(Tuple(bt))
97101
# Base interface
98102
Base.Tuple(bt::BlockedTuple) = bt.flat
99103

100-
Base.map(f, bt::BlockedTuple) = BlockedTuple{blocklengths(bt)}(map(f, Tuple(bt)))
101-
102104
# BlockArrays interface
103105
function BlockArrays.blocklengths(::Type{<:BlockedTuple{BlockLengths}}) where {BlockLengths}
104106
return BlockLengths

0 commit comments

Comments
 (0)