Explorer

cbor.head-bytes

description
The CBOR head of the major type with the argument value (the shortest form)
type
Fn(major: Number, value: Number) -> List<Number>
expression
fn(major$0, value$1) =>
  let base$2 = @core.multiply(left: $0, right: 32);
  match @core.less-than(left: $1, right: 24) {
    true =>
      [@core.plus(left: $2, right: $1)],
    false =>
      match @core.less-than(left: $1, right: 256) {
        true =>
          [@core.plus(left: $2, right: 24), $1],
        false =>
          match @core.less-than(left: $1, right: 65536) {
            true =>
              @core.list-concat(left: [@core.plus(left: $2, right: 25)], right: @cbor.uint-bytes(value: $1, count: 2)),
            false =>
              match @core.less-than(left: $1, right: 4294967296) {
                true =>
                  @core.list-concat(left: [@core.plus(left: $2, right: 26)], right: @cbor.uint-bytes(value: $1, count: 4)),
                false =>
                  @core.list-concat(left: [@core.plus(left: $2, right: 27)], right: @cbor.uint-bytes(value: $1, count: 8))
              }
          }
      }
  }
visibility
public
cbor.head-bytes (project cbor, branch main, snapshot 5bvML2Im-osGmgnKJsp0FwmfSMONephnrgdWQboV3-E)
id: KS1rsUl-5aPQ7HlZhRBaVCARaTQqRp01belGw4jCVvk
content hash: iI_0ZEt4NziNhDkznrOy0ZAX7KYLYmJNBKirVFXTYCc