Explorer

core.decode-value-items

description
Reads count more values (core.decode-value-at) from index on after items. It reads the first half and then the rest, so a long list does not need deep recursion
type
Fn(text: String, bytes: List<Number>, index: Number, count: Number, items: List<@core.value>) -> Union{#none, #some(Record{items: List<@core.value>, next: Number})}
expression
fn(text$0, bytes$1, index$2, count$3, items$4) =>
  match @core.less-than-or-equal(left: $3, right: 1) {
    true =>
      match @core.less-than-or-equal(left: $3, right: 0) {
        true =>
          #some({items: $4, next: $2}),
        false =>
          match @core.decode-value-at(text: $0, bytes: $1, index: $2) {
            #some(read$5) =>
              #some({items: @core.list-append(list: $4, item: $5.value), next: $5.next}),
            #none(_) =>
              #none
          }
      },
    false =>
      let half$6 = @core.divide(left: $3, right: 2);
      match @core.decode-value-items(text: $0, bytes: $1, index: $2, count: $6, items: $4) {
        #some(first$7) =>
          @core.decode-value-items(text: $0, bytes: $1, index: $7.next, count: @core.minus(left: $3, right: $6), items: $7.items),
        #none(_) =>
          #none
      }
  }
visibility
public
core.decode-value-items (project definy, branch main, snapshot l0VFjJZP174d8CbZWFoujAGTYjgsQu4uTq5uWCZaXgo)
id: JKFWqJSyhcoSnl6OIyzZGT5Dln5IiB5MnDw30xJPIUU
content hash: rNZsFlUhzl5ljav_MTHuPHSexBf94Eb7-dVAYBaqhZ0