SRFI 43: Vector Library
This SRFI proposes a comprehensive and complete library of vector operations accompanied by a freely available and complete reference implementation. The reference implementation is unencumbered by copyright, and useable with no modifications on any Scheme system that is R5RS-compliant. It also provides several hooks for implementation-specific optimization as well. Because this SRFI is more of a library or module specification than a request for additions to readers or any other internal implementation detail, in an implementation that supports a module or structure or package or library or unit (et cetera) systems, these procedures should be contained in a module / structure / package / library / unit called vector-lib. R5RS provides very few list-processing procedures, for which reason SRFI 1 (list-lib) exists. However, R5RS provides even fewer vector operations — while it provides mapping, appending, et cetera operations for lists, it specifies only nine vector manipulation operations —: Many Scheme implementations provide several vector operations beyond the miniscule set that R5RS defines (the typical vector-append, vector-map, et cetera), but often these procedures have different names, take arguments in different orders, don’t take the same number of arguments, or have some other flaw that makes them unportable. For this reason, this SRFI is proposed. It should be noted that no vector sorting procedures are provided by this SRFI, because there already is a SRFI for such a purpose (SRFI 32 (sort-lib)), which includes routines for sorting not only vectors but also lists. Here is an index of the procedures provided by this package. Those marked by bold are provided in R5RS and those marked by bold italic are defined by R5RS but are modified from their original definitions. In this section containing specifications of procedures, the following notation is used to specify parameters and return values: It should be noted that all of the procedures that iterate across multiple vectors in parallel stop iterating and produce the final result when the end of the shortest vector is reached. The sole exception is vector=, which automatically returns #f if the vectors’ lengths vary. With this SRFI comes a complete reference implementation. It is licensed under a very open copyright with which no implementors should have any legal issues. The reference implementation has only one non-R5RS dependency: SRFI 23’s error procedure. This reference implementation of all the procedures described in this SRFI can be found here. Thanks to Olin Shivers for his wonderfully complete list and string packages, to all the members of the #scheme IRC channel on Freenode who nitpicked a great deal, but also helped quite a lot in general, and helped test the reference implementation in various Scheme systems, to Michael Burschik for his numerous comments, to Sergei Egorov for helping to narrow down the procedures, to Mike Sperber for putting up with an extremely overdue draft, to Felix Winkelmann for continually bugging me about finishing up the SRFI so that it would be only overdue and not withdrawn, and to everyone else who gave questions, comments, thoughts, or merely attention to the SRFI. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Source.