[plt-scheme] PLT v 4.0 discussion - sequences

From: Mark Engelberg (mark.engelberg at gmail.com)
Date: Wed Jun 4 21:22:34 EDT 2008

Sequences play an important role in v 4.0, especially in
comprehensions.  The current mechanism for creating new sequences
seems rather clunky (make-do-sequence of a thunk producing values of
six sequencing functions, two of which are usually irrelevant, and you
better get them all in the right order).

Creating new sequences should be easy.

It seems like at a minimum, you'd want to use comprehension syntax to
be able to express map and filter over existing sequences.
For example, the sequence of all square numbers could be:
(for/sequence ([i (in-naturals)]) (* i i))

(BTW, it seems a pity that in-naturals doesn't support an optional
step parameter).

What other easy ways could there be to express and create sequences?
Python uses "yield" to concisely express many generators, which are
essentially the same as PLT Scheme's sequences, but I don't know
whether yield is a good fit for the Scheme way of doing things.  Any
other ideas?

--Mark


Posted on the users mailing list.