May. 12th, 2004

Sleep

May. 12th, 2004 10:56 pm
pmb: (Default)
Presented in opposite order.


So, perhaps you were wondering if it was possible to write something like Perl::Memoize in python. The answer, of course is yes. There's lots of versions, from the simple yet appealing
def fib(n):
    if n == 0:
        return 0
    elif n== 1:
        return 1
    else:
        return fib(n-1) + fib(n-2)

def memo(f):
    answers = {}
    def g(n):
        if n not in answers:
            answers[n] = f(n)
        return answers[n]
    return g

fib = memo(fib)


To the more-complicated, to the CRAZY. You see, now that python has closures, memoization of closures becomes a possibility. So what you do is break them up, carefully poke innards which you are not supposed to know about, and put them all back together. http://soy.dyndns.org/~peter/projects/fun/random/memoize.py


It became clear around 10 pm last night that there was no way for [livejournal.com profile] goteam to get to PDX in time for her flight on public transit. So we called up [livejournal.com profile] theshytiger and asked to borrow her car. Then we arose at 4:3-, drove to PDX airport (120 miles), I dropped Tracy off, I had breakfast with a surprised [livejournal.com profile] nedthealpaca and [livejournal.com profile] chocolatesmudge, and then drove back (120 miles). Then I went out to lunch with a faculty candidate. Then I worked on the python crap, then I went to other meetings.

I have been tired beyond belief but not wanting to sleep for ~5 hours now. I have had lots of rambling conversations with people on the phone or in person. I think I will now finally go to well deserved sleep.

Profile

pmb: (Default)
pmb

October 2009

S M T W T F S
    1 23
45678910
11121314151617
18192021222324
25262728293031

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 20th, 2025 11:54 am
Powered by Dreamwidth Studios