This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-05
Channels
- # beginners (240)
- # boot (5)
- # cider (48)
- # clara (2)
- # cljs-dev (3)
- # cljsrn (66)
- # clojure (111)
- # clojure-denver (2)
- # clojure-italy (42)
- # clojure-nl (5)
- # clojure-spec (12)
- # clojure-uk (45)
- # clojurescript (138)
- # community-development (7)
- # core-async (8)
- # datomic (27)
- # emacs (21)
- # euroclojure (6)
- # figwheel (10)
- # fulcro (29)
- # graphql (5)
- # hoplon (3)
- # luminus (1)
- # lumo (7)
- # mount (4)
- # off-topic (13)
- # onyx (20)
- # parinfer (3)
- # pedestal (4)
- # precept (1)
- # proton (3)
- # re-frame (41)
- # reagent (3)
- # reitit (28)
- # ring-swagger (7)
- # shadow-cljs (88)
- # specter (1)
- # testing (10)
- # tools-deps (27)
- # vim (58)
1. I have an existing java application. 2. I have launched a nrepl from it via (clojure.tools.nrepl.server/start-server ...) 3. I can connect to this repl via "boot repl --client --port 5555" 4. I want to run (require 'foo.bar) 5. how do I set the src path that clojure searches for foo/bar.clj in ?
@qqq Are you trying to load code that is external to the application?
https://clojuredocs.org/clojure.core/add-classpath <-- this is marked as Deprecated. What is it replaced with ?
@seancorfield: I want to specify a path ~/blahblah-src/ then I want (require 'foo.bar) to search ~/blahblah-src/foo/bar.clj
You could load files via their file system path using load-file
...
Unless you start the application with a classpath that includes your src
directory perhaps?
Deprecated just means "there are better ways". It doesn't mean "removed".
Does anyone know of a bounded prn
function? I want to print an arbitrarily large data structure, but only the first (say) 100 characters of it, and don't want to spend the CPU to print the whole thing out.
I’ll take a look, although I think the nested shape of the data may not work here
Oh yeah and there could be a single massive string in there too
unrepl appears to introduce *string-length* https://github.com/Unrepl/unrepl/blob/master/src/unrepl/printer.clj#L11
Awesome, that looks like what I’m thinking of
how do I "continuously" interleave two colls? e.g. if I have:
[:a :b :c] [1 2]
I want to get [:a 1 :a 2 :b 1 :b 2 :c 1 :c 2
no, I mean if I have "infinitely" many 🙂 then I'm gonna have to use math.combinatorics I guess
Which method of function argument validations is considered more idiomatic in Clojure - using :pre
and :post
checks or perhaps using s/assert
in the function body instead? Or perhaps something else instead?
Hello all, I have a question regarding the "cat" transducer... why does it need to double wrap reduced (i.e. why does it use the preserving-reduced wrapper for rf). Could anyone give me an example of why that's needed?
@boogie666 Do you see how it calls (reduce rrf result input)
? If it didn't "double wrap" a (reduced ...)
call inside your transduction the reduce
would just return the value. And the reduction of the transducer wouldn't honor the reduced.
Basically it makes sure that if the rf
function does a reduced
call it will propagate to the transduction (which is again a reduce
)
the thing is, i can't think of an example where not stoping the whole chain would be a problem
for that matter, i can't think of an example in which i could stop the whole thing...
(defn cat-wrong
[rf]
(fn
([] (rf))
([result] (rf result))
([result input]
(reduce rf result input))))
(into [] (comp cat-wrong (take-while odd?)) [[1 2] [3]])
Note, you can't get that to work with (take x)
transducer since it will properly guard that (it's more robust)
Yeah take will still work since it keeps internal state. So it would just waste CPU cycles. But still be correct...
i remember seeing a presentation online about funnel / spc charts in clojure, possibly to do with healthcare? anyone know what im talking about and have a link?
hi all! I’m looking at a defmethod implementation in clj-http
and I don’t fully recognise the form… http://leo-mt-prod-app07.aslan.local:8306/accountretention/admin/metrics?pretty=true — what is that extra arg none-cookie-policy
that sits between the dispatch-value and the fn-parameter declaration?
are you talking about something like https://github.com/dakrone/clj-http/blob/eca25dd8cb66a1e909a712037b28cf1fe09d9a42/src/clj_http/core.clj#L149 ?
in that case, yes - the “none-cookie-policy” is a function name for the specific defmethod (which you’ll really only see in stack traces typically)
defmethods technically take the “function tail” which is “all the args you’d pass to fn” which includes the (optional) function name
Anyone here using parinfer-mode in emacs? I'm curious what everyone is using for the parinfer-mode-toggle key, Is it something you use often?
@U0670BDCH You might find help in #emacs
I use C-'
And only about thrice an hour, depending on the kinds of changes I'm doing
In my experience, C-c C-p was already bound to something (cider pprint something or another). I added C-' after finding there was no binding with where-is
Why do some clojure functions that take arbitrary arguments provide several signatures to handle a known number of arguments before just taking arbitrary ones and applying the rest of the args to them? Is it just for performance and common case handling? for example https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L6123
@theeternalpulse performance, but also for easier code writing
Often the arity that has & rest
at the end calls into the other arities
I see. I'm often a little thrown off by them, I recognize the pattern but I generally wouldn't write arbitrary args like that, then agian I don't write languages 🙂
@theeternalpulse check out Erlang sometime 😄 They take it to a whole new level ,and use that pattern instead of if statement:
while(L) -> while(L,0).
while([], Acc) -> Acc;
while([_|T], Acc) ->
io:fwrite("~w~n",[Acc]),
while(T,Acc+1).
Not sure that it's better than other methods, just a different way of doing it
If I wanted to implement a “clojure lite” on the EVM, purely to learn more about compilers and clojure internals, where should I start? Is there any good reading on how clojure and the JVM play together?
well there's https://github.com/kanaka/mal - not sure if that's what you're looking for
These look like they are implementations in a language, not in a VM. Does Clojure compile to the JVM or Java first?
so... assuming the coll is an instance of PersitentHashMap
, it looks like there is no cons method for that object, but it extends APersistentMap
, which has the following code:
yes, that’s all correct
the call to assoc
I just see it pulling out values from the passed argument x
but not the joining to the map
what you said is correct - what’s confusing about it?
x in RT.conj is a map entry like [k v] if this is a map
in PAM.cons() that becomes o
the key and value parts of o get pulled apart and used to invoke assoc, which returns an updated map
i don't see how it's added to original coll (map in this case) since it's only passed the two args from x
oh, this is an instance method on the map instance
so you are implicitly “in” the map and calling assoc on it
it is, but it’s call on the current object
which is the map
all instance method calls in Java have an implicit first argument which is the instance
which Java uses for dispatch
you can get that instance with this
in Java
but you typically don’t need to do that explicitly
OK thx for clarifying... btw are these type of questions reasonable here or is that more beginner channel?
generally, people in this slack are happy to answer questions anywhere :)
this could easily be #beginners or #java or even #clojure-dev since you’re looking at internals
here’s fine too