view or post comments

Python Curry

24 July 2008

See the wikipedia article on Currying for an explanation of the basic concept.

# An attempt at implementing currying in Python.

import inspect

class Curry(object):
    def __init__(self, f):
        args, varargs, varkw, defaults = inspect.getargspec(f)

        self._f = f
        self._n = len(args)
        self._arg_values = []

    def __call__(self, *args):
        self._arg_values.extend(args)
        if len(self._arg_values) >= self._n:
            return self._f(*self._arg_values)
        else:
            return self

def f(x,y):
    return x + y
cf = Curry(f)
print cf(5)(6)

def g(x,y,z,w):
    return (x - y) + (z - w)
cg = Curry(g)
print cg(6)(5)(4)(3)

view or post comments

Voice Control

19 May 2008

Linux.com has a funky article on setting up simple voice recognition on Linux [1]. Now to get something like this going for the lounge computer.

view or post comments

Queen at the Ballet

3 October 2007

We went to see Queen at the Ballet currently showing at the Artscape, tickets provided courtesy of Joanna, who is playing the piano (Thank you!). It was a fun night out, but the show is not without its faults -- primarily the lack of a plan for dealing with the male singers not having Freddie's range. Other problems included the weird accent of one of the lead male singers, a diva who seemed not to know the words to Barcelona and really lacklustre costuming in parts.

On the whole the orchestra were pretty cool, as were the ballet and costumes in the second half and the show was not without its highlights (I enjoyed Another One Bites the Dust, Radio Ga Ga and Innuendo).

There was a pyrotechnic at the end.

view or post comments

Visas Suck

16 July 2007

Things I could have bought instead of a Polish visa:

  • A box of VtES boosters.
  • A plane trip to somewhere in South Africa.
  • A second Linksys wireless router.

And a Schengen visa will be even more expensive. :/

view or post comments

Lightening Blogging

15 January 2007

  • Friday: Birthday drinks at Stones for Beth's 21st. Happy birthday Beth! Proper celebrations in February.
  • Saturday: Purchasing of bookcases and a chest of drawers. Delivery in a few weeks. Tour of Access Park. Brunch at Nino's. Linux Magazine with Knopix 5.0 DVD. Fruit and Veg crowded but also filled with cheap pasta. L5R, yes we're roleplaying on a Saturday afternoon for the next month or so. Green Fairy Party. Katherine will soon be our neighbour. Cocktails. Lots of sleep.
  • Sunday: Milk run. Lots of poker chips in a cool case with dice and cards. Hooray! Super and Space Munchkin with Kevin and Neil. Ice-cream. Frisbee. Campaign summaries and classifieds for CLAWmarks.

Index ---- (:commentboxchrono:)

Page last modified on October 08, 2007, at 02:28 PM