Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
== Outdated egg! This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for [[/eggref/5/byte-blob-stream|the CHICKEN 5 version of this egg]], if it exists. If it does not exist, there may be equivalent functionality provided by another egg; have a look at the [[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:]] == byte-blob-stream === Description {{byte-blob-stream}} is a library of routines for manipulating [[byte-blob|byte blobs]] contained in [[srfi-41|SRFI-41]] streams. === Library Procedures ==== Predicates <procedure>(byte-blob-stream? X) => BOOL</procedure> Returns {{#t}} if the given object is a stream that is either empty or its first element is a byte blob, {{#f}} otherwise. <procedure>(byte-blob-stream-empty? STREAM) => BOOL</procedure> Returns {{#t}} if the given stream is empty, {{#f}} otherwise. ==== Constructors <procedure>(byte-blob-stream-empty) => STREAM</procedure> Returns an empty stream. <procedure>(byte-blob-stream-cons BYTE-BLOB STREAM) => STREAM</procedure> Prepends the given byte blob to the given stream and returns the resulting stream. ==== Accessors <procedure>(byte-blob-stream-length STREAM) => INTEGER</procedure> Returns the number of elements contained in all byte blobs in the given stream. <procedure>(byte-blob-stream-car STREAM) => X</procedure> 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. <procedure>(byte-blob-stream-cdr STREAM) => STREAM</procedure> 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. <procedure>(byte-blob-stream-ref STREAM I) => BYTE</procedure> Returns the i-th element of the given stream of byte blobs. ==== Transformers <procedure>(byte-blob-stream-append STREAM STREAM) => STREAM </procedure> Appends two streams of byte blobs together. <procedure>(byte-blob-stream-reverse STREAM) => STREAM</procedure> Returns a stream that contains the elements of the given stream of byte blobs in reverse order. <procedure>(byte-blob-stream-intersperse STREAM BYTE) => STREAM</procedure> 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. <procedure>(byte-blob-stream-map F STREAM) => STREAM</procedure> Returns a stream of byte blobs obtained by applying {{F}} to each element of the byte blobs in the input stream. <procedure>(byte-blob-stream->list STREAM) => LIST</procedure> Returns a list containing the elements of the byte blobs contained in the input stream. If procedure {{F}} is provided as a second argument, it is applied to every element of the returned list. <procedure>(list->byte-blob-stream LIST) => STREAM</procedure> Returns a stream of a single byte blob containing the elements of the given list. ==== Subsequences <procedure>(byte-blob-stream-take STREAM N) => STREAM</procedure> Returns the prefix of the given stream of byte blobs of length {{N}}. <procedure>(byte-blob-stream-drop STREAM N) => STREAM</procedure> Returns the suffix of the given stream of byte blobs after the first {{N}} elements. <procedure>(byte-blob-stream-span STREAM START END) => STREAM</procedure> Returns the subsequence of the given stream of byte blobs from position {{START}} to position {{END}}. ==== Fold <procedure>(byte-blob-stream-fold-left F INIT STREAM) => VALUE</procedure><br> <procedure>(byte-blob-stream-fold-right F INIT STREAM) => VALUE</procedure><br> 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. ==== Find <procedure>(byte-blob-stream-find NEEDLE HAYSTACK) => LIST</procedure> Finds all non-overlapping instances of the byte blob {{NEEDLE}} in the stream of byte blobs {{HAYSTACK}}. The first element of the returned list is the prefix of {{HAYSTACK}} prior to any matches of {{NEEDLE}}. The second is a list of lists. 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. ==== Files <procedure>(file->byte-blob-stream FILENAME [BLOCKSIZE] ) => STREAM</procedure> Reads a file into a {{byte-blob}} stream. === Version History * 1.5 Updated test script to return proper exit code * 1.4 Added procedure {{list->byte-blob-stream}} * 1.3 Added optional second argument to byte-blob-stream->list * 1.2 Added procedure {{file->byte-blob-stream}} * 1.0 Initial release === License Based on ideas from the Haskell [[http://www.cse.unsw.edu.au/~dons/fps.html|bytestring]] library. The code for {{byte-blob-stream-find}} is based on code from the Haskell Text library by Tom Harper and Bryan O'Sullivan. Copyright 2009-2011 Ivan Raikov and the Okinawa Institute of Science and Technology. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. A full copy of the GPL license can be found at <http://www.gnu.org/licenses/>.
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you multiply 3 by 5?