[plt-scheme] Cleaner, more general way to collect partial results from a long-running computation?

From: Eric Hanchrow (offby1 at blarg.net)
Date: Mon Apr 18 12:00:30 EDT 2005

At http://paste.lisp.org/display/7527 you can see rather ugly hacky
code that I wrote to compute _some_ of the permutations of a list of
integers.  The idea is that computing all of them would take too long,
so we want to simply compute for two seconds, and collect the results
that have accumulated by then.

The code that I've written works, but I suspect there's a far cleaner
and more general way to do this sort of thing.  For example, the code
that I've written is a replacement for the "map" function, but what if
I need similar interruptibility from, say, the "for-each" function?
I'll have to implement that, too.  This seems wasteful.  And I can't
believe I'm the first person in history to want partial results from a
computation.

So: can anyone suggest a cleaner and more general way to do this?

Thanks.

-- 
To me, an extra 0.1% performance increase, even if I am only
imagining it to be faster, is certainly worth one day a week
recompiling all of the latest packages from source code.
        -- some Gentoo user, quoted on http://funroll-loops.org



Posted on the users mailing list.