functools.partial

functools.partial is one of those things that you don't need until you need it, and then you need it badly. Trying to create a series of lambda functions I discovered that the simplest answer that came to my mind did something counter intuitive, and functools.partial - which I had ignored so far, came to my rescue. …

Advertisements

Quick thoughts on starting Functional Programming (in Racket)

Having been "functionally curious" for a while now, I've started with Racket, a language in the scheme family which is a type of Lisp. Yes. Racket rhymes with bracket. My first foray into functional programming was with Haskell. When I started with Learn You a Haskell for Great Good I was initially excited, but then …

(time (apply max a))

A while ago I started up with Haskell in an effort to figure out what this functional programming was all about. One of the simple tests I did was try to find the maximum of a list of numbers and time it. This led me down an interesting rabbit hole, documented here. I've now started …

maximum [1..1e6]

I had heard about Haskell - the coolest language on the block - from several friends. After reading the chapter on typeclasses from Learn You A Haskell for Great Good my mind was blown away and I wanted to get cracking and learn this cool functional programming thing. I'm a practical guy. As I followed the …

I yield to Python

I've been using Python for a few years now and I am amazed that I got by all these years without using yield. I think this is a result of my coming from a C/Matlab background and self-teaching myself Python. Now of course I have the zeal of a recent convert. The way I came …