Explorer

std.bytes-replace-from

description
Appends bytes from index to the end to result, taking the bytes of replacement from start instead
type
Fn(
  bytes: List<Number>,
  start: Number,
  replacement: List<Number>,
  index: Number,
  result: List<Number>
) -> List<Number>
expression
fn(bytes$0, start$1, replacement$2, index$3, result$4) =>
  match @core.list-get(list: $0, index: $3) {
    #none(_) =>
      $4,
    #some(byte$5) =>
      @std.bytes-replace-from(
        bytes: $0,
        start: $1,
        replacement: $2,
        index: @core.plus(left: $3, right: 1),
        result: @core.list-append(
          list: $4,
          item: match @core.list-get(list: $2, index: @core.minus(left: $3, right: $1)) {
            #none(_) =>
              $5,
            #some(replaced$6) =>
              match @core.less-than(left: $3, right: $1) {
                true =>
                  $5,
                false =>
                  $6
              }
          }
        )
      )
  }
visibility
public
std.bytes-replace-from (project definy, branch auto-release, snapshot oiQgPqhJm-TbM4kexXeRHBaJB_tS7gwBSewII64P-44)
id: dofZTLFvJSMSpr4i9_EINwx_L-_OCrgwCRwD-K2fY6w
content hash: 5SEkpaOgxXZY26KT2pMN1XmicVIf7D2i1Xp_26NPPfU