[Tutor] Text processing and functional programming?
Clay Shirky
clay at shirky.com
Thu Aug 14 12:32:57 EDT 2003
> And further on think about closures. They allow nice constructs (people
> who know Common Lisp or Scheme use them all the time).
>
> In [2]: def make_counter(start=0, step=1):
> ....: def cfun(step=step, counter=[start]):
> ....: counter[0] += step
> ....: return counter[0]
> ....: return cfun
Isn't this what yield does? Are there kinds of closures that can't be
implemented with iterators? Or are iterators another way of creating
closures?
-clay
More information about the Tutor
mailing list