[Edu-sig] More Pythonic Precalculus (Python 2.0)

Dustin Mitchell dustin@cs.uchicago.edu
Mon, 25 Sep 2000 13:15:33 -0500 (CDT)


Kirby --

How about

>>> f = lambda x : 2 * x * x - 10 * x + 2
>>> graph(f)

where:

def graph(fn):
  for x in range(-10, 10):
    print x, fn(x)

or the like.

*much* cleaner; this is *precisely* what lambda is meant for.

Dustin

---------------------------------------------------------------------
|                         Dustin Mitchell                )O(        |
---------------------------------------------------------------------