This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-17
Channels
- # aws (2)
- # beginners (34)
- # boot (39)
- # cider (28)
- # cljs-dev (2)
- # cljsrn (30)
- # clojure (195)
- # clojure-austin (6)
- # clojure-dev (6)
- # clojure-dusseldorf (1)
- # clojure-france (1)
- # clojure-russia (139)
- # clojure-spec (25)
- # clojure-uk (66)
- # clojurescript (125)
- # community-development (1)
- # core-async (42)
- # cryogen (1)
- # cursive (22)
- # datascript (6)
- # datomic (67)
- # docker (1)
- # emacs (7)
- # events (1)
- # garden (3)
- # hoplon (15)
- # jobs (3)
- # lein-figwheel (10)
- # leiningen (3)
- # luminus (4)
- # mount (2)
- # nginx (1)
- # off-topic (101)
- # om (42)
- # om-next (6)
- # onyx (7)
- # proton (1)
- # protorepl (4)
- # re-frame (15)
- # reagent (30)
- # remote-jobs (1)
- # ring (8)
- # ring-swagger (17)
- # rum (1)
- # spacemacs (2)
- # sql (1)
- # yada (50)
user> `(require '[clojure.string :as ~‘s])
(clojure.core/require (quote [clojure.string :as s]))
(which is basically the same — the answer is “no”)
(at least, as I understand your question)
Perhaps if you provide a bit more context around what you’re doing, folks might be able to offer a suggestion @neupsh ?
What's the best way to turn dates
and team
(seqs) into something like this?
[[[:shift team-member day] [:shift team-member day]]
[[:shift team-member day] [:shift team-member day]]]
@seylerius you've got 2 seqs, how do they line up with that structure?
(partition 2 (map (fn [t d] [:shift t d]) team dates))
does this do it?
More precisely: for team-member-i
within team
and day-j
within dates
, I need this:
[[[:shift team-member-1 day-1] [:shift team-member-1 day-2]]
[[:shift team-member-2 day-1] [:shift team-member-2 day-2]]]
probably with for
then
Do I need a pair of for
s? Like this?
(for [team-member team]
(for [day dates]
[:shift team-member day]))
(partition (count dates) (for [t team d dates] [:shift t d]))
something like that?
you can already pass a few bindings to for
and it goes through all the combinations
after that you're just grooming the structure of the output data
check out this example https://clojuredocs.org/clojure.core/for#example-542692c7c026201cdc326957 @seylerius
what's the best channel to brainstorm a new oo / msg passing model (like smalltalk mixed with erlang) to build in clojure? i asked in #off-topic if ppl are interested to check it out
Clojure looks to be a very good match for this kind of computers: https://lwn.net/Articles/655437/ (The Machine by HP).
Hiya. I’m trying to set up a new vagrant dev env with a new luminus project.. running lein repl gives me the following error: Caused by: java.lang.UnsupportedClassVersionError: from/riddley/Util : Unsupported major.minor version 52.0, compiling:(from/riddley/compiler.clj:1:1)
.. not sure what steps i should take to pin it down..
@tbaldridge good progress with fn-fx
! Here is an issue I encountered though: Is it already possible to construct controls that have mandatory constructor arguments? for example controls/scatter-plot
which needs to get two axes in the ctor. I suspect that something like render-core/construct-control
could be used to build it, but I do not yet understand how everything fits together. Maybe you could help with that?
@brabster would you mind sharing a bit of that meta endpoint ? i am wrestling similiar issue… And AOT uberjar and env vars seeem a bit tricky to navigate...
@karol.adamiec hey, I found the leiningen configleaf plugin. It lets you generate and store a copy of your project.clj as it appears under a profile in your jar, so that you can access it as a clojure data structure
That's probably enough for me, I can set my project version using System/getenv and run lein set-profile foo to generate the code... is that any help?
hmm, i was thinking more along the lines of generating a edn file with echo and reading that on startup… but will take a look at that plugin 🙂.
@tbaldridge was able to render it via diff/component
. I think it is brittle though because only prop-names-kw
gets checked for matches and this is empty for all ctors of the ScatterPlot even though there are arity 2 and 3 ctors. However, that’s a bit too much detail for the chat I guess… will proceed the way it works for now.
I want to push a library to clojars. I set the projectname to my org, but still get a 401 after several broken pipe errors. What do I have to consider? Return code is: 401, ReasonPhrase: Unauthorized.
`
@danielgrosse what does "I set the projectname to my org" mean exactly?
Anyone using HugSQL that can help me with this one? http://stackoverflow.com/questions/41697464/hugsql-select-where-in-with-uuid-values
hi all. i'm a bit stuck on how to recursively nest keys in a map to store the output of a recursive function. i have a simple function that does list comprehension on vectors and i'm mapping it to core.async channels recursively so if "fans out" exponentially, but i can't figure out how to store the output in a map at each step without overwriting previous values, if that makes sense.
here's an example with the current output and how i'd like it to look: https://gist.github.com/Sophia-Gold/c686cd3efac3e5389878b2011351be57. the base is one less than the count of the nested vectors i'm processing, so in this case two. right now the map obviously just ends up with the last values of each index to finish as they overwrite the previous ones. in order to store them all i'd need the map to be nested so it has 2^n values for the nth recursive call, but i'm struggling to imagine how to do this with assoc-in
.
@sophiago
1 - I would not recommend the nested defn
it may work but it’s not idiomatic and “looks funny” for lack of a better description .. prefer letfn
(as you need recursion)
2 - why are you using core.async?
i'm using core.async because the number of processes on each recursive call quickly grows quite large and i don't need the output to be ordered
(this is calculating derivatives, so just the third derivative of a three dimensional function will have 27 partials)
You're using core.async as a way of parallelizing?
Not trying to cop out here @sophiago , but I think the mutable variable and core.async channels makes it hard to reason about (at least for me, it does), for this particular problem. Others may have another opinion, but I would not use async tools here, as you do not have an async problem to solve. You said "i can't figure out how to store the output in a map at each step without overwriting previous values”, and I don’t think your choice of tools is making it easy
np, i appreciate the input. i don't think core.async is the issue, though. perhaps refactoring it to not use doseq
would make it easier to reason about. otherwise, well, i am currently living somewhere with a hammock 🙂
you might have similar flexibility by just using futures
but with less trickiness
I would opt for solving the problem first — without parallelism at all — then parallelize if desired
so it's true if it was sequential, it'd be a cinch just because i could have one long vector and not worry about labeling anything right away
isn’t the “unordered” part directly contributing to your difficulty in constructing the data the way you want it?
yes of course. but an ordered implementation wouldn't translate to the concurrent version
to scale beyond this tiny example i'm using simply because i can mentally check whether it's correct
i was playing around with a third index earlier rather than nesting so deeply and i think i may be able to figure it out that way
More is better
More protocols, fewer signatures per protocol
thanks @alexmiller
I was a bit reluctant, but it's more elegant than having to advertise what you're doing I guess
never really thinking too much about how clojure.test
works I just noticed that I can create a function and place multiple is
statements in its body, and then returning something completely different, and calling that function in a deftest
still seems to check the results of those is
forms
I have some tests that need to perform side-effectful preparation and teardown work, is it a fine practice to just set up the context like this within a function body, call a few is
forms in the middle and then perform teardown afterwards
and then wrap a call to this no-argument function inside a deftest
, or am I overlooking something?
nope, that's fine
@luxbock I also recommend taking a look at this pattern: https://stuartsierra.com/2016/05/19/fixtures-as-caches
Yes, is
is side-effecting. It depends on a thread-local binding
for output reporting. I was young and foolish.
Well it's a very nice and clean way of doing asserts and getting reporting. I prefer it over having to make sure all my tests return a collection of test results.
Yeah, there are trade-offs either way.
@stuartsierra so, will there be clojure.test2
?
@mavbozo There was. It was called Lazytest. It never really worked out as a testing framework, but the core of it became tools.namespace
.
None of them solve the problem stuart mentioned though, and they come with their own set of problems.
In the end, the simplicity of clojure.test always wins, IMO. If you took out the fixture stuff from clojure.test the core could be about 100 lines of code.
btw @tbaldridge do you know if it's somehow possible to pay for your videos on your YT channel without having access to a Google Wallet? I used to subscribe to them while you still hosted them on Pivotshare but have been unable to watch any of your new content because of this
@luxbock there's a link in the description of the YT site that talks about that. Basically no, but I also offer the vids via Paypal+Dropbox (or Google Drive)
https://www.youtube.com/channel/UC6yONKYeoE2P3bsahDtsimg Click the "show more" dropdown section
and we should probably move this off-topic now. But I'm happy to answer any more questions
Guys, anyone that has worked with quartzite and can give some help? I'm trying do implement a basic schedule but it never executes
@tvalerio without taking a closer look, are you sure you keep your process running after you started the scheduler? Often the main process shuts down and with it the scheduler will be killed too.
@sveri I'm pretty sure the process keep running, I'm using ring as server and I'm calling the scheduler main function when the server initializes
@tvalerio Your main function exits after scheduling the job. Like I said, you need to keep the process running.
Gotcha. If you don't need all the bells & whistles that quartz/quartzite provides, you may want to look at org.immutant/scheduling
. It uses quartz as well, but your example above would collapse to:
(require '[immutant.scheduling :as s])
(defn my-job [] (println "howdy!"))
(s/schedule my-job (-> (s/every 300) (s/limit 11)))
docs: http://immutant.org/documentation/current/apidoc/immutant.scheduling.html#var-schedule
@tvalerio You could add a sleep to your main function after scheduling and you should see the outputs.
@sveri I have a main function that starts a ring server. In this function I start the schedule, thats why I think it should not exit... But it must be a simple thing
@tvalerio At least the code you pasted does not have a ring server inside. It only required quartzite libs.
Not sure about vanilla ring, but using http-kit server, the function returns and does not block. So, the main function is usually expected to return after starting the server.
@joshjones so i had to step away for a bit, but as mentioned earlier i did get that core.async code working by just replacing the lowest level of nesting with unique indices. the thing that's really confusing me now, though, is that each time i run it i'm getting a slightly different set of values. i understand the order will differ based on when each channel finishes, but since they're all on separate channels it should be returning the same values each time it recurses and certainly not duplicating others in place of the slower ones. do you have any guesses why this could be occurring? here's the code again with new output: https://gist.github.com/Sophia-Gold/c686cd3efac3e5389878b2011351be57
clojure is not scheme, def (and forms based on it like defn) binds names to values in the top level scope
@hiredman @joshjones told me the same thing (and it is my scheme background). but that's not the source of this error
i suspect it's something i can learn in here: https://github.com/clojure/core.async/wiki/Go-Block-Best-Practices
you are binding different functions to the global name diff-loop, each different function has closed over different values of s m and n
but are you saying using letfn
would fix that because i get the same behavior regardless?
i would have liked to use a go-loop
but you can see i'm not recurring from tail position
partial-diff is returning a lazy seq, and then you put it in to a channel unrealized
why are you pre-allocating all those channels? the usage (which I don't why they are being used) doesn't escape that one area, so if you do need them, create them locally there and use them there
@joshjones i thought you said to not use concurrency entirely? he seems to be pointing out exactly what it says at the beginning of that doc
you should never do (go (<! c))
, that should be a take! but I agree, you don't need so many channels
yes @sophiago , and I still say that after a lot of headache with this, you should work to get it correct using sequential methods, then understand the mechanisms for making it parallel, if you find some benefit to doing so, and then implement it using those mechanisms, if necessary. and unless you have a good reason for using async tools for their intended purpose (not this problem, IMO), don’t use them
how is their intended purpose not to run many calculations concurrently? this seems like a perfect use case
But what @hiredman says is right, your channels being created in the go
blocks aren't doing much at all. But one of the core issues here, is that you're firing off go blocks and then not doing anything with the results, so it's possible to get a result in the repl before the go blocks have finished executing
@tbaldridge that's consistent with what i'm seeing
by "in the repl" do you mean i just need to wait longer for them to finish? or should i be doing something differently?
although if that was the case i'd expect to see values missing from the map, not ones repeated
go blocks return channels, those channels will contain results or return nil when the go block executes. So you need to be taking from every block you create
Or use futures and deref
can you post that code?
so i tried putting a one second thread sleep between the puts and takes and even with that the behavior is the same... i should try reducing channels (although i don't think eight running concurrently is so excessive), but i'm having trouble both mapping my function to the channels and indexing the return values to store in the hash-map since apparently nesting doseq
s causes an infinite loop 😕
Perhaps this (long) discussion belongs in #core-async ?
Definitely seems like it’s gone beyond general #clojure discussions at this point (with my Admin hat on).
😄 I think sometimes, when a discussion gets to be essentially one-on-one and goes deep in the weeds, taking it to DM is worth considering (and perhaps reporting back just a summary of the solution so folks know how an issue got resolved).
@seancorfield While I would agree in a corporate kind of setting where human "resource" is scarce and expensive this makes sense I think at a place like this I would do this only very seldom. In the end everybody can learn and go through the thought process. For instance right now I am following this discussion interested although I never used core.async in a useful way and I am curious to find out what the problem / better solution here is.
Btw, I refer to the "going DM" part, not switching to #core-async, which does make sense as it is more on topic there.
A DM conversation can be multi-party so if you’re interested in a discussion where the folks involved decide to take it out of the channel, you can always ask to be added in. We just need to bear in mind that in some of these channels, our audience is ~8,000 people. follow-up on discussion etiquette can go to #community-development as it’s not relevant to this channel — I’m happy to continue it there.
from personal experience often when there's a long discussion between few people going on there are other people who have questions or want to say something unrelated and are waiting out of politeness
I think this will help http://www.theverge.com/2016/4/13/11418594/slack-threaded-messaging-chat-app-feature
hello guys, I try to use source
on one of my defn
but Source is not found
I looked and .getResourceAsStream
returns null
yes, same namespace
* .getResourceAsStream
is used internally by source-fn
Did you define the function from the repl or in a source file? And can you call the function?
source file
yes I can call it
ok, thx anyway 🙂
(fwiw i learn a lot by lurking here)