chickadee » traversal

This page is maintained in the package's github repository.

Traversal

This is a Chicken Scheme egg which contains various list and vector traversal functions. Many of the functions provided by this egg originate from Jeff Siskind's QobiScheme.

overall

The final character of many of these functions denotes the compairson function being used. 'q' compares with 'eq?', 'v' compares with 'eqv?', 'e' with 'equal?', 'p' and the lack of a final character denotes that the function takes a user-provided predicate.

The following documentation uses the following notation: 'l' list, 'n' number, 'v' vector, 'p' procedure (usually a predicate).

Some of the functionality of this egg is provided by other eggs, like srfi-1, with different naming conventions.

lists

countq x lprocedure
countv x lprocedure
counte x lprocedure
countp p x lprocedure
count-if p lprocedure
count-if-not p lprocedure
findq x lprocedure
findv x lprocedure
finde x lprocedure
findp p x lprocedure
find-if p lprocedure
find-if-not p lprocedure
positionq x lprocedure
positionv x lprocedure
positione x lprocedure
position p lprocedure
positionp p x lprocedure
position-if p lprocedure
position-if-not p lprocedure
vector-positione val vectorprocedure
remove-if p lprocedure
remove-if-not p lprocedure
removee x lprocedure
removep p x lprocedure
removeq x lprocedure
removev x lprocedure
remove-duplicatesq lprocedure
remove-duplicatesv lprocedure
remove-duplicates p lprocedure
remove-duplicatese x lprocedure
list-set! l i xprocedure
list-insert l i xprocedure
list-remove l iprocedure
list-replace l i xprocedure
equivalence-classesq xprocedure
equivalence-classesv xprocedure
equivalence-classes p xprocedure
equivalence-classese xprocedure
transitive-equivalence-classes p xprocedure
adjoinq x lprocedure
adjoinv x lprocedure
adjoin x lprocedure
adjoinp p x lprocedure
rest lprocedure
but-last lprocedure
sublist list start endprocedure
every-other listprocedure
take-until p lprocedure
drop-until p lprocedure

Misc list manipulation stuff.

group-by key lprocedure

Find equivalence classes of the elements of l that are equal? given output of key.

sort list predicate keyprocedure

Merge sort.

lexicographically<? <? =?procedure
minimal-membersp <? =? lprocedure
unzip lprocedure

Transposes lists.

creation

enumerate nprocedure
enumerate-vector nprocedure

Produce a list or a vector containing 0 through n-1.

assertions

some p lprocedure
some-n p nprocedure
some-vector p vprocedure
every-n p nprocedure
every-vector p vprocedure
one p l #!rest &restprocedure
one-n p nprocedure
one-vector p v #!rest &restprocedure
pairwise? p lprocedure

Does p hold on each adjacent pair of elements in l.

traversal

for-each-n f nprocedure
for-each-n-decreasing f nprocedure
map-n f nprocedure
map-n-vector f nprocedure
for-each-from-a-up-to-b f a bprocedure
for-each-m-n f m nprocedure
for-each-m-n-indexed f m nprocedure
for-each-m-n-dec f m nprocedure
map-m-n f m nprocedure
map-m-n-indexed f m nprocedure
for-each-vector f v #!rest &restprocedure
map-vector f v #!rest &restprocedure

Like 'vector-map' but take an arbitrary number of vectors.

map-linear f start end nprocedure

Map linearly between 'start' and 'end' in 'n' steps.

reduce-n f i nprocedure
reduce-vector f i vprocedure
map-reduce g i f l #!rest lsprocedure
map-reduce-n g i f nprocedure
map-reduce-vector g i f v #!rest vsprocedure
map-reduce2 g i f lprocedure
map-reduce3 g i f l1 l2procedure

Reduces are left folds.

for-each-indexed f lprocedure
map-indexed f lprocedure
for-each-indexed-vector f vprocedure
map-indexed-vector f v #!rest &restprocedure

Passes 'f' both the element and an offset into the list/vector.

map-medial f l keyprocedure

'f' is passed each adjacent pair of elements in l after being sorted by the key. Key must return a number given each element of l.

all-pairs lprocedure
map-all-pairs f lprocedure

'f' is passed each adjacent pair of elements in l.

memp p x lprocedure
assp p x alistprocedure

Like memq and assq but take a predicate for comparison.

map-accum f i lprocedure

f will be passed the accumulator and each element of the list.

sets

set-unionq x yprocedure
set-unionv x yprocedure
set-union p x yprocedure
set-unione x yprocedure
set-unionvt x yprocedure
set-differenceq x yprocedure
set-differencev x yprocedure
set-difference p x yprocedure
set-differencee x yprocedure
set-differencevt x yprocedure
set-intersectionq x yprocedure
set-intersectionv x yprocedure
set-intersection p x yprocedure
set-intersectione x yprocedure
set-intersectionvt x yprocedure
set-equalq? x yprocedure
set-equalv? x yprocedure
set-equale? x yprocedure
set-equal? p x yprocedure
subsetq? x yprocedure
subsetv? x yprocedure
subsete? x yprocedure
subset? p x yprocedure
subsetvt? x yprocedure

rings

ring-backward lprocedure
ring-forward lprocedure
ring-forward-between r a bprocedure
ring-forward-to l oprocedure

These manipulate a list while treating it as a ring.

minimizing and maximizing

maximump lprocedure
minimump lprocedure
maximum p lprocedure
minimum p lprocedure
maximum-with-position lprocedure
minimum-with-position lprocedure

p is a function that returns a number.

math

sum lprocedure
sum p nprocedure
sum p lprocedure
product lprocedure
product p nprocedure
product p lprocedure
factorial nprocedure
choose n mprocedure

QobiScheme compatibility

qfind x lprocedure
qcount x lprocedure
qposition x lprocedure
qremove x lprocedure
qremove-duplicates lprocedure
qtopological-sort p lprocedure
qset-difference x yprocedure
qset-intersection x yprocedure
qset-union x yprocedure
qset-equal? x yprocedure
qreduce f l iprocedure
qreduce-vector f v iprocedure
qreduce-n f n iprocedure
qmap-reduce g i f l #!rest lsprocedure
qmap-reduce-n g i f nprocedure
qmap-reduce-vector g i f v #!rest vsprocedure
qequivalence-classes xprocedure
qtransitive-equivalence-classesp p xprocedure
qmaximum lprocedure
qminimum lprocedure
qmaximump l pprocedure
qminimump l pprocedure

License

  Copyright 1993-1995 University of Toronto. All rights reserved.
  Copyright 1996 Technion. All rights reserved.
  Copyright 1996 and 1997 University of Vermont. All rights reserved.
  Copyright 1997-2001 NEC Research Institute, Inc. All rights reserved.
  Copyright 2002-2013 Purdue University. All rights reserved.
  Contact Andrei Barbu at andrei@0xab.com.
  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU Lesser General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU Lesser General Public License for more details.
  You should have received a copy of the GNU Lesser General Public License
  along with this program.  If not, see http://www.gnu.org/licenses.

Contents »