Bidding farewell to currying

I love this code. It enables me to pass any function and then a set of coordinates. So if I want game pieces to move, for example, using a sin pattern, I can establish a partially applied version of the function that’s specific to sin — or any other pattern I want to use: wiggles, sawtooths, etc.

Once established, I can then once again apply for each game move from the piece’s starting position to ending position. The returned function is now ready to be traversed to create a SpriteKit-ready Bezier path for moving.

With Swift 3.0, currying is saying goodbye and with it, the simple elegance of partial application.

I’m off to refactor this code. Wish me well. Suggestions welcome.

Update: Here’s what I’ve got. Thanks to Mike Ash for simplifying the “return { stuff in” patterns. Of course, the worst thing about all this after worrying about this for days, the result isn’t horrible and it’s highly likely that I’ve made a fuss about nothing big.

3 Comments