Augmentations to R7RS-small standard libraries.
Import (r7rs-extras all)
to get all of the following.
(r7rs-extras io)
-
(call-with-input-string string proc)
: Appliesproc
to an input port fed withstring
. -
(call-with-output-string proc)
: Appliesproc
to a port feeding a string which is then returned. -
(with-input-port port thunk)
: Closesport
after callingthunk
with it as thecurrent-input-port
. -
(with-output-port port thunk)
: Closesport
after callingthunk
with it as thecurrent-output-port
. -
(with-error-port port thunk)
: Closesport
after callingthunk
with it as thecurrent-error-port
. -
(with-input-from-port port thunk)
: Callsthunk
withport
as thecurrent-input-port
. Doesn't closeport
. -
(with-output-to-port port thunk)
: Callsthunk
withport
as thecurrent-output-port
. Doesn't closeport
. -
(with-error-to-port port thunk)
: Callsthunk
withport
as thecurrent-error-port
. Doesn't closeport
. -
(with-error-to-file file thunk)
: Callsthunk
withcurrent-error-port
bound tofile
. -
(with-input-from-string string thunk)
: Callsthunk
withcurrent-input-port
bound to a port fed withstring
. -
(with-output-to-string thunk)
: Callsthunk
withcurrent-output-port
bound to a port feeding a string which is then returned. -
(with-error-to-string thunk)
: Callsthunk
withcurrent-error-port
bound to a port feeding a string which is then returned.
(r7rs-extras higher-order)
-
(const value)
: Make a nullary procedure always returningvalue
. -
(negate proc)
: Make a procedure negating the application ofproc
to its arguments. -
(compose proc . rest)
: Functional composition; e.g.((compose x y) a)
=(x (y a))
. -
(pipeline proc . rest)
: Reverse functional composition; e.g.((pipeline x y) a)
=(y (x a))
. -
(identity . x)
: Returns values given to it as-is. -
(and=> value proc)
: Ifvalue
is true, callproc
on it, else return false.
(r7rs-extras partition)
-
(partition* list . procs)
: Partitionslist
viaprocs
, returningprocs + 1
many lists; the last list containing elements that didn't match any procedure. The ordering of each list obeys that oflist
. If there are elements matching multipleprocs
, it's unspecified in which one of the matching lists they appear. -
(partition+ list . procs)
: This is like thepartition*
procedure, but elements matching multiple procedures appear in every corresponding list.
(r7rs-extras arithmetic)
-
(euclidean/ x y)
: Returnq
andr
inx = q*y + r
where0 <= r < |y|
. -
(euclidean-quotient x y)
: Returnq
inx = q*y + r
where0 <= R < |y|
. -
(euclidean-remainder x y)
: Returnr
inx = q*y + r
where0 <= r < |y|
. -
(ceiling/ x y)
: Returnq
andr
inx = q*y + r
whereq = ceiling(x/y)
. -
(ceiling-quotient x y)
: Returnq
inx = q*y + r
whereq = ceiling(x/y)
. -
(ceiling-remainder x y)
: Returnr
inx = q*y + r
whereq = ceiling(x/y)
. -
(centered/ x y)
: Returnq
andr
inx = q*y + r
where-|y/2| <= r < |y/2|
. -
(centered-quotient x y)
: Returnq
inx = q*y + r
where-|y/2| <= r < |y/2|
. -
(centered-remainder x y)
: Returnr
inx = q*y + r
where-|y/2| <= r < |y/2|
. -
(round/ x y)
: Returnq
andr
inx = q*y + r
whereq = round(x/y)
. -
(round-quotient x y)
: Returnq
inx = q*y + r
whereq = round(x/y)
. -
(round-remainder x y)
: Returnr
inx = q*y + r
whereq = round(x/y)
.
(r7rs-extras pushpop)
-
(push! pair value)
:(set! pair (cons value pair))
-
(pop! pair)
:(let ((value (car pair))) (set! pair (cdr pair)) value)