This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-23
Channels
- # aleph (1)
- # architecture (4)
- # aws (7)
- # beginners (249)
- # boot (17)
- # calva (4)
- # cider (30)
- # cljdoc (7)
- # cljs-dev (1)
- # cljs-experience (3)
- # clojure (69)
- # clojure-dev (7)
- # clojure-europe (1)
- # clojure-italy (7)
- # clojure-japan (15)
- # clojure-spec (6)
- # clojure-uk (39)
- # clojurescript (51)
- # cursive (31)
- # data-science (4)
- # datavis (1)
- # datomic (40)
- # dirac (67)
- # duct (8)
- # editors (15)
- # emacs (9)
- # events (3)
- # figwheel-main (2)
- # fulcro (157)
- # juxt (4)
- # kaocha (11)
- # lein-figwheel (1)
- # off-topic (31)
- # pathom (18)
- # re-frame (4)
- # reagent (2)
- # reitit (16)
- # remote-jobs (1)
- # shadow-cljs (11)
- # specter (2)
- # speculative (1)
- # tools-deps (27)
- # vim (1)
- # yada (2)
or if you just want to pick a specific result type: (into [] (map f) coll)
etc.
@noisesmith I've also been using vec
quite a bit.
the difference here is into doesn't need to build a lazy-seq, as it uses the transducing arity of the collection functions
and it can use #{}
or clojure.lang.PersistentQueue/EMPTY
or {}
instead of []
A have dynamic tabular data
I don't know how many rows or columns I might have
So I'm accessing cells in this data by x and y index
in broad strokes, lazy seqs can to some extent amortize the cost of traversals by being lazy so maybe you do a bunch of mapping opperations and only force them at the end, if you always concretely constructing vectors you lose that
So I should probably just convert to vec in the final step?
Or can I avoid vectors entirely here?
I might look at another representation too, maybe {[x y] data}
, depending on what operations you are doing
if you can describe your transformations as a transducer you pass to into, that is even better than lazy seqs
Hello! Quick q: is there a nice way in clojure to do a few if-let
/ if
/ let
in a row (nested), but have them all branch out to the same fallback? For example when signing in a user you might want to fetch a user account (`if-let`), then check the password, etc, but if at any point the condition fails you want to branch out to some error message
You might have a look at a library Iāve been working on which has pattern matcher designed to make this sort of thing easier to read without sacrificing (much) performance š https://github.com/noprompt/meander
(require '[meander.match.alpha :as r.match])
(defn find-password [data]
(r.match/find data
;; Only binds ?password if data contains a :user key which points
;; to a map that has a :password key points to a string.
{:user {:password (pred string? ?password)}}
[:okay ?password]
?_
[:nope]))
(find-password {:user {:password "password"}})
;; =>
[:okay "password"]
(find-password {:user {:password :wrong}})
;; =>
[:nope]
(find-password {:user {}})
;; =>
[:nope]
(find-password {})
;; =>
[:nope]
meander looks really awesome, i intend to find some time to try it soon
@hmaurer If none of the "success" expressions can produce nil
, you can always wrap the whole in (or ... (my-fall-back))
(and use when
/`when-let`)
Also, I'd say that if you have a long enough chain of conditionals, you probably need to refactor it into smaller functions anyway (which then become a bit easier to chain together with or
š )
(or threading or whatever)
@hmaurer hi. try these two different macros
Can someone help me decipher one of the new clojure error messages? Itās this:
{:type clojure.lang.Compiler$CompilerException
:message Syntax error compiling at (plus_one_api/server.clj:38:1).
:data #:clojure.error{:phase :compile-syntax-check, :line 38, :column 1, :source plus_one_api/server.clj}
:at [clojure.lang.Compiler load Compiler.java 7647]}
{:type java.lang.ClassNotFoundException
:message clojure.spec
:at [java.net.URLClassLoader findClass URLClassLoader.java 466]}]
:trace
Does this mean that clojure.spec
is missing? I looked at line 38 in server.clj, and it is a comment. Not a spec related comment
You might have a look at a library Iāve been working on which has pattern matcher designed to make this sort of thing easier to read without sacrificing (much) performance š https://github.com/noprompt/meander
(require '[meander.match.alpha :as r.match])
(defn find-password [data]
(r.match/find data
;; Only binds ?password if data contains a :user key which points
;; to a map that has a :password key points to a string.
{:user {:password (pred string? ?password)}}
[:okay ?password]
?_
[:nope]))
(find-password {:user {:password "password"}})
;; =>
[:okay "password"]
(find-password {:user {:password :wrong}})
;; =>
[:nope]
(find-password {:user {}})
;; =>
[:nope]
(find-password {})
;; =>
[:nope]
@mv Is there any mention of the Java class java.net.URLClassLoader and/or the method findClass in that file? If so, note that findClass is a method, not a class. If there is an import statement that contains "java.net.URLClassLoader findClass", perhaps it should be changed to "http://java.net URLClassLoader"
The exception is a ClassNotFoundException, and since findClass is a method name, not a class name, that led to my questions above.
Nothing I found. Did clojure.spec exist under a different name at some point? Is this a version issue?
I do not see any mention of clojure.spec, or anything that I know to be related to clojure.spec, in the error messages you sent. What makes you believe it has something to do with clojure.spec?
hello, i am using kafka consumer in clojure and i keep seeing tons of these logs printed to screen:
DEBUG org.apache.kafka.clients.consumer.internals.ConsumerCoordinator - Group some-group committed offset 8 for partition test-0
there are thousands of these, any one know how to turn them off?
settings i've tried:
log4j.properties
in resources
folder
log4j.rootLogger=INFO
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%d] %p %m (%c)%n
log4j.logger.org.apache.kafka.streams=WARN
log4j.additivity.org.apache.kafka.streams=false
also
(set-logger! :level :warn
:additivity false
:pattern "%p - %m%n"
:filter (constantly true))
This might be stupid question but is there a way to process huge binary files/streams lazily? or partially ? or in chunks? and to save those parts/chunks to a file until stream is empty?
I need to save big binary data to a file system without realizing whole stream in memory/heap.
What i imagine is i have a reference to big input stream in java which i will use in clojure code as input stream which will take lets say
50mb > save to file
take another 50 > save to file
do this until stream is empty
i am doing this (
but i am not sure if it's what i am looking for
the Java channel APIs are probably the most efficient way to do stuff like this - Iād just google up the best way to do it in Java, and then do the same via interop
Could the persistent data structures in Clojure be made as performant in idiomatic Clojure instead of Java?
I believe Rich has intimated in the past that it could be done, but the payoff wasn't clear. FWIW, I believe CLJS's data structures are within an order of magnitude performance of CLJ's and they're implemented in CLJS. Not sure if the performance difference is between js's vm and JVM, or between CLJS and CLJ though.
well, since the code in clojurescript is āpureā clojure, it shouldnāt be too hard to port it to .cljc, so you can run them in the JVM
I donāt know that much about it. Personally I would start reading the source code.
yeah, I'm doing that, still can't comprehend how little js there is in the repo, just a handful of boostrap files in https://github.com/clojure/clojurescript/tree/master/src/main/cljs/cljs
here is some emit code: https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/compiler.cljc#L512
i see, that's all happening in https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/core.cljs
but the emit link is helpful. I had searched for this without success a few times, thanks!
Well, cljs's persistent data structures are built on js's arrays, which are pretty semantically close to java's imo. So it shouldn't be too hard to port them over
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/PersistentQueue.java#L106
Hmmm, don't see a more specific channel, so asking here. Has anyone used bidi https://github.com/juxt/bidi with http-kit? The claim is it is compatible with http-kit, but not sure how to use it via http-kit/run-server
@jsa-aerial might be worth posting in #juxt
Thanks - you were correct, answer given there
Does anyone know how to correctly escape arguments to lein
under windows powershell? I've tried variously lein update-in :dependencies conj "[nrepl \
`"0.5.3\``"]" -- repl`` and lein update-in :dependencies conj '[nrepl "0.5.3"]' -- repl
, but the first just prints the help banner and the latter blows up in the lisp reader claiming 0.5.3 isn't a valid number š
also I apparently can't escape backticks in slack markdown correctly, so that is compounding the issue...
if you have emacs and cider, you could jack in in a project and then check the *Messages*
buffer which will have the lein invocation that CIDER uses. it has some escaped arguments there.
yeah, looked at that already, but it appears that cider is invoking it some other way, to complicate matters :S