This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-12-29
Channels
- # beginners (31)
- # boot (5)
- # cider (1)
- # clara (1)
- # cljs-dev (9)
- # clojure (118)
- # clojure-nl (2)
- # clojure-russia (90)
- # clojurescript (344)
- # cursive (4)
- # datascript (1)
- # datomic (41)
- # emacs (5)
- # hoplon (48)
- # ldnclj (13)
- # lein-figwheel (13)
- # leiningen (1)
- # off-topic (1)
- # om (146)
- # omnext (1)
- # onyx (65)
- # re-frame (22)
@seancorfield: I read boot documentation, and it looks like a sane approach.
Which Clojure functions are lazy seq functions? You know functions that are lazily evaluated
reduce is lazy?
reductions is lazy: https://clojuredocs.org/clojure.core/reductions
nowprovision: reduce is not lazy, you're right. http://blog.altometrics.com/2015/02/lazy-reduce-in-clojure/ someone made lazy version
Hi all, I’ve got a compojure app with the following middle-ware
(def app
(-> routes
wrap-json-body
wrap-json-response
wrap-request-logging
init-data))
When i use ring-mock to test it, the :body of the request is an InputStream. When I make a request from a browser its just a string.
Im confused by this and not sure the best way to go about fixing it.
@kopasetik: your problem can be solved without any cycle :)
@kopasetik: I'll try to prompt a bit. Split your queue into pieces like ["sheldon" "howard" "penny"], ["sheldon" "sheldon" "howard" "howard" "penny" "penny"] ... in your head. Then use Math/log2 to find out in which piece your input number is. I guess that would be enough :)
But I also want to know why I have that PersistentVector$ChunkSeq
error when I run my original code…any ideas?
@rm using ring-mock?
Is this a good idea? bad idea?
@pastafari: All good, thanks!
This looks like a good guide to Clojure’s laziness functions: http://clojure-doc.org/articles/language/laziness.html
@kopasetik: maybe because rest is internal clojure function and there is some conflict. Try other name
@underplank: no, it's ok, but I can't remember if I got the same problem. How your mock looks exactly?
@rm:
(deftest user-put-handler-test
(init-data app)
(let [new-user {:email "" :address "hello there"}
req (mock/request :put "/user")
req (mock/body req (generate-string new-user))]
(is (= {:status 200
:headers {"Content-Type" "application/json; charset=utf-8"}
:body (generate-string new-user)}
(app req)
)))
)
underplank: https://github.com/weavejester/ring-mock/blob/master/src/ring/mock/request.clj#L70
ahh… but my body is json.. not urlencoded...
@rm actually I think i’ve worked it out. Its the body in the response not the request that is an InputStream.
hello world
world answers: hello @jimmyramia
are we running an eval bot here? Trying to get one on our company slack: https://github.com/verma/clj-slackbot seems to need pr-str for lazy-seqs, which is annoying.
ah, I found the fork: https://github.com/samflores/clj-slackbot
Hey guys! … Two questions for you: 1) Which library do you use for error handling?, 2) How do you structure your "handling error” code to keep it separated from your main code?… I found a library named Dire, which encourages the separation between this two worlds, however, is not clear to me how to accomplish this in the real world (I am thinking at folder/files level).
Am I missing something or is (into {} (filter #(f %2) my-map))
really the most concise way to filter a map with f
on its keys?
Hmm, given that clojure is not so young anymore, is it fair to say that some "batteries" (i.e. functions commonly needed) are missing from core and one shouldn't expect them to be added?
Ah, the great debate about what belongs in clojure core, and why certain less useful things are already included...
Here's one that's been getting me lately. I just wrote this function to simplify a pattern I keep running into:
(defn zipmapf [coll f]
(zipmap coll (map f coll)))
Anyone know if something like this already exists, or what a better name might be?One could argue that it is weird to have frequencies
in core, but not something more generic. But I'm not starting a fight.
Looks like flatland useful has the following:
(defn map-to
"Returns a map from each item in coll to f applied to that item."
[f coll]
(into {}
(for [item (distinct coll)]
(map-entry item (f item)))))
Ah @gtrak I wasn't aware there was a fork with fixes, I'll try to get that merged in, fwiw that fork is pretty old and I've added realtime API bot since (which is far more responsive). I'll try to get some of the annoyances fixed.
I started using core.async/pipeline
and I'm not getting the CPU utilization I expected. It's a computational pipeline, the job is CPU-bound, I specified 16 as the number of jobs, and yet I'm maxing out at about 250% CPU load as reported by the OS. I expected to reach 600-800%, as I did when using tesser.
@verma I tried both, webhook works for us b/c it lets us use heroku free tier+sleep, but the print fixes are also a good thing.
In my lein project.clj, is there a convenient way to automatically increment the version number when I deploy?
I've been playing around with lein-release plugin, but not sure yet if it's exactly what I want
Can anyone help with making my use of clojure.data.xml more lazy wrt outputting big xml files?
It looks like data.xml
is just going to call (str o)
on whatever object is supplied as the attribute.
hi all, i'm looking for some documentation on best practices for incorporating logging into a library. the only docs i can find are for application layer logging, where logging configuration is controlled
@micha: You can't find anything because your time would be better spent helping me with my problem. 😉
I need to supply an object on which str
will be called and have it return a huge string.
in general you delay stuff by wrapping it in a function, delay does that for you, lazy-seq is used to delay a recursion
yeah, that's not going to work - basically I'm using clojure.data.xml to write an X3D file and it isn't lazy enough so with big files I'm running out of memory.
internally data.xml
is going to call str
on whatever I supply as an xml element attribute
I've been formatting these attributes using this function: list-format (fn [coll] (string/join " " (apply concat coll)))
well, the string can't be lazy, but rather than create all the ones I need, I thought if the string creation were at least delayed until data.xml calls str
on it that it might take some of the memory pressure off
(apply str (interpose " " (apply concat [[1 2 3] [4 5 6] [7 8 9]])))
=> "1 2 3 4 5 6 7 8 9"
(str (interpose " " (apply concat [[1 2 3] [4 5 6] [7 8 9]])))
=> "clojure.lang.LazySeq@2b53c34c"
the problem is that calling str
on any lazy seq, which is what clojure.data.xml
is going to do, yields a string representation of the lazy seq object, not a string of the elements of the sequence, if that makes sense
I may have to create a custom deftype with an implementation of Object.str that does what I want.
@meow: apply is exactly as lazy as the function you are applying
that wouldn't return if it weren't lazy
@noisesmith: good point
I need to figure out in exactly what way clojure.data.xml
is lazy when it comes to writing xml files.
ooh, boot! I have a boot question... https://github.com/frankhenderson/boot-cljs-test-question