Learning to walk with Clojure

Introduction This is a blogpost on how to use clojure.walk. clojure.walk is incredibly powerful and definitely worth investing time into. We’ll first look at some simple examples to get a feel for the functions and then I’ll demonstrate its power by walking through a problem and showing two solutions, one without clojure.walk and one with. I know the title says ’learning to walk’, but by the end of the post you will know how to fly. That is how powerful clojure.walk is. ...

October 9, 2022 · 23 min · Abhinav Omprakash

The problem with python's map and filter...

… and how we might fix it. This is NOT a hate post. Let me say that again, This is NOT a hate post! Python is a fine language and it was my first programming language. Like the initial stages of falling in love with someone, you can’t see the flaws, the same was with python :) But as time goes by and the initial limerance fades, you start seeing the flaws. Nobody is free of flaws, and neither are programming languages (not even lisp). ...

November 27, 2021 · 10 min · Abhinav Omprakash

Recursion is recursion is recursion is...

Defining recursion in terms of itself is an old joke among programmers. Despite the fact that it frustrates a lot of new-comers, we don’t change it. I like to define recursion as “Iteration for the cool kids”. I don’t mean this in a snobbish, let-us-exclude-the-for-loopers kinda way, but rather in a tone of appreciation. Recursion is an elegant way of doing things. Recursive alogrithms are concise, have less noise and have immutability baked in (always a plus). ...

October 27, 2021 · 9 min · Abhinav Omprakash

Clojure Tutorial for Beginners 1

Welcome, young lisper. I see you have heard the summons from the mystical forces. Prepare yourself for a journey like no other. Your view of programming shall change, and change for the better. You must shed your past beliefs and practices. This is a new path, one that bears little resemblance to the paths you have trodden before. And that is a good thing. Initiation rites You have two options - either use an online one-click setup or bite the bullet and install clojure and other tools on your local machine. I recommend the latter option, since you will have to do it at some point. But I am not without sympathy. Setup can be a pain and can be discouraging. Follow the instructions on calva online for a zero-install approach to getting started with clojure. ...

August 30, 2021 · 8 min · Abhinav Omprakash

Fold is gold: understanding reduce

Introduction reduce or foldleft is a very powerful function, but it can be quite tricky to understand and use. In fact, I used to think that reduce was an obscure function, that reduced (hehe) the readability of a program. If you ever want to make it as a functional programmer, understanding reduce is as important as important as knowing how to reverse linked list. I’m joking, knowing how to reverse a linked list is not that important, and it can be done with reduce! ...

July 11, 2021 · 10 min · Abhinav Omprakash

Understanding partial functions

Welcome to the land of contrived examples and imperfect metaphors. Today we will be visiting a store called the five-item store. You’re only allowed to buy five items, no more, no less. The moment we enter the store, a cashier sees us and begins tailing us, and he keeps repeating “give me your items for so that I can make a bill” over and over again, so we just pick up an item and give it to him, and he shrieks and says “give me all five at the same time or none at all.” At this point you’re probably very annoyed, and this is when, a man in a suit introduces himself, says he is a personal shopper and he will deal with the cashier on your behalf, of course it will cost you a little bit (that’s how corporations suck money, kids!). But since you’re so annoyed, you say “okay, fine! I’ll pay the fee”. The personal shopper is jovial, quiet, and helps you to find the items you need to. You pick two boxes of cookies and hand it over to the personal shopper, then you pick three boxes of coffee (a programmer has needs!) and hand it over. Now that you have five items the personal shopper takes all your items and goes the cashier and gets you the bill. You pay and you leave. ...

June 7, 2021 · 8 min · Abhinav Omprakash