dash.el icon indicating copy to clipboard operation
dash.el copied to clipboard

Opposite of -applify?

Open sindikat opened this issue 10 years ago • 2 comments

-applify takes a variadic function and turns it into a function on a list. Can we have a function that takes a function on a list of similar values and turns it into a variadic function?

(defun -unapplify (fn)
  (lambda (&rest args)
    (funcall fn args))) ; requires lexical binding

(funcall (-unapplify (-partial '-reduce '-intersection)) '(1 2 3 4) '(2 3 4 5) '(3 4 5 6)) ; => (3 4)

Do we need such a function? And what should be its name? The question arised, when answered this question on SO.

sindikat avatar Aug 18 '15 12:08 sindikat

It could go to dash functional as dash.el still does not support lexical binding. It might even be there already with different name, I'm not sure.

Fuco1 avatar Aug 18 '15 12:08 Fuco1

This is usually called curry, and -applify is usually called uncurry. I don't know what they are called in Clojure, but we should probably use their naming.

Fuco1 avatar May 01 '16 10:05 Fuco1