[plt-scheme] foldl, map, filter with sequences?

From: Marek Kubica (marek at xivilization.net)
Date: Tue Dec 9 14:46:13 EST 2008

On Tue, 09 Dec 2008 17:32:26 +0100
Jens Axel Soegaard <jensaxel at soegaard.net> wrote:

> Marek Kubica wrote:
> > I have a rather large list which would be handled best if I wouldn't
> > need to create it as one big thing but rather compute on need (it is
> > the output of string-tokenize applied on a 350 MB file). As I am
> > using foldl in my program, I don't need all items at once. Is there
> > a way to feed a sequence into foldl? Or maybe there a
> > sequence-foldl? 
> 
> Maybe you it is time to try comprehensions?
> 
> http://docs.plt-scheme.org/guide/for.html

I already know comprehensions from Python and while they are a very
useful tool I found it fascinating that I was able to solve a task
completely by using immutable data structures and foldl. Maybe I'll
write a version using comprehensions later, to check the performance of
that, but first I'll try streams. Thanks for the suggestion!

Considering sequences I have a small suggestion: please put a note that
to access the data of a sequence, one has to use comprehensions. I
wasn't able to find out what to do with the mysterious #<sequence> so I
needed to ask in IRC where I was told that comprehensions are the way
to go.

regards,
Marek


Posted on the users mailing list.