Return Elements in a Key Range
Value
An ordered_sequence of matched elements, in key order. Use
as.list() to convert to a plain list.
Details
Range membership is controlled by include_from and include_to:
include_from = TRUEuseskey >= from_key; otherwisekey > from_key.include_to = TRUEuseskey <= to_key; otherwisekey < to_key.
If no elements fall in the range, returns an empty ordered_sequence.
Examples
x <- ordered_sequence("a", "b", "c", "d", keys = c(1, 2, 2, 3))
elements_between(x, 2, 3)
#> Unnamed ordered_sequence with 3 elements.
#>
#> Elements (by key order):
#>
#> [[1]] (key 2)
#> [1] "b"
#>
#> [[2]] (key 2)
#> [1] "c"
#>
#> [[3]] (key 3)
#> [1] "d"
#>
as.list(elements_between(x, 2, 3))
#> [[1]]
#> [1] "b"
#>
#> [[2]]
#> [1] "c"
#>
#> [[3]]
#> [1] "d"
#>
elements_between(x, 2, 2, include_to = FALSE)
#> Unnamed ordered_sequence with 0 elements.
