Skip to content

Instantly share code, notes, and snippets.

@shirok
Created July 15, 2012 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shirok/3118861 to your computer and use it in GitHub Desktop.
Save shirok/3118861 to your computer and use it in GitHub Desktop.
(use srfi-60) ; for list->integer
(define read-bools
($ gconcatenate $ gmap (cut reverse-bits->generator <> 0 8)
$ port->byte-generator $))
(define (string->bools s) (call-with-input-string s read-bools))
(define (write-bools src)
($ generator-for-each (^b (write-byte (list->integer b)) (flush))
$ gslices src 8 #t 0))
(define (bools->string bs) (with-output-to-string (cut write-bools bs)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment