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

From: John Clements (clements at brinckerhoff.org)
Date: Mon Apr 18 20:23:48 EDT 2005

On Apr 18, 2005, at 12:00 PM, Eric Hanchrow wrote:

>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> 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?

In a lazy language, you can force the result until you run out of time, 
then abandon it. That's the principle, anyhow.  I don't a lot of 
practical experience writing for lazy languages, though.

john
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2430 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20050418/e6815bb5/attachment.p7s>

Posted on the users mailing list.