Skip to content

cljr promote function

Lars Andersen expez@expez.com edited this page Jun 9, 2015 · 1 revision

pf Promote function

Promote function literal to anonymous function

Given this:

(map #(-> % (str "!") symbol) '[aww yeah])

And I place my cursor on symbol and do cljr-promote-function and rename % to sym:

 (map (fn [sym] (-> sym (str "!") symbol)) '[aww yeah])

With a prefix it will promote the function literal all the way to a defn.

Promote anonymous function to defn

Given this:

 (map (fn [sym] (-> sym (str "!") symbol)) '[aww yeah])

And I place my cursor on symbol and do cljr-promote-function and call the fn shout-it!

(defn shout-it!
  [sym]
  (-> sym (str "!") symbol))

(map shout-it! '[aww yeah])

Clone this wiki locally