This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-07-26
Channels
- # aleph (1)
- # beginners (96)
- # boot (5)
- # cider (44)
- # cljdoc (11)
- # clojure (73)
- # clojure-conj (4)
- # clojure-dev (1)
- # clojure-finland (2)
- # clojure-italy (7)
- # clojure-new-zealand (1)
- # clojure-nl (3)
- # clojure-spec (4)
- # clojure-uk (66)
- # clojurescript (114)
- # code-reviews (16)
- # cursive (15)
- # datomic (37)
- # emacs (6)
- # events (2)
- # figwheel-main (12)
- # fulcro (36)
- # graphql (19)
- # hoplon (2)
- # hyperfiddle (3)
- # jobs (2)
- # leiningen (4)
- # off-topic (36)
- # om (1)
- # om-next (2)
- # other-languages (1)
- # re-frame (12)
- # reagent (12)
- # reitit (5)
- # remote-jobs (4)
- # ring (2)
- # shadow-cljs (218)
- # spacemacs (8)
- # specter (7)
- # sql (34)
- # tools-deps (9)
- # uncomplicate (6)
why does this result in false? (reduce 'or '(false false true false false))
@vigilancetech because you are using Symbol
as a function (in this case it's 'or
)
@vigilancetech and it behaves like a keyword
. It roughly translates to (:some-keyword {} "default value if not found")
so how do I do it?
(reduce 'or '(false false true false false))
;; similar to
(reduce #('or %1 %2) '(false false true false false))
;; Notice that the `Symbol` behave like a keyword:
('or {'or 2} 3) => 2
('or {'foobar 2} 3) => 3
;; So step by step:
('or false false) => false ;; feed this to the next iteration
('or false true) => true
('or true false) => false
('or false false) => false
ah, ok thanks! I'll try it
Hello all, is there a way to generate the predicate for filter
(filter
#(or
(clojure.string/includes? (clojure.string/upper-case (:codigo %)) (clojure.string/upper-case filtro))
(clojure.string/includes? (clojure.string/upper-case (:nome %)) (clojure.string/upper-case filtro))) dados)
dynamicaly?why oh why are Clojure REPLs not Clojure data structures themselves ? I want to be able to 'branch' a REPL session and explore a tangent without affecting where I was before, and I want to be able to persist and restore sessions
https://clojure.org/guides/repl/enhancing_your_repl_workflow - don’t type into a repl, connect your editor to your repl, and use files, @octo221.
What is the current status of om-next?
I think most new projects use #fulcro @pvillegas12
Why is that @nha?
@pvillegas12 they forked om.next, and have done a great job documenting and improving it.
@fenoloftaleina I mean REPL-as-immutable-data-structure; files and namespaces are mutable
@funyako.funyao156 I could not follow your idea, can you give me an example?
@fabrao I think if you have a pretty similar predicate like this (clojure.string/includes? (clojure.string/upper-case (:codigo %)) (clojure.string/upper-case filtro))
(taken from your example)
if I have [:codigo :nome]
I want to generate #(or (clojure.string/includes? (clojure.string/upper-case (:codigo %)) (clojure.string/upper-case filtro))) (clojure.string/includes? (clojure.string/upper-case (:nome %)) (clojure.string/upper-case filtro)))
You could just create something like:
(defn my-pred
[filtro k v]
(clojure.string/includes? (clojure.string/upper-case (k %)) (clojure.string/uppercase filtro)))
;; use it like
(filter #(or (my-pred filtro :codigo %) (my-pred filtro :my-key %) ) dados)
Then I think you could create a function that check whether the map has the key you're looking for
@fabrao If the key is generated based on the map, it'll become shorter: (filter #(my-new-pred filtro %) dados)
Hi, just out of curiosity. I just found out about prefix-paths when requiring namespaces. So I'm wondering if there is any "catch all" way to require every namespace in a given prefix path?
I don't think it exists, but even if it does I don't think it's a good way to require
namespaces like that
yes, I fully agree, it's seams like a really bad practice to do that. I just wanted to know if it existed. 🙂
Is there a library that can be used from the REPL to asynchronously reload code, and perhaps run tests (or call a hook), when files are saved to disk?
I see that clojure.tools.namespace.repl/refresh has a hook, but it doesn't auto-load. Also, the hook doesn't receive loaded namespaces.
@eraserhd you could probably monkey something up from lein-auto's file watching machinery
I've used CIDER and emacs hooks to compile/load on save, never tried to integrate file watches into a bare repl.
There's a Clojure file-watching library that seems nice enough... I'm just kinda surprised it hasn't been done. I mean, midje has it in it's test-runner, but midje has a large bundle of dependencies.
I think in the clojure world, an unqualified "zach" means ztellman
(we should have a "clojure community first name basis" FAQ)
my bad. here it is: https://github.com/ztellman/virgil
it's interesting. In boot the watcher is disabled, so that's really a patch for the fact lein doesn't have one.
I think it sucks that lein doesn't have a file watcher, because it affects things like this.
iirc the ring wrap-reload works by comparing timestamps on files when requests come in, and reloading code before handline the request if there are recent changes
for basic questions this channel or #beginners work, there's also #clojure-spec
@eraserhd if you’re just trying to run clojure.test or expectations on change, there is https://github.com/jakemcc/lein-test-refresh . It has a few other features to get feedback faster as well. It isn’t in your repl though
Though the lein plugin appears to just run code in the project, except that it does (System/exit) when finished.
Mind elaborating on why in a REPL? I’ve always preferred having things that autoreload on code change outside of a repl, since if you’re reloading properly (in my opinion) you’re losing any state that has built up.
is @alexmiller the right person to thank for clj
providing a way of specifying a one-liner with dependencies? asking because this feature is awesome