[plt-scheme] On continuations...

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sun Dec 19 21:43:28 EST 2004

On Dec 19, 2004, at 9:23 PM, Alexander Schmolck wrote:

>     def lazyPartitions(n):
>         if n == 0:
>              return []
>         else:
>              return ([head] + tail for head in range(1, n+1)
>                                    for tail in partitions(n-head)
>                                    if not tail or tail[0] <= head)

I can't get these to run in my Python:

[:~/Unison/Accounts] matthias% python
Python 2.3 (#1, Sep 13 2003, 00:49:11)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

Do I need a newer build?

;; ---

I actually enjoy Python and have abused it myself for functional 
programming. If its libraries were written properly, you could write 
really neat code in this language.

As for convincing yourself of the correctness and equivalence of the 
imperative version, I doubt you have ever done a formal argument about 
this stuff. Sorry it's not trivial. If you can show me one, I will sit 
corrected of course.

As for the laziness argument, I have been around for too long to buy 
this now. Please take a look at FPCA 1995; the article on how few 
programs need laziness should be of interest to you.

-- Matthias

Posted on the users mailing list.