On 29 Sep 2009, at 4:50 pm, John Cowan wrote:

> (Hmm, no map-string.  Or string-for-each.  Added from SRFI 13.
> R6RS has string-for-each but not map-string, which is particularly
> mysterious given that you can't write your own map-string without
> importing the mutable-strings library, which is not loaded by
> default.)


That reminds me of a point which, while thinking while walking along,
I wished I'd raised in response to Fare's post about abstraction
noting that we don't have a good sequence abstraction to apply to
strings/lists/vectors/ports/streams: I remember thinking that we do,
we just don't use it very often - fold.

I had always rather turned my nose up at fold, thinking it a HOF that
I'd rarely have cause to use, and would never remember the argument
order for when I did want to use it. But then I was looking at a GDBM
interface library for Chicken by Alex Shinn, and it handled GDBM's
ability to iterate over the entire database by providing a gdbm-fold
procedure.

I was then struck by an insight that all the talk I'd heard of fold
being able to implement map, car, cdr, and so on on top of fold wasn't
just a pointless observation; if you partially apply a sequence-
specific fold procedure to an instance of that sequence, you get a
closure that inherently expresses the ordered-list nature of that
sequence.

Which led me to wonder if we should have string-fold, list-fold,
vector-fold, and so on; then provide HOFs that accept a "folder" and
do all the generic sequence operations in terms of that.

ABS

--
Alaric Snell-Pym
Work: http://www.snell-systems.co.uk/
Play: http://www.snell-pym.org.uk/alaric/
Blog: http://www.snell-pym.org.uk/archives/author/alaric/




_______________________________________________
r6rs-discuss mailing list
[email protected]
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss

Reply via email to