Explorer

cbor.byte-items

description
The items from start to end (exclusive) as bytes if all of them are integers from 0 to 255
type
Fn(items: List<@cbor.item>, start: Number, end: Number) -> Union{#none, #some(List<Number>)}
expression
fn(items$0, start$1, end$2) =>
  let count$3 = @core.minus(left: $2, right: $1);
  match @core.less-than(left: $3, right: 2) {
    true =>
      match @core.equal(left: $3, right: 1) {
        true =>
          match @core.list-get(list: $0, index: $1) {
            #some(item$4) =>
              match $4 {
                #integer(byte$5) =>
                  match @core.and(left: @core.less-than(left: -1, right: $5), right: @core.less-than(left: $5, right: 256)) {
                    true =>
                      #some([$5]),
                    false =>
                      #none
                  },
                _ =>
                  #none
              },
            #none(_) =>
              #none
          },
        false =>
          #some([])
      },
    false =>
      let middle$6 = @core.plus(left: $1, right: @core.divide(left: $3, right: 2));
      match @cbor.byte-items(items: $0, start: $1, end: $6) {
        #some(left$7) =>
          match @cbor.byte-items(items: $0, start: $6, end: $2) {
            #some(right$8) =>
              #some(@core.list-concat(left: $7, right: $8)),
            #none(_) =>
              #none
          },
        #none(_) =>
          #none
      }
  }
visibility
public
cbor.byte-items (project cbor, branch main, snapshot 5bvML2Im-osGmgnKJsp0FwmfSMONephnrgdWQboV3-E)
id: 8bX4dA7QjpMWg-vyNL6es-HF1y_jETkibtjmh9kE15I
content hash: LK3NtQW8unmKIVy1mXa4rLrvsIgB5iqqz-08R_kBh8Y