Scheme Programmer's Manual

NAME

bytevector-u8-set!, bytevector-s8-set! - modify a byte in a bytevector

LIBRARY

(import (rnrs))                     ;R6RS
(import (rnrs bytevectors))         ;R6RS
(import (scheme base))              ;R7RS

SYNOPSIS

(bytevector-u8-set! bytevector k octet)
(bytevector-s8-set! bytevector k byte)  ;R6RS

DESCRIPTION

The bytevector-u8-set! procedure stores octet at index k of bytevector. The bytevector-s8-set! procedure stores the two's complement representation of byte.

RETURN VALUES

Returns unspecified values.

EXAMPLES

(let ((b (make-bytevector 16 -127)))
  (bytevector-s8-set! b 0 -126)
  (bytevector-u8-set! b 1 246)


  (list
    (bytevector-s8-ref b 0)
    (bytevector-u8-ref b 0)
    (bytevector-s8-ref b 1)
    (bytevector-u8-ref b 1)))
          => (-126 130 -10 246)

COMPATIBILITY

The bytevector-s8-set! procedure is absent from R7RS. A possible implementation is shown below. (define (bytevector-s8-set! bytevector k byte)
  (let ((octet (if (< byte 0) (+ 256 byte) byte)))
    (bytevector-u8-set! bytevector k octet)))

ERRORS

This procedure can raise exceptions with the following condition types:
&assertion (R6RS)
The wrong number of arguments was passed or an argument was outside its domain. The index k was not a valid index for bytevector.

SEE ALSO

bytevector-u16-set!(3)

STANDARDS

R6RS

AUTHORS

This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at

Index

NAME
LIBRARY
SYNOPSIS
DESCRIPTION
RETURN VALUES
EXAMPLES
COMPATIBILITY
ERRORS
SEE ALSO
STANDARDS
AUTHORS
Return to Main Contents