## Outdated egg!

This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for 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 egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.

## Fundamental sequence operations

This module provides the minimum necessary to handle linear container datatypes under a common sequence interface. It's written primary to be used in the bindings egg but secondary to be extendable to a full-fledged sequence package.

### Documentation

#### basic-sequences

*[procedure]*

`(basic-sequences sym ..)`

documentation procedure. Shows the exported symbols and the syntax of such an exported symbol, respectively.

#### seq-exception

*[procedure]*

`(seq-exception loc msg . args)`

generates a composite condition of type (exn sequence) with location loc, message msg and arguments args.

#### seq-ref

*[procedure]*

`(seq-ref seq n)`

returns the nth item of the generic sequence seq

#### seq-tail

*[procedure]*

`(seq-tail seq n)`

returns the tail of the generic sequence seq, starting at n

#### seq-car

*[procedure]*

`(seq-car seq)`

returns the zeroth item of the generic sequence seq

#### seq-cdr

*[procedure]*

`(seq-cdr seq)`

returns the tail of the generic sequence seq, starting at 1

#### seq?

*[procedure]*

`(seq? xpr)`

checks, if xpr is a sequence

#### seq-null?

*[procedure]*

`(seq-null? seq)`

checks, if seq is empty.

#### seq-random-access?

*[procedure]*

`(seq-random-access? seq)`

checks, if seq is randomly accessible

#### seq-db

*[procedure]*

`(seq-db)`

shows the sequence database

*[procedure]*

`(seq-db type? ref: ref tail: tail maker: maker ra?: random-access?)`

adds a new custom sequence type with predicate type? and keyword arguments ref: tail: maker: ra?: naming procedures to be later accessed as seq-ref, seq-tail, seq-maker and seq-randoam-access? respectively.

### Convenience procedures

#### cons*

*[procedure]*

`(cons* arg ....)`

iterative version of cons

#### list-of

*[procedure]*

`(list-of ok? ...)`

returns a predicate which checks, if its argument is a list which passes every predicate ok? ...

#### pseudo-list-of

*[procedure]*

`(pseudo-list-of ok? ...)`

returns a predicate which checks, if its argument is a pseudo-list, which passes every predicate ok? ...

#### vector-of

*[procedure]*

`(vector-of ok? ...)`

returns a predicate which checks, if its argument is a vector which passes every predicate ok? ...

#### tagged-vector

*[procedure]*

`(tagged-vector kw arg ...)`

generates a tagged vector with keyword kw and args arg ...

#### tagged-vector?

*[procedure]*

`(tagged-vector? xpr)`

type predicate

#### tagged-vector-of

*[procedure]*

`(tagged-vector-of ok? ...)`

generates a tagged vector predicate which checks all of its arguments

#### tagged-vector-ref

*[procedure]*

`(tagged-vector-ref tv k)`

access to kth item of tagged vector tv

#### tagged-vector-tail

*[procedure]*

`(tagged-vector-tail tv k)`

returns a tagged subvector of tv starting at k

#### thunk

*[syntax]*

`(thunk xpr ....)`

generates a thunk with body xpr ....

#### thunk?

*[procedure]*

`(thunk? xpr)`

checks if xpr is a thunk, i.e. a nullary procedure

#### symbol-dispatcher

*[procedure]*

`(symbol-dispatcher alist)`

creates a documentation procedure as used in all modules of this library.

### Requirements

simple-exceptions

### Usage

(use simple-exceptions basic-sequences)

### Examples

(require-library basic-sequences simple-tests arrays) (import basic-sequences simple-tests (only arrays array array? array-ref array-tail array->list)) (seq-db array? ref: array-ref tail: array-tail maker: array ra?: #t) (definelst '(0 1 2 3 4)) (definepls '(0 1 2 3 . 4)) (definevec #(0 1 2 3 4)) (definearr (array 0 1 2 3 4)) (definestr "01234") (seq-ref lst 3) ;-> 3 (seq-ref pls 3) ; -> 3 (seq-tail pls 4) ; -> 4 (seq-ref vec 3) ; -> 3 (seq-ref arr 3) ; -> 3 (seq-ref str 3) ; -> #\3 (seq-tail lst 3) ; -> '(3 4) (seq-tail pls 3) ; -> '(3 . 4) (seq-tail vec 3) ; -> #(3 4) (array->list (seq-tail arr 3)) ; -> '(3 4) (seq-tail str 3) ; -> "34" (seq-null? (seq-tail lst 5)) ; -> #t (seq-null? (seq-tail vec 5)) ; -> #t (seq-null? (seq-tail arr 5)) ; -> #t (seq-null? (seq-tail str 5)) ; -> #t (seq-null? (seq-tail pls 4)) ; -> #t (seq? lst) ; -> #t (seq? pls) ; -> #t (seq? vec) ; -> #t (seq? str) ; -> #t (seq? arr) ; -> #t ((seq-of integer? odd?) arr) ; -> #f ((seq-of integer? odd?) #(1 3 5 7)) ; -> #t (seq-maker lst) ; -> list (seq-maker pls) ; -> cons* (seq-maker vec) ; -> vector (seq-random-access? arr) ; -> #t (seq-random-access? vec) ; -> #t (seq-random-access? lst) ; -> #f (cons* 0 1 2 3) ; -> '(0 1 2 . 3) (thunk? (thunk 1 2 3)) ; -> #t (definetv (tagged-vector x: 0 1 2 3)) (tagged-vector-ref tv 0) ; -> x: (definenull (tagged-vector x:)) (tagged-vector? null) ; -> #t (seq? null) ; -> #t (seq-null? null) ; -> #f (definetv3 (tagged-vector-tail tv 3)) (tagged-vector-ref tv3 0) ; -> x: (definetv4 (tagged-vector-tail tv 4)) (tagged-vector? tv4) ; -> #t (seq-null? tv4) ; -> #f (definetv5 (tagged-vector-tail tv 5)) (seq-null? tv5) ; -> #t (condition-case (tagged-vector-ref tv5 0) ((exn sequence) #f)) ; -> #f

## Last update

Jul 12, 2018

## Author

## License

Copyright (c) 2011-2018, Juergen Lorenz All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

## Version History

- 2.2 ; fixed the bugfix
- 2.1 ; bug in tagged-vector? fixed, thanks to Martin Schneeweis
- 2.0 ; tagged vectors added to be used with algebraic types
- 1.0
- initial import