Explorer

core.list-reverse

description
The items of list from start (inclusive) to end (exclusive) in reverse order. Splits the range in halves, so it takes O(n log n). Used before core.list-hash-index when the first of the same keys must win (core.list-hash-index-find returns the last one in its bucket)
type
Fn(T: Type, list: List<Param("T")>, start: Number, end: Number) -> List<Param("T")>
expression
fn(T$0, list$1, start$2, end$3) =>
  let length$4 = @core.minus(left: $3, right: $2);
  match @core.less-than(left: $4, right: 2) {
    true =>
      match @core.equal(left: $4, right: 1) {
        true =>
          match @core.list-get(list: $1, index: $2) {
            #some(item$5) =>
              [$5],
            #none(_) =>
              []
          },
        false =>
          []
      },
    false =>
      let middle$6 = @core.plus(left: $2, right: @core.divide(left: $4, right: 2));
      @core.list-concat(
        left: @core.list-reverse(T: $0, list: $1, start: $6, end: $3),
        right: @core.list-reverse(T: $0, list: $1, start: $2, end: $6)
      )
  }
visibility
public
core.list-reverse (project definy, branch main, snapshot CfIAXM725tR74SWd4aoTUz4-JJQfqnllblZbQ2Sv204)
id: kGBg6OEYsM8pAGxVZNotJfk4F99iukVzsQzn8652xFc
content hash: fTQ0raGpIVD78vHn178zV5NBItmZ-FubVodaaha4PjM