[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

On sequences



1. I suggest that we define the TAIL of any empty sequence to be that
   empty sequence. That's currently the case for lists. (TAIL "") now
   yields #{a very long string whose length is -1} (cute but useless?).
   T 1.89 doesn't have TAIL defined for vectors.

2. Any new thoughts on what to do about generic ops on sequences
   (LENGTH, APPEND, MAP, WALK, MEM, COPY, ...)?  If people don't want
   to make these names generic (I'm undecided), how about a similar
   set of names, using a prefix like | ("bar") in front of the old,
   familiar names to indicate the generic-ness?  If they know the type
   of sequence and don't want to pay for the dispatch, they can use
   the original names (for lists) or long, ugly names (like
   VECTOR-APPEND) for other types.

   --- Predicates ---
   (|NULL? seq)         (i.e., EMPTY?) (That's why it's a prefix, not a suffix)
   (|EQ? seq1 seq2)     [same type]
   (|EQUIV? seq1 seq2)  [not necessarily same type. E.g., '(0 1 6),
                         '#(0 1 6), and "016" are |EQUIV?.]

   --- Constructors ---  [These try to preserve type whenever possible.]
   (|MAKE-SEQUENCE length)      [mixed-type]
   (|CONS object seq)           [not necessarily the same type]
   (|APPEND . sequences)        [not necessarily all the same type]
   (|APPEND! . sequences)
   (|COPY seq)

   --- Selectors ---
   (|CAR seq)                   (i.e., HEAD) [maybe should be |HEAD] settable
   (|CDR seq)                   (i.e., TAIL) [maybe should be |TAIL] settable
   (|NTH seq n)                                                      settable
   (|NTHTAIL seq n)             [maybe |NTHCDR]                      settable
   (|SUBSEQ seq start count)                                         settable
   (|SUBSEQ! seq start count)   [shared subsequence, not defined on all types]


   --- Searchers ---
   (|MEM predicate seq)         [first tail whose head satisfies predicate]
   (|POS predicate seq)
   (|ANY predicate . sequences)
   (|EVERY predicate . sequences)

   --- Traversers ---
   (|LENGTH seq)
   (|REVERSE seq)
   (|REVERSE! seq)
   (|MAP procedure . sequences)         [not necessarily all the same type]
   (|MAP! procedure . sequences)         [not necessarily all the same type]
   (|WALK procedure . sequences)
   (|FILTER predicate seq)
   (|FILTER! predicate seq)

   --- Miscellany ---
   (|COERCE seq type)   [e.g., replacing STRING->LIST, LIST->STRING; not guaranteed
                         to succeed, as in (|COERCE "0011020" 'BITV)]
   (|TYPE seq)          [the MOST restrictive type, one of BIT, BYTE, CHARACTER,
                         INTEGER, FLOAT, REAL, RATIO, NUMBER, SYMBOL, OBJECT]

   Perhaps with ASSERTs, the compiler could use the type-specific routine.
-------