« Final Scala to Java comparisonCorporate Spreadsheets Still Suck »

Miscellaneous Links

01/11/07

Permalink 09:31:32 pm, 298 words
Categories: Background, Code

Miscellaneous Links

Remember when I said "good riddance to bad rubbish?". Here's why: Java programmers round up to the nearest power of 2. This is worst case, not typical case, but that doesn't make it less funny.

Now that I've been thinking about games on the Mac, I went back and watched the old Switcher commercial on Youtube. And the games he names are almost exactly the games I've been playing! Zork...Zork 2...Zork 3...Starcraft...(photoshop?). Well, except Photoshop. I heard it's not that great.

Aziz now has his Scheme compiler online. He calls it Ikarus Scheme and it is 80% R6RS compliant. Unlike Chez, it's GPLed and free. This means, if you don't mind x86-only compilation, you get an industrial-strength Scheme compiler that's not (1) lame (eg PLT) or (2) beholden to C (Chicken, I think?). Plus it is pro-R6RS, which doesn't mean much except that probably the SRFIs don't work on it. This is the sort of thing that two years ago I might have thought would increase use of Scheme but now I don't. Have fun anyway.

I finally wrote a real currying function instead of a partial application. It was surprisingly hard—the code came out recursive even though I didn't want it to, since I was writing in Python.

import inspect
def curried(f):
    def curhelp(n, args):
        if n==0:
            return f(*args)
        else:
            return lambda arg: curhelp(n-1, args+[arg])
    return curhelp(len(inspect.getargspec(f)[0]), [])
## use ##
@curried
def add(a,b):
    return a + b
map(add(10), range(3)) # == [10,11,12]

If you can find a way to make in non-recursive or to get rid of the annoying args+[arg] (which is inefficient in Python), let me know. The crack coders of RefactorMyCode have already had a chance to look at it. We'll see how they do.

1 comment

Comment from: Andrew [Visitor] · http://www.andrewreiter.com
Wow, you almost made it through a post without putting code into it... darn.
02/11/07 @ 11:50

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)
powered by b2evolution