CL Enumerations: Standard Generic Function ENUMERATE
 

Generic function ENUMERATE

Package:

CL.EXTENSIONS.ENUMERATIONS

Syntax:

  enumerate object &key start end &allow-other-keys
  => enumeration
  

Arguments and Values:

object---an object

enumeration---an enumeration instance

start---an object

end---an object or NIL

Description:

The generic function ENUMERATE is the main entry point in the ENUMERATIONS machinery. It takes a CL object, object, some additional parameters, which may or may not be used depending on the type of the object to be enumerated. The ENUMERATE implementations provided are described in the "known methods" section.

Known Methods:

The known methods for ENUMERATE are the following.

  •   enumerate (l list) &key (start 0) end &allow-other-keys
      => list-enumeration
      

    Calling ENUMERATE on a LIST returns a LIST-ENUMERATION instance. l should be a proper list. The behavior of ENUMERATE when passed a non proper list is undefined.

    start must be an integer between 0 and (length l). end must be an integer between 0 and (length l) or NIL. The usual CL semantics regarding sequence traversals applies.

  •   enumerate (a array) &key (start 0) end &allow-other-keys
      => array-enumeration
      

    Calling ENUMERATE on an ARRAY returns an ARRAY-ENUMERATION instance.

    start must be either an integer between 0 and (array-total-size a), or a LIST of indices between 0 and the appropriate limit on the array-dimension. end must be an integer between 0 and (array-total-size a), or a LIST of indices between 0 and the appropriate limit on the array-dimension, or NIL. If end is nil then it is set to (array-total-size a).

  •   enumerate (v vector) &key (start 0) end &allow-other-keys
      => vector-enumeration
      

    Calling ENUMERATE on a VECTOR returns a VECTOR-ENUMERATION instance.

    start must be an integer between 0 and (length v). end must be an integer between 0 and (length v) or NIL. The usual CL semantics regarding sequence traversals applies.

  •   enumerate (s string) &key (start 0) end &allow-other-keys
      => vector-enumeration
      

    Calling ENUMERATE on a STRING returns a STRING-ENUMERATION instance. A STRING-ENUMERATION traverses the STRING s using the accessor CHAR.

    start must be an integer between 0 and (length s). end must be an integer between 0 and (length s) or NIL. The usual CL semantics regarding sequence traversals applies.

  •   enumerate (ht hash-table) &allow-other-keys
      => hash-table-enumeration
      

    Calling ENUMERATE on a HASH-TABLE returns a HASH-TABLE-ENUMERATION instance.

    Note that it makes no sense to set "bounds" on a HASH-TABLE-ENUMERATION, as an HASH-TABLE is an unordered data structure.

  •   enumerate (n (eql 'number)) &key (start 0) end (by #'1) &allow-other-keys
      => number-enumeration
      

    Calling ENUMERATE on a the symbol NUMBER returns a NUMBER-ENUMERATION instance.

    NUMBER-ENUMERATIONs are not real enumerations per se, but they have a nice interface and serve to render things like Python xrange type.

    startmust be a number, while end can be a number or NIL. The next (or previous) element is obtained by changing the current element by by. by can be a function (#'1+ is the default) or a number, in which case it is always summed to the current element.

    A NUMBER-ENUMERATION can also enumerate COMPLEX numbers, but in this case the actual enumeration properties are completely determined by the value of by.

Affected By:

None.

Exceptional Situations:

ENUMERATE calls MAKE-INSTANCE on the appropriate ENUMERATION sub-class. The instance initialization machinery may signal various errors. See the documentation for each ENUMERATION sub-class for details.

See Also:

ENUMERATION class, BOUNDED-ENUMERATION, NUMBER-ENUMERATION, BI-DIRECTIONAL-ENUMERATION, SEQUENCE-ENUMERATION, LIST-ENUMERATION, ARRAY-ENUMERATION, VECTOR-ENUMERATION, STRING-ENUMERATION, HASH-TABLE-ENUMERATION, NEXT, HAS-NEXT-P, CURRENT, PREVIOUS, HAS-PREVIOUS-P.

Notes:

None.