((section 2 "Outdated egg!" (p "This is an egg for CHICKEN 4, the unsupported old release.  You're almost certainly looking for " (int-link "/eggref/5/byte-blob-stream" "the CHICKEN 5 version of this egg") ", if it exists.") (p "If it does not exist, there may be equivalent functionality provided by another egg; have a look at the " (link "https://wiki.call-cc.org/chicken-projects/egg-index-5.html" "egg index") ". Otherwise, please consider porting this egg to the current version of CHICKEN.") (tags "eggs") (toc)) (section 2 "byte-blob-stream" (section 3 "Description" (p (tt "byte-blob-stream") " is a library of routines for manipulating " (int-link "byte-blob" "byte blobs") " contained in " (int-link "srfi-41" "SRFI-41") " streams.")) (section 3 "Library Procedures" (section 4 "Predicates" (def (sig (procedure "(byte-blob-stream? X) => BOOL" (id byte-blob-stream?))) (p "Returns " (tt "#t") " if the given object is a stream that is either empty or its first element is a byte blob, " (tt "#f") " otherwise.")) (def (sig (procedure "(byte-blob-stream-empty? STREAM) => BOOL" (id byte-blob-stream-empty?))) (p "Returns " (tt "#t") " if the given stream is empty, " (tt "#f") " otherwise."))) (section 4 "Constructors" (def (sig (procedure "(byte-blob-stream-empty) => STREAM" (id byte-blob-stream-empty))) (p "Returns an empty stream.")) (def (sig (procedure "(byte-blob-stream-cons BYTE-BLOB STREAM) => STREAM" (id byte-blob-stream-cons))) (p "Prepends the given byte blob to the given stream and returns the resulting stream."))) (section 4 "Accessors" (def (sig (procedure "(byte-blob-stream-length STREAM) => INTEGER" (id byte-blob-stream-length))) (p "Returns the number of elements contained in all byte blobs in the given stream.")) (def (sig (procedure "(byte-blob-stream-car STREAM) => X" (id byte-blob-stream-car))) (p "Returns the first element of the first byte blob contained in the given stream. The stream argument must be non-empty, or an exception will be thrown.")) (def (sig (procedure "(byte-blob-stream-cdr STREAM) => STREAM" (id byte-blob-stream-cdr))) (p "Returns a stream that contains the elements after the first element of the given byte blob. The argument stream must be non-empty, or an exception will be thrown.")) (def (sig (procedure "(byte-blob-stream-ref STREAM I) => BYTE" (id byte-blob-stream-ref))) (p "Returns the i-th element of the given stream of byte blobs."))) (section 4 "Transformers" (def (sig (procedure "(byte-blob-stream-append STREAM STREAM) => STREAM " (id byte-blob-stream-append))) (p "Appends two streams of byte blobs together.")) (def (sig (procedure "(byte-blob-stream-reverse STREAM) => STREAM" (id byte-blob-stream-reverse))) (p "Returns a stream that contains the elements of the given stream of byte blobs in reverse order.")) (def (sig (procedure "(byte-blob-stream-intersperse STREAM BYTE) => STREAM" (id byte-blob-stream-intersperse))) (p "Returns a stream of byte blobs with the given byte placed between the elements of the each byte blob from the input stream, and between byte blobs.")) (def (sig (procedure "(byte-blob-stream-map F STREAM) => STREAM" (id byte-blob-stream-map))) (p "Returns a stream of byte blobs obtained by applying " (tt "F") " to each element of the byte blobs in the input stream.")) (def (sig (procedure "(byte-blob-stream->list STREAM) => LIST" (id byte-blob-stream->list))) (p "Returns a list containing the elements of the byte blobs contained in the input stream. If procedure " (tt "F") " is provided as a second argument, it is applied to every element of the returned list.")) (def (sig (procedure "(list->byte-blob-stream LIST) => STREAM" (id list->byte-blob-stream))) (p "Returns a stream of a single byte blob containing the elements of the given list."))) (section 4 "Subsequences" (def (sig (procedure "(byte-blob-stream-take STREAM N) => STREAM" (id byte-blob-stream-take))) (p "Returns the prefix of the given stream of byte blobs of length " (tt "N") ".")) (def (sig (procedure "(byte-blob-stream-drop STREAM N) => STREAM" (id byte-blob-stream-drop))) (p "Returns the suffix of the given stream of byte blobs after the first " (tt "N") " elements.")) (def (sig (procedure "(byte-blob-stream-span STREAM START END) => STREAM" (id byte-blob-stream-span))) (p "Returns the subsequence of the given stream of byte blobs from position " (tt "START") " to position " (tt "END") "."))) (section 4 "Fold" (def (sig (procedure "(byte-blob-stream-fold-left F INIT STREAM) => VALUE" (id byte-blob-stream-fold-left)) (procedure "(byte-blob-stream-fold-right F INIT STREAM) => VALUE" (id byte-blob-stream-fold-right))) (p "Given a procedure of two arguments, a starting value, and a stream of byte blobs, reduces the stream using the supplied procedure, from left to right, or right to left, respectively."))) (section 4 "Find" (def (sig (procedure "(byte-blob-stream-find NEEDLE HAYSTACK) => LIST" (id byte-blob-stream-find))) (p "Finds all non-overlapping instances of the byte blob " (tt "NEEDLE") " in the stream of byte blobs " (tt "HAYSTACK") ". The first element of the returned list is the prefix of " (tt "HAYSTACK") " prior to any matches of " (tt "NEEDLE") ". The second is a list of lists.") (p "The first element of each pair in the list is a span from the beginning of a match to the beginning of the next match, while the second is a span from the beginning of the match to the end of the input."))) (section 4 "Files" (def (sig (procedure "(file->byte-blob-stream FILENAME [BLOCKSIZE] ) => STREAM" (id file->byte-blob-stream))) (p "Reads a file into a " (tt "byte-blob") " stream.")))) (section 3 "Version History" (ul (li "1.5 Updated test script to return proper exit code") (li "1.4 Added procedure " (tt "list->byte-blob-stream")) (li "1.3 Added optional second argument to byte-blob-stream->list") (li "1.2 Added procedure " (tt "file->byte-blob-stream")) (li "1.0 Initial release"))) (section 3 "License" (p "Based on ideas from the Haskell " (link "http://www.cse.unsw.edu.au/~dons/fps.html" "bytestring") " library.") (p "The code for " (tt "byte-blob-stream-find") " is based on code from the Haskell Text library by Tom Harper and Bryan O'Sullivan.") (pre " Copyright 2009-2011 Ivan Raikov and the Okinawa Institute of Science and Technology.") (pre " This program is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as\n published by the Free Software Foundation, either version 3 of the\n License, or (at your option) any later version.") (pre " This program is distributed in the hope that it will be useful, but\n WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n General Public License for more details.") (pre " A full copy of the GPL license can be found at\n <http://www.gnu.org/licenses/>."))))