46 lines
1.4 KiB
TeX
46 lines
1.4 KiB
TeX
%&latex -*- latex -*-
|
|
|
|
\chapter{Miscellaneous routines}
|
|
|
|
\section{Integer bitwise ops}
|
|
\label{sec:bitwise}
|
|
\defun{arithmetic-shift} {i j} \integer
|
|
\defunx {bitwise-and} {i j} \integer
|
|
\defunx {bitwise-ior} {i j} \integer
|
|
\defunx {bitwise-not} {i} \integer
|
|
\defunx {bitwise-xor} {i j} \integer
|
|
\begin{desc}
|
|
These operations operate on integers representing semi-infinite
|
|
bit strings, using a 2's-complement encoding.
|
|
|
|
\ex{arithmetic-shift} shifts \var{i} by \var{j} bits.
|
|
A left shift is $j > 0$; a right shift is $j < 0$.
|
|
\end{desc}
|
|
|
|
\section{List procedures}
|
|
\defun{nth}{list i}\object
|
|
\begin{desc}
|
|
Returns the $i^{\mathrm th}$ element of \var{list}.
|
|
The first element (the car) is \ex{(nth \var{list} 0)},
|
|
the second element is \ex{(nth \var{list} 1)}, and so on.
|
|
|
|
This procedure is provided as it is useful for accessing elements
|
|
from the lists returned by the field-readers (chapter~\ref{chapt:fr-awk}).
|
|
\end{desc}
|
|
|
|
|
|
\section{Top level}
|
|
\defun{repl}{}\undefined
|
|
\begin{desc}
|
|
This runs a {\scm} read-eval-print loop,
|
|
reading forms from the current input port,
|
|
and writing their values to the current output port.
|
|
|
|
If you wish to try something dangerous,
|
|
and want to be able to recover your shell state, you can
|
|
fork off a subshell with the following form:
|
|
\codex{(run (begin (repl)))}
|
|
{\ldots}or, rephrased for the proceduralists:
|
|
\codex{(wait (fork repl))}
|
|
\end{desc}
|