> I imagine some input, that is too big and should be handled one element
> at a time instead. How would one do that in Racket, when not using
> something comparable to a Python generator?


It depends on the situation specifically the interface that’s force on your
components (if any) and how you use this large piece of data. 

The simplest and cleanest solution is laziness. Here is a standard example 
from my teaching. Say your program demands a large decision tree (imagine
a strategy-based game tree). A ‘planner’ tends to visit select portions of such
a tree up to a certain depth. You can use 

 — standard lambda encodings of lazy branches 
        use this if you never need to recompute values 

 — import the lazy constructs from #lang Lazy 
        these cache the results of computations making it somewhat cheaper to 
recompute 

This solution is simple and elegant because the overall program remains a 
functional 
program and the simple algebraic laws of reasoning apply if you need to work 
something
out in your head. 

Stephen Chang’s dissertation shows how to discover where to insert lazy 
constructors
and strict accessors for lazy data constructions to speed up programs. It’s a 
prototype 
and someone should turn it into a full-fledge tool. 

Above and beyond this simple solution, you may wish to use 

  — generators (replaces laziness with almost the same simplicity, but they do 
use imperative control) 
  — coroutines (explicit hand-over of control, co-operative threads) 
  — threads (as in time-preempted) 
  — places (OS level parallelism) with channels of communication 
  — distributed places (like places, across different cpus possibly on 
networks) 

It’s too much detail to spell out here when/why each situation calls for what. 
But it pays 
off to implement the same problem and variants of the same problem with various 
linguistic 
means and to think about the consequences. (This is how HtDP came about.) 

— Matthias

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to