Is it possible to use/implement tacit programming (also known as point-free programming) in Lisp? And in case the answer is yes, has it been done?
Is it possible to use/implement tacit programming (also known as point-free programming) in Lisp?
Share
This style of programming is possible in CL in principle, but, being a Lisp-2, one has to add several
#'s andfuncalls. Also, in contrast to Haskell for example, functions are not curried in CL, and there is no implicit partial application. In general, I think that such a style would not be very idiomatic CL.For example, you could define partial application and composition like this:
(Those are just quick examples I whipped up – they are not really tested or well thought-through for different use-cases.)
With those, something like
map ((*2) . (+1)) xsin Haskell becomes:The
sumexample:(In this example, you could also set the function cell of a symbol instead of storing the function in the value cell, in order to get around the funcall.)
In Emacs Lisp, by the way, partial application is built-in as
apply-partially.In Qi/Shen, functions are curried, and implicit partial application (when functions are called with one argument) is supported:
There is also syntactic threading sugar in Clojure that gives a similar feeling of “pipelining”: