Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MasonProtter committed Nov 18, 2024
1 parent 457d93a commit dbb9523
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/TransducersNext.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ include("utils.jl")
@public __fold__, foldstyle, FoldStyle, IterateFold, RecursiveFold
@public Reduction, Transducer, Composition
@public reduction, reducingfunction
@public Finished, isfinished, finished, value, var"@return_if_finished"
@public next, var"@next", combine, inner, xform, start

include("core.jl")
include("library.jl")
Expand Down
11 changes: 5 additions & 6 deletions src/library.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,20 @@ upstream transducer.
# Examples
```jldoctest
julia> using Transducers
julia> foldl((l, r) -> r, TerminateIf(x -> x == 3), 1:10)
julia> 1:10 |> TerminateIf(x -> x == 3) |> fold((l,r) -> r)
3
```
"""
struct ReduceIf{P} <: AbstractFilter
struct TerminateIf{P} <: AbstractFilter
pred::P
end

function next(rf::R_{ReduceIf}, result0, input)
function next(rf::R_{TerminateIf}, result0, input)
shouldterminate = xform(rf).pred(input)
result = next(inner(rf), result0, input)
if shouldterminate
return terminated(complete(inner(rf), result))
return finished(result)
#return finished(complete(inner(rf), result))
end
return result
end
Expand Down

0 comments on commit dbb9523

Please sign in to comment.