Skip to content

Commit

Permalink
Add methods for Float64/Int diff in CBLS
Browse files Browse the repository at this point in the history
  • Loading branch information
Azzaare committed Mar 25, 2021
1 parent 98d96f7 commit 5beab38
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/PatternFolds.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export Interval, IntervalsFold
export pattern, gap, folds, check_pattern
export length
export fold, unfold
export value
export value, closed, opened
export a_isless, b_isless, a_ismore, b_ismore

# includes
include("common.jl")
Expand Down
16 changes: 16 additions & 0 deletions src/intervals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ closed(i, ::Val{:b}) = i.b[2]
closed(i, bound) = closed(i, Val(bound))
opened(i, bound) = !closed(i, bound)

function a_isless(i₁, i₂)
a₁ = value(i₁, :a)
a₂ = value(i₂, :a)
return a₁ == a₂ ? closed(i₁, :a) || opened(i₂, :a) : a₁ < a₂
end

a_ismore(i₁, i₂) = a_isless(i₂, i₁)

function b_ismore(i₁, i₂)
b₁ = value(i₁, :b)
b₂ = value(i₂, :b)
return b₁ == b₂ ? closed(i₁, :b) || opened(i₂, :b) : b₁ > b₂
end

b_isless(i₁, i₂) = b_ismore(i₂, i₁)

function Base.in(val, i::Interval)
(x, y) = (value(i, :a), value(i, :b))
lesser = closed(i, :a) ? x val : x < val
Expand Down

0 comments on commit 5beab38

Please sign in to comment.