Fork me on GitHub

is there a way to eval a piece of code and insert it in a separate window on vim? (as to keep a visual history of commands used)


@vitruvia You might check the #vim-fireplace room and see if anyone can help you there?


(also bear in mind it's late afternoon on Saturday and that tends to be a quiet time in here)


Regarding (first (filter pred? ...)): If I'm not mistaken, filter will return a chunked-seq, which will return a seq up to 32 elements when doing (first (filter pred? ...)). See:

(first (filter #(do (prn %) (some? %)) (into [] (range 1e3))))
;; prints  0 1 2 3 4 .. 31
;; returns 0
If it's important that you process as few items as possible you can use some instead of first and filter, but you'll have to wrap your pred? in #(when (pred? %) %):
(some #(do (prn %) (when (some? %) %)) (into [] (range 1e3)))
;; prints  0
;; returns 0


(this is why it's important to have side-effect-free sequence generation)


In Medley, there’s a find-first function that uses (reduce (fn [_ x] (if (pred x) (reduced x))) nil coll)


Reducing avoids the problem with chunked seqs, and is generally faster.


why implement functions with multiply arity in this fashion?

# [org.clojure/clojure "1.8.0"] clojure.core/apply

## Usages
  [f args]
  [f x args]
  [f x y args]
  [f x y z args]
  [f a b c d & args]
is it convince? Is its necessary? does it make creating the function easier? or using the function?


as opposed to [f & args]


it performs better


don't write normal code that way, but clojure.core is in everyone's "hot path" so they do make things the most performant way, even if it looks weird