Rest Parameters Curry

According to Wikipedia, Currying is the technique of translating the evaluation of a function that takes multiple arguments into evaluating a sequence of functions, each with a single argument. Simply, if a function takes three arguments and is curried, it is really three functions. Each function takes one argument and return a new function that takes the next argument until all arguments are received, then it returns the final result.

Consider a function that takes three arguments:


The equivalent curried function:


This is somewhat insane! returning nested functions as function takes more and more arguments. One option is to convert a normal function into a curried function, which is what mainly this article focuses here onward.

When converting a normal function into a curried function, it is required to know how many arguments the function is expecting. Functions have a length property in JavaScript and it can be used in here. Although the main intention here is to demonstrate how ES6 Rest Parameters can be used when creating generic curry function.

In concise, a Rest Parameter allows a function to receive a variable number of arguments and more details on this can be found in MDN: Rest Parameters.


The first time this function is called it only expects one argument, a function to  curry. The args parameter will probably be an empty array on first invocation. Save the number of arguments it expects (argLength) to a local variable. Then return a function we define inside the curry function. When this function is invoked it concatenate the new args2 array with the old args array and check if it has received all the arguments yet. If so, it apply the original function and return the result. If  not it recursively call the curry function, passing along all the new arguments which puts us back in the original position, returning the curried function to await more arguments.

With concepts like currying, it is much easier to abstract the logic and make clear and concise functions.


  1. Currying on Wikipedia
  2. Rest parameters on MDN

Rock on!

On 280 Characters

Twitter recently announced that it has increased the 140 character limit to 280 for some users. This news left Tweeps in mixed thoughts, at least the community I’m interacting. Indeed, this has launched as a test but it is more sensible to assume that this will be the future considering problems Twitter deals with the growth as a platform.

What is the role of Twitter in the crowded street of social media? Fundamentally Twitter allows every voice flow in the platform in real time, which represents working, living, and breathing view of the community at personal level. Like Chamath Palihapitiya highlighted once, culture is constantly evolving and this is what Twitter should stand for, fight for and thrive for, fancy stories or augmented animations are not part of the core equation in Twitters case.

“fight for the culture the way it should be…not the way it was or the way its becoming”

140 character limit has two rationales, one is practical and the other one is conceptual. Initially Twitter was mainly used via SMS and website acted as an archive.  SMS/Text was the most convenient way of communicating more simple message instantly back then. SMS has 160 character limit and leaving 20 characters out for username gives 140 characters to express what’s going on in real time. On the other hand, constrains inspires creativity. People tend to live in the moment, be more human and live with 140 characters.

Once Twitter decided to increase character length to 10000, which is similar to its direct messaging product. Fortunately, Jack, the CEO if Twitter scrapped the project and everyone should be grateful for this decision which saved the fundamental ideology of Twitter. However, as a platform it should attract new users, which Twitter is hardly good at. Doubling character length  may open the door for new users to actively engage in the platform and been more expressive while core principles remain the same.

Finally, praise the core principles not how it is represented.

Rock on!