3.2.4 Fixnums
The racket/fixnum library provides operations like
fx+ that consume and produce only fixnums. The operations in
this library are meant to be safe versions of unsafe operations like
unsafe-fx+. These safe operations are generally no faster
than using generic primitives like +.
The expected use of the racket/fixnum library is for
code where the require of racket/fixnum is
replaced with
to drop in unsafe versions of the library. Alternately, when
encountering crashes with code that uses unsafe fixnum operations, use
the racket/fixnum library to help debug the problems.
3.2.4.1 Fixnum Arithmetic
3.2.4.2 Fixnum Vectors
A fxvector is like a vector, but it holds only
fixnums. The only advantage of a fxvector over a
vector is that a shared version can be created with functions
like shared-fxvector.
Two fxvectors are equal? if they have the same length,
and if the values in corresponding slots of the fxvectors are
equal?.
Returns
#t if
v is a
fxvector,
#f otherwise.
Example: |
> (fxvector 2 3 4 5) |
#<fxvector> |
Creates a
fxvector with
size elements, where every
slot in the
fxvector is filled with
x.
Returns the length of
vec (i.e., the number of slots in the
fxvector).
Returns the
fixnum in slot
pos of
vec. The first slot is position
0, and the last slot
is one less than
(fxvector-length vec).
Sets the
fixnum in slot
pos of
vec. The
first slot is position
0, and the last slot is one less than
(fxvector-length vec).
Creates a fresh
fxvector of size
(- end start), with all of the
elements of
vec from
start (inclusive) to
end (exclusive).
Returns a sequence equivalent to vec when no optional
arguments are supplied.
The optional arguments start, stop, and
step are as in in-vector.
An in-fxvector application can provide better
performance for fxvector iteration when it appears directly in a for clause.