Explorer

core.decode-number-until

description
Reads a decimal number (- for a negative one) from index on that ends with the byte end. next is the index after end. none if end does not follow. For core.decode-value
type
Fn(bytes: List<Number>, index: Number, end: Number) -> Union{#none, #some(Record{value: Number, next: Number})}
expression
fn(bytes$0, index$1, end$2) =>
  let negative$3 = match @core.list-get(list: $0, index: $1) {
      #some(byte$4) =>
        @core.equal(left: $4, right: 45),
      #none(_) =>
        false
    };
  let read$5 = @core.decode-digits(
      bytes: $0,
      index: match $3 {
        true =>
          @core.plus(left: $1, right: 1),
        false =>
          $1
      },
      value: 0
    );
  match @core.list-get(list: $0, index: $5.next) {
    #some(byte$6) =>
      match @core.equal(left: $6, right: $2) {
        true =>
          #some({
            value: match $3 {
              true =>
                @core.minus(left: 0, right: $5.value),
              false =>
                $5.value
            },
            next: @core.plus(left: $5.next, right: 1)
          }),
        false =>
          #none
      },
    #none(_) =>
      #none
  }
visibility
public
core.decode-number-until (project definy, branch main, snapshot l0VFjJZP174d8CbZWFoujAGTYjgsQu4uTq5uWCZaXgo)
id: baxUwEVrRFlXenibYcXJiyybXO1dsrM-ovL5MAU2xcU
content hash: ISCb5xfUAQE5aePojACcrH5tXhgQw2u1mYsvWJJr0Io