This is the mail archive of the
mailing list for the Guile project.
Re: Constructs for programming with sequences
- To: Mikael Djurfeldt <email@example.com>
- Subject: Re: Constructs for programming with sequences
- From: Lars Arvestad <firstname.lastname@example.org>
- Date: 01 Jun 1999 08:12:48 +0200
- Cc: email@example.com
- References: <199905311843.UAA26099@mdj.nada.kth.se>
I think the suggested list library by Olin Shivers is a very good
starting point. (See http://srfi.schemers.org/srfi-1/srfi-1.html for
details and sample implementation.) The library has everything you
suggest and more for lists. It shouldn't be that hard to implement it
for vectors too.
MD> 1. Generation
MD> (map-index N PROC) --> LIST
MD> (vector-map-index N PROC) --> VECTOR
Shivers has suggested list-tabulate to work like map-index.
MD> 3. Combination
MD> (foldl PROC INIT LIST) --> COMBINED
MD> (foldr PROC INIT LIST) --> COMBINED
These two are also implemented by Shivers with the feature that they
work on as many lists as you need, similar to map and for-each.
There is a lot more good stuff in that libary! I have used some bits
and pieces myself (such as the fold procedures) without major
problems. There seems to be only one obstacle before turning the
sample implementation into a module, and that is that several of the
procedures are implemented with receive-values pairs. I rewrote one
function to use call-with-values instead, but surely there is a way of
implementing receive-values with macros? Would a power schemer care to
enlight a simple amateur?
Lars Arvestad Dept. of Numerical Analysis and Computing Science
Royal Institute of Technology (KTH), Stockholm, Sweden