wiki:CompleteSequenceCowan

Version 3 (modified by cowan, 7 years ago) (diff)

Added tables

The WG1 charter says "Self consistency is an important objective, which may require adding new features." Scheme has three sequence types: lists, strings, and vectors, but the support for them is not consistent. Lists have the most support, strings and vectors have much less, and inconsistently so. I propose providing the following procedures, some of which are R5RS, some R6RS, some in various SRFIs, and some new:

Type of procedureListsStringsVectorsTables
Basic constructormake-list (SRFI 1)make-stringmake-vectormake-table
Variadic constructorliststringvectortable
Copy constructorcopy-list (SRFI 1)copy-stringcopy-vector (SRFI 43)copy-table
Basic predicatelist?string?vector?table?
Sequence lengthlengthstring-lengthvector-lengthtable-length
Element access?list-refstring-refvector-reftable-ref
Element mutatorlist-set! (proposed)string-set!vector-set!table-set!
Map functionmapstring-map (SRFI 13 extended)vector-map (R6RS)table-map
Map side effectsfor-eachstring-for-each (proposed)vector-for-each (R6RS)table-for-each
Convert to list---string->listvector->listtable->list
Convert to stringlist->string---vector->string (proposed)---
Convert to vectorlist->vectorstring->vector (proposed)------
Convert to tablelist->table---------

In summary: 33 procedures, 23 in R5RS, 2 in R6RS, 2 in SRFI 1, 1 in SRFI 43, 1 in SRFI-13 but extended to take multiple strings, 4 novel but obvious.

I further propose that the map and for-each groups should be specified to implicitly truncate all sequence arguments to the length of the shortest sequence.

Update: I have added an additional row and column to this table that reflects the TablesCowan proposal.