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): Appliesprocto an input port fed withstring. -
(call-with-output-string proc): Appliesprocto a port feeding a string which is then returned. -
(with-input-port port thunk): Closesportafter callingthunkwith it as thecurrent-input-port. -
(with-output-port port thunk): Closesportafter callingthunkwith it as thecurrent-output-port. -
(with-error-port port thunk): Closesportafter callingthunkwith it as thecurrent-error-port. -
(with-input-from-port port thunk): Callsthunkwithportas thecurrent-input-port. Doesn't closeport. -
(with-output-to-port port thunk): Callsthunkwithportas thecurrent-output-port. Doesn't closeport. -
(with-error-to-port port thunk): Callsthunkwithportas thecurrent-error-port. Doesn't closeport. -
(with-error-to-file file thunk): Callsthunkwithcurrent-error-portbound tofile. -
(with-input-from-string string thunk): Callsthunkwithcurrent-input-portbound to a port fed withstring. -
(with-output-to-string thunk): Callsthunkwithcurrent-output-portbound to a port feeding a string which is then returned. -
(with-error-to-string thunk): Callsthunkwithcurrent-error-portbound 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 ofprocto 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): Ifvalueis true, callprocon it, else return false.
(r7rs-extras partition)
-
(partition* list . procs): Partitionslistviaprocs, returningprocs + 1many 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): Returnqandrinx = q*y + rwhere0 <= r < |y|. -
(euclidean-quotient x y): Returnqinx = q*y + rwhere0 <= R < |y|. -
(euclidean-remainder x y): Returnrinx = q*y + rwhere0 <= r < |y|. -
(ceiling/ x y): Returnqandrinx = q*y + rwhereq = ceiling(x/y). -
(ceiling-quotient x y): Returnqinx = q*y + rwhereq = ceiling(x/y). -
(ceiling-remainder x y): Returnrinx = q*y + rwhereq = ceiling(x/y). -
(centered/ x y): Returnqandrinx = q*y + rwhere-|y/2| <= r < |y/2|. -
(centered-quotient x y): Returnqinx = q*y + rwhere-|y/2| <= r < |y/2|. -
(centered-remainder x y): Returnrinx = q*y + rwhere-|y/2| <= r < |y/2|. -
(round/ x y): Returnqandrinx = q*y + rwhereq = round(x/y). -
(round-quotient x y): Returnqinx = q*y + rwhereq = round(x/y). -
(round-remainder x y): Returnrinx = q*y + rwhereq = 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)