Skip to content

Commit

Permalink
Pure tail
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf committed Jan 18, 2019
1 parent 867bbc7 commit 0c1e50e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/basics.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# --- Utilities

@inline Base.@pure argtail(x, rest...) = rest
@inline Base.@pure tail(x::Tuple) = argtail(x...)

valueof(::Val{x}) where x = x

ieltype(T) =
Expand Down
10 changes: 3 additions & 7 deletions src/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,9 @@ InType(T::Type) = throw(MethodError(InType, (T,)))

Setfield.constructor_of(::Type{T}) where {T <: Reduction} = T

inner(rf::Reduction) =
if length(rf.xforms) > 1
Reduction(Base.tail(rf.xforms), rf.bottom)
else
rf.bottom
end

# inner(rf::Reduction{<:Any, Tuple{}}) = error()
@inline inner(rf::Reduction{<:Any, <:Tuple{Any}}) = rf.bottom
@inline inner(rf::Reduction) = Reduction(tail(rf.xforms), rf.bottom)
xform(rf::Reduction) = rf.xforms[1].xform

Transducer(rf::Reduction) =
Expand Down

0 comments on commit 0c1e50e

Please sign in to comment.