Path to Y – Shallow Composition

Last time we saw how to pass "build" functions (i.e. return a function from a function that depends on the arguments passed to the outer function) in C++, even though C++ functions don’t really "do that." The trick is to wrap the return function in a class that can set private member variables which are…

Path to Y – Functors

In yesterday’s post we showed that the first part of Y – passing a function to another function – is not only possible but fairly easy in C++. What about returning one? As you might expect, that’s just as easy, though the signature can get a little awkward if you don’t use typedefs. Let’s start…

Path to Y – Function Pointers

Most of the stuff you read on the internet about the Y combinator works in functional languages. This only makes sense: the Y combinator comes from the Lambda Calculus, and functional languages allow you to implement Lambda Calculus concepts more or less directly in that functions are first-class values in those languages. What that means…

Variables Aren’t

Functional programming – what is it? Wikipedia’s got the goods: In computer science, functional programming is a programming paradigm – a style of building the structure and elements of computer programs – that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data. "Avoids mutable data." That’s the one that always…

Duped by the Birthday Paradox

A well-known counterintuitive fact about probability is the birthday problem – the idea that the odds of two people in a group sharing a birthday increases much more rapidly with the size of the group than most people expect. Most people’s intuition seems to be roughly linear: odds increase more or less uniformly with each…

Cleaner in Coffeescript: Random Password Generator

Today I solved one of those problems that’s been solved a billion times, but you never seem to have the solution handy when you need it. I needed a password generator for work – anyone who makes a call to the API to create a user but doesn’t supply a password should have one created…

Keeping Simple Simple

The one thing I have deja vu all over again about again and again and again and again in software development is being confronted with a thing that seems intimidatingly complex and deep only to find out that it’s actually dead simple. I’m rapidly becoming convinced that no profession, save possibly high finance, is more…

Getting THIS Right in Coffeescript in the DOM

Once upon a time, I was in love with AngularJS. Sure, there was a (very) steep learning curve, and it was a little clunky, and its rationale for dividing things up the way it did wasn’t always optimally clear, and how it actually all worked was even less clear and … well, iterations of that…