Skip to main content

Date_Range.partition

partitioncondition

Group: Selections

Documentation

Partitions the range into Vectors of elements which satisfy a given condition and ones that do not. Returns a Pair whose first element is the Vector of elements satisfying the predicate and the second element is a Vector of elements which did not satisfy it. The relative order of elements kept in each returned list is the same as in the input.

Arguments

  • condition: A Filter_Condition or a predicate function to test each element.

Examples

Splitting a range into weekends and weekdays.

      is_weekend day =
[Day_Of_Week.Saturday, Day_Of_Week.Sunday].contains day.day_of_week
(Date.new 2020 10 01).up_to (Date.new 2020 10 15).partition is_weekend