This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-18
Channels
- # beginners (13)
- # boot (2)
- # cider (5)
- # cljs-dev (47)
- # cljsrn (5)
- # clojure (34)
- # clojure-berlin (2)
- # clojure-russia (33)
- # clojure-serbia (10)
- # clojure-spec (24)
- # clojurebridge (1)
- # clojurescript (21)
- # code-reviews (8)
- # core-matrix (4)
- # datomic (11)
- # hoplon (1)
- # jobs (1)
- # leiningen (4)
- # lumo (4)
- # off-topic (12)
- # om (3)
- # parinfer (4)
- # pedestal (3)
- # proton (1)
- # reagent (3)
- # ring-swagger (2)
- # rum (2)
- # untangled (9)
- # vim (6)
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
In Medley, there’s a find-first
function that uses (reduce (fn [_ x] (if (pred x) (reduced x))) nil coll)
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?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