Re: Help with strange test output when deftest used inside a macro

2017-10-10 Thread Gary Verhaegen
is is looking for specific patterns and, if it can't find a known one, defaults to assuming its argument is a random predicate and prints that. So what's happening here is the syntax quote expands (resolves) = to clojure.core/= and thus it doesn't match the pattern for = anymore. So you'd need

Re: Is there a better way to get to `Classname[].class` ?

2017-10-10 Thread Gary Verhaegen
What Alex suggested is probably the best approach here. Note: there's a typo in my message, the name of the class needs to be as Alex says for the type hint too, i.e. the L and ; are essential for this to work. > On 9 Oct 2017, at 18:31, pericles macedo wrote: > > Hey Gary, thanks for the help

Re: any? in clojure 1.9.0 alpha

2017-10-10 Thread Gordon Syme
With respect, I have searched prior conversations and have not found a justification for why any? is in clojure.core rather than clojure.spec. All the problems people have raised with any? are due to it be a predicate with a very specific use-case (defining specs) but placed in a namespace where

Re: Is there a better way to get to `Classname[].class` ?

2017-10-10 Thread Peter Hull
I actually preferred your solution, pericles, because it doesn't require memorising the "[L...;" syntax, and works if you don't know the class at compile time. By the way you can use make-array to create a zero size array which might be (ever so slightly) more efficient. For reference (apologie

Re: any? in clojure 1.9.0 alpha

2017-10-10 Thread Jozef Wagner
Clojure isn't for the most part a community effort therefore decisions about the language and it's core library are seldom made in the collaboration with the community. In my opinion, if you want your language change proposal to be considered, you have to justify and back it up by a strong real

Re: Help with strange test output when deftest used inside a macro

2017-10-10 Thread Matt Grimm
Excellent, thanks! The actual macro is indeed a little more complicated, but the test assertions are limited to (is (= ...)), so replacing = with ~'= works perfectly. On Tuesday, October 10, 2017 at 3:10:37 AM UTC-6, Gary Verhaegen wrote: > > is is looking for specific patterns and, if it can't

Updating repeated nested structures?

2017-10-10 Thread Rob Nikander
Hi, Say I have a map like this: (def m {:qs [{:nums [3 1 2]} {:nums [7 4]}]}) I want to transform each number with a function (say, `inc`). I imagine something like this: (update-in m [:qs * :cell-fns] #(map inc %)) ; or (update-in m [:qs * :cell-fns *] inc) But of cours

About determinism of async

2017-10-10 Thread JokkeB
I'm wondering about a case when using async: I have a channel where I write from multiple threads. One of the sources is a go-loop with a timeout, so each second I write something to the channel. If I do two consecutive writes inside the go block, can another thread write between the two writes

Re: About determinism of async

2017-10-10 Thread Gary Trakhman
I think a core assumption is that all writes can yield control at any time to other worker go processes. I wouldn't rely on the consecutive behavior even if it were true, nondeterminism is a good assumption with core.async. If you need that particular guarantee, consider a call to partition? On T

Re: About determinism of async

2017-10-10 Thread JokkeB
Thanks for the response. That's what I suspected. How does partition help me in this case? I can't see any way of using it. How about onto-chan, would that be deterministic? Or any other function? tiistai 10. lokakuuta 2017 17.33.22 UTC+3 Gary Trakhman kirjoitti: > > I think a core assumption is

Re: Updating repeated nested structures?

2017-10-10 Thread Timothy Baldridge
My answer to most of these questions is often "write it once, stuff it in a function, and forget about it". Really though I often see this as a data-modeling and naming problem. For example, you could go and write a `(update-cells cell-list f & args)` that wraps custom logic for finding and manipu

Re: About determinism of async

2017-10-10 Thread Gary Trakhman
So, at the point where you need 2 things to be consecutive, wrap them up in a vector so they're one thing. `(partition-all 2)` will return a transducer xform that chunks up your message stream by 2 https://clojuredocs.org/clojure.core/partition-all, and if you need to undo it you can do so with the

Re: Updating repeated nested structures?

2017-10-10 Thread Rob Nikander
Gah. I changed one name and not another. I meant: (update-in m [:qs * :nums] ...) On Tuesday, October 10, 2017 at 10:18:56 AM UTC-4, Rob Nikander wrote: > > Hi, > > Say I have a map like this: > > (def m {:qs [{:nums [3 1 2]} {:nums [7 4]}]}) > > I want to transform each number with a funct

Re: [core.spec] Stricter map validations?

2017-10-10 Thread Leon Grapenthin
In terms of code loading, acyclic dependencies turned out to be a great design choice in Clojure - why its benefits shouldn't apply to or be justified for spec loading is totally unclear to me. To make my point more clear let me recap. I am simply asking for s/keys to throw if provided specs ar

Re: Clojure examples

2017-10-10 Thread John M. Switlik
And so, starting today with Google App Engine. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To

Re: Updating repeated nested structures?

2017-10-10 Thread hitesh
It's not terse, but it is easier to follow. (defn flip [f x y] (f y x)) (defn update-nums [m f] (update m :qs (fn [x] (flip map x (fn [x] (update-in x [:nums] #(map f %))) ;; (update-nums m inc

Re: Updating repeated nested structures?

2017-10-10 Thread Gary Trakhman
I wrote a terrible terrible function once to help with this while bored in jury duty, called flipartial, in the style of core's 'let's expand/optimize out the most common arities': (defn flipartial "A combo of partial/flip, makes it easier to fake-curry non-data-last functions. In general, only

Re: Updating repeated nested structures?

2017-10-10 Thread aleks m s
I agree with someone else that the first thing you should do is see if you can flatten the data in some way. I find that namespaced keywords often help with that. If it doesn't make sense to flatten it, however, I'd use specter . It's for exactly this use-

Is the Learning Guide in Order?

2017-10-10 Thread Tomiwa Ademidun
Hey guys, I Finally started learning Lisp/Clojure thanks to inspiration from the great Paul Graham's essays . First, I wanted to say I appreciate your work in putting together the tutorial and clojure-docs website, its very helpful and I really appreciate all

[ANN] zprint 0.4.3

2017-10-10 Thread Kim Kinnear
A new version of zprint, a full function Clojure and Clojurescript code and data pretty printer: https://github.com/kkinnear/zprint is available. You can use zprint in a variety of ways: - As a "filter" that will accept Clojure(script) source on stdin and produce formatted source on s

Re: About determinism of async

2017-10-10 Thread Rangel Spasov
I think simply wrapping the two values in a vector is the only thing that's needed in this case. Simply do a put like (>!! ch [my-val-1 my-val-2]) and take from the channel from another place. If my-val-1 and my-val-2 are not immediately available, you can have a separate mechanism (atoms, (loop