Extra SRFI Libraries
1 SRFI-112 Environment Inquiry
2 SRFI-141 Integer division
3 SRFI-151 Bitwise Operations
4 SRFI-158 Generators and Accumulators
rkt-generator->srfi-generator
5 SRFI-175 ASCII character library
6 SRFI-190 Coroutine Generators
7 SRFI-208 Na  N Procedures
8 SRFI-223 Generalized binary search procedures
bytes-bisect-left
bytes-bisect-right
8.6

Extra SRFI Libraries

    1 SRFI-112 Environment Inquiry

    2 SRFI-141 Integer division

    3 SRFI-151 Bitwise Operations

    4 SRFI-158 Generators and Accumulators

    5 SRFI-175 ASCII character library

    6 SRFI-190 Coroutine Generators

    7 SRFI-208 NaN Procedures

    8 SRFI-223 Generalized binary search procedures

While Racket comes with a number of SRFI libraries, it’s missing quite a lot of useful ones. This collection adds some.

A note on licensings: Most of the included SRFIs are the reference implementations adapted to Racket, and retain the original licenses.

1 SRFI-112 Environment Inquiry

 (require srfi/112) package: extra-srfi-libs

Reference documentation.

Notes: (os-version) always returns #f, but the other functions are all implemented.

2 SRFI-141 Integer division

 (require srfi/141) package: extra-srfi-libs

 (require typed/srfi/141) package: extra-srfi-libs

Reference documentation.

Notes:

The functions in the typed version are constrained to only take and return exact integers. The regular package’s will accept inexact integers.

3 SRFI-151 Bitwise Operations

 (require srfi/151) package: extra-srfi-libs

Reference documentation.

Notes:

Written in Typed Racket. Hopefully the type signatures should be obvious and intuitive. If performance matters, code that uses these routines should also be written in Typed Racket.

4 SRFI-158 Generators and Accumulators

 (require srfi/158) package: extra-srfi-libs

Reference documentation. Also includes SRFI-221 Generator/accumulator sub-library routines.

These generators are not compatible with the ones in "racket/generator". There is an adaptor function provided to wrap Racket generators in SRFI-158 ones, but beware of conflicting generator identifiers in the two modules.

procedure

(rkt-generator->srfi-generator g)  (-> any/c)

  g : generator?
Adapt a Racket generator to a SRFI-158 generator. Generators that are called with arguments are not supported.

5 SRFI-175 ASCII character library

 (require srfi/175) package: extra-srfi-libs

Reference documentation.

Notes:

What the SRFI calls a bytevector is what Racket calls a byte string.

6 SRFI-190 Coroutine Generators

 (require srfi/190) package: extra-srfi-libs

Reference documentation.

Notes: The yield syntax conflicts with racket/generator.

7 SRFI-208 NaN Procedures

 (require srfi/208) package: extra-srfi-libs

Reference documentation.

Notes:

Currently only works with double-precision flonums, though the SRFI allows for other floating point types. While Racket BC supports single precision flonums, Racket CS doesn’t, and I don’t have a version of CS installed that supports extflonums for testing. If either changes I might go back and add support for those types.

8 SRFI-223 Generalized binary search procedures

 (require srfi/223) package: extra-srfi-libs

Reference documentation.

 (require srfi/223/bytes) package: extra-srfi-libs

SRFI-223 procedures specialized for byte strings.

procedure

(bytes-bisect-left bs val less? [lo hi])  integer?

  bs : bytes?
  val : byte?
  less? : (-> byte? byte? any/c)
  lo : integer? = 0
  hi : integer? = (bytes-length bs)
Do a binary search in bs for val per SRFI-223 bisect-left.

procedure

(bytes-bisect-right bs val less? [lo hi])  integer?

  bs : bytes?
  val : byte?
  less? : (-> byte? byte? any/c)
  lo : integer? = 0
  hi : integer? = (bytes-length bs)
Do a binary search in bs for val per SRFI-223 bisect-right.