Next: , Previous: , Up: bytevectors 8   [Index]


27.2.7 Mapping functions

Function: bytevector-s8-map proc bv0 bv ...
Function: bytevector-u8-map proc bv0 bv ...

Build and return a newly–allocated bytevector mapping proc over all the bytes of the bytevector arguments, from zero to the end in increasing order. It is an error if the bytevectorss have different length.

proc must return an exact integer representing a byte and it is applied to the elements as:

(proc idx
  (bytevector-u8-ref bv0 idx)
  (bytevector-u8-ref bv  idx)
  ...)

where idx is the current index.

Function: bytevector-s8-map! proc bv0 bv ...
Function: bytevector-u8-map! proc bv0 bv ...
Function: bytevector-s8-map*! proc bv0 bv ...
Function: bytevector-u8-map*! proc bv0 bv ...

Mutate bytevector bv0 mapping proc over all the elements of the bytevector arguments, from zero to the end in increasing order.

bytevector-u8-map! must be applied to bytevectorss of the same length; bytevector-u8-map*! accepts bytevectorss of different length and iterates until the end of the shorter is reached.

proc is applied to the elements as:

(proc idx
  (bytevector-u8-ref bv0 idx)
  (bytevector-u8-ref bv  idx)
  ...)

where idx is the current index.

Function: bytevector-s8-for-each* proc bv0 bv ...
Function: bytevector-u8-for-each* proc bv0 bv ...

Apply proc over all the elements of the bytevector arguments, from zero to the end in increasing order. This function accepts bytevectorss of different length and iterates until the end of the shorter is reached.

proc is applied to the elements as:

(proc idx
  (bytevector-u8-ref bv0 idx)
  (bytevector-u8-ref bv  idx)
  ...)

where idx is the current index.

Mapping over subvectors

Function: %subbytevector-s8-map proc bv start past
Function: %subbytevector-u8-map proc bv start past
Macro: subbytevector-s8-map proc B
Macro: subbytevector-u8-map proc B

Build and return a new bytevector mapping proc over the bytes in the selected subvector of bv, from index start to index past in increasing order. proc must be a byte–to–byte procedure.

Function: %subbytevector-s8-map! proc bv start past
Function: %subbytevector-u8-map! proc bv start past
Macro: subbytevector-s8-map! proc B
Macro: subbytevector-u8-map! proc B

Mutate the selected subvector of bv, mapping proc over its bytes from index start to index past in increasing order. proc must be a byte–to–byte procedure.

Function: %subbytevector-s8-for-each proc bv start past
Function: %subbytevector-u8-for-each proc bv start past
Macro: subbytevector-s8-for-each proc B
Macro: subbytevector-u8-for-each proc B

Apply proc to each byte in the selected subvector of bv, from index start to index past in increasing order.

Function: %subbytevector-s8-for-each-index proc bv start past
Function: %subbytevector-u8-for-each-index proc bv start past
Macro: subbytevector-s8-for-each-index proc B
Macro: subbytevector-u8-for-each-index proc B

Apply proc to each index in the selected subvector of bv, from index start to index past in increasing order. This is simply a method of looping over a bytevector that is guaranteed to be safe and correct.


Next: , Previous: , Up: bytevectors 8   [Index]