clojure map to java instance of pojo class

2015-03-04 Thread Xiangtao Zhou
hi all, is there some library or simple way to do it like the function "map-to-pojo" in the following code ? java code class A{ public int a; public String b; } clojure code (def a {:a 1 :b 2}) (def b (map-to-pojo a A)) (instance? b A) any solution is good. Joe -- You received this

Re: partition-when

2015-03-04 Thread Ivan L
I went though almost the exact same exercise and my code is almost identical to yours. I called it partition-every and I use it a lot. A more determined individual might submit this for inclusion into core! On Tuesday, March 3, 2015 at 2:46:29 PM UTC-5, Frank wrote: > > Hi all, > > for some te

Re: Any Lispers in South Devon, UK?

2015-03-04 Thread Stephen Wakely
Awesome! I work in the middle of Exeter so that's definitely close enough. I would love to get involved. Do you guys have anything planned for a meet up? On 4 Mar 2015 19:13, "John Kane" wrote: > Hello Stephen, > > There is a small group of us based around Exeter and we are trying to get > a gr

Re: How to persist a value while doing do-seq

2015-03-04 Thread Fluid Dynamics
For examining adjacent items in a sequence, there are a few functional (i.e., no mutable state) approaches. When the output is a sequence with an element for each adjacent pair: (map (fn [a b] ...) s (next s)) When the output is a sequence with an element for each adjacent pair that meets some

Re: How to persist a value while doing do-seq

2015-03-04 Thread Justin Smith
Consider using for, and returning the new set of values (for [[a b] (partition 2 1 coll)] (if (= (:foo a) (:foo b)) (dissoc a :foo) a)) Here I use partition so that each item can be compared to the one that follows it. You would likely want a final step that tacks on the last it

Re: How to persist a value while doing do-seq

2015-03-04 Thread Marc Limotte
Probably a reduce is more appropriate. (reduce (fn [x a] (your-compare-expression x a) ; the result of this expr is the result of the fn and will be 'x' for the next iteration ) 0 b) BTW, a let to bind an atom outside your do-seq, while _not recommended_, should work. We would have

Re: Any Lispers in South Devon, UK?

2015-03-04 Thread Colin Yates
Only if you promise to move up to Leicester :). On 4 March 2015 at 13:14, John Kane wrote: > Hello Stephen, > > There is a small group of us based around Exeter and we are trying to get a > group off the ground, is that close enough to be of interest? > > John > > > On Tuesday, 3 March 2015 21:53

Re: Any Lispers in South Devon, UK?

2015-03-04 Thread John Kane
Hello Stephen, There is a small group of us based around Exeter and we are trying to get a group off the ground, is that close enough to be of interest? John On Tuesday, 3 March 2015 21:53:57 UTC, Stephen Wakely wrote: > > Hi, > > Are there any other Lispers in South Devon who would be interest

How to persist a value while doing do-seq

2015-03-04 Thread noobcoder
Hi, I have the following code structure (do-seq [a b] . . . ) For each a in b, I want to check a particular value in a, store it and compare it with the same value in next a. If it is same I want to clear it before next a. I tried to define an x (atom 0) by having a let outside of

Re: Idiomatic way to co-ordinate 'disconnected' services into a single transaction (ala Spring's @Transactional functionality)?

2015-03-04 Thread Colin Yates
Yeah, that is the conclusion I came to, dynamic binding for the win, I think :). On 4 Mar 2015 18:47, wrote: > (if it's just a regular ThreadLocal, you should be able to get its value > through (.get tx)) > > To elucidate briefly, I mean something like this: > > (def ^:dynamic *tx*) > > ;; elsewh

Re: Idiomatic way to co-ordinate 'disconnected' services into a single transaction (ala Spring's @Transactional functionality)?

2015-03-04 Thread adrian . medina
(if it's just a regular ThreadLocal, you should be able to get its value through (.get tx)) To elucidate briefly, I mean something like this: (def ^:dynamic *tx*) ;; elsewhere (binding [*tx* (.get tx)] ...do stuff ...cleanup) a with-tx macro would make this pattern reusable throughout y

Re: Idiomatic way to co-ordinate 'disconnected' services into a single transaction (ala Spring's @Transactional functionality)?

2015-03-04 Thread adrian . medina
Ah I think I understand now! Is it possible to dereference the connection and "hold on" to the thread local state? If so, then dynamically binding the transactional connection and doing all of your work within that context might be a good solution. You can also write a macro to do this, closing

Re: Idiomatic way to co-ordinate 'disconnected' services into a single transaction (ala Spring's @Transactional functionality)?

2015-03-04 Thread Eduardo Aquiles Affonso Radanovitsck
In my previous project we were using high order functions to wrap everything in a transaction. So we would have stuff like this: (require [clojure.java.jdbc :as db]) (defn create-foo-entity [entity] [(fn [conn] (db/insert! ...))]) (defn create-bar-entity [entity] [(fn [conn] (db/insert! ...

Re: Idiomatic way to co-ordinate 'disconnected' services into a single transaction (ala Spring's @Transactional functionality)?

2015-03-04 Thread Colin Yates
Hi Adrian, and thanks for replying. I understand your point, but the subtlety is that a transactional connection is per function invocation where as the database component is per Component lifecycle - passing the db around isn't sufficient here. Spring plumbing binds a transactional connection to

Re: Idiomatic way to co-ordinate 'disconnected' services into a single transaction (ala Spring's @Transactional functionality)?

2015-03-04 Thread Colin Yates
And just to be clear - I get _why_ explicit parameter passing is a good idea, or rather why dynamic binding is frowned upon, I am asking for practical help with the consequences of that decision. I also get the argument that a transaction changes at runtime state and so shouldn't be part of the

Re: Idiomatic way to co-ordinate 'disconnected' services into a single transaction (ala Spring's @Transactional functionality)?

2015-03-04 Thread adrian . medina
Having never used Spring (or anything else resembling the style of code you presented) I don't really know if I'm understanding what you're asking. However, it might be useful to wrap your database in a component. I do this for Datomic all of the time, and the boilerplate looks something like t

Idiomatic way to co-ordinate 'disconnected' services into a single transaction (ala Spring's @Transactional functionality)?

2015-03-04 Thread Colin Yates
Hi, I am looking for the Clojure equivalent of: class Whatever { @Transactional void doSomething(IDoSomething one, IDoSomethingElse two) { one.doSomething() two.doSomething() } } where both one and two are dependency injected with a proxy which resolves to a thread local

Re: [ANN] Understanding the Persistent Vector

2015-03-04 Thread Jean Niklas L'orange
Hi Frank, On Wednesday, March 4, 2015 at 12:24:42 PM UTC+1, Frank Castellucci wrote: > > Will you be doing this for other data types? > I will have a small break first, but I intend to do the same kind of series for persistent hash maps/sets. Maybe even RRB-trees if people are interested (I fou

Re: clj-uuid: time-based uuid now 350% faster than java.util.UUID/randomUUID

2015-03-04 Thread danle...@gmail.com
Yep. I can't overstate how useful feedback from this group has been to find new ways to optimize the code and to try to make the documentation more clear and useful. On Wednesday, March 4, 2015 at 11:17:30 AM UTC-5, Lucas Bradstreet wrote: > > Thanks for the extra analysis. My feeling was that

[ANN] EuroClojure 2015

2015-03-04 Thread Alex Miller
EuroClojure has been a great conference for Clojure for several years - big thanks to Marco Abis and the community for all of their hard work. To ensure the continued excellence and growth of the conference, we are excited that EuroClojure has joined the Cognitect ecosystem. Marco has been helping

Re: [ClojureScript] Re: IMPORTANT: ClojureScript Firefox Nightly ES6 Issue

2015-03-04 Thread David Nolen
I just cut 0.0-2985. This is only for people who need to and can upgrade to address the FireFox Nightly issue. No release information for this. There's a proper release coming this week or next which will enumerate the changes since 0.0-2913. David On Wed, Mar 4, 2015 at 3:38 AM, Mitchel Kuijper

Re: clj-uuid: time-based uuid now 350% faster than java.util.UUID/randomUUID

2015-03-04 Thread Lucas Bradstreet
Thanks for the extra analysis. My feeling was that it would be possible, but I wasn't sure. Luckily my current use cases don't depend on keeping UUIDs secret, but I was still wondering if there was a trade off. A mention in the docs seems worthwhile. Cheers > On 4 Mar 2015, at 21:40, "danle

[ANN] Onyx 0.5.3: Flow Conditions

2015-03-04 Thread Michael Drogalis
Onyx is a distributed, masterless, fault tolerant data processing system for Clojure. Version 0.5.3 is out with a new feature called Flow Conditions. Flow Conditions isolate logic for message routing within your cluster, offering extraordinary flexibility for runtime specification. Blog post:

Re: clj-uuid: time-based uuid now 350% faster than java.util.UUID/randomUUID

2015-03-04 Thread danle...@gmail.com
Also, if someone were given another time based UUID to use as a basis of comparison, they could eliminate 47 more bits of randomness to guess at. So, I think you make a good point that I think will be worthwhile to mention in my documentation. Thank you. -- You received this message because

Re: clj-uuid: time-based uuid now 350% faster than java.util.UUID/randomUUID

2015-03-04 Thread Dan Lentz
It is a fair point about guessability, though, in the sense that you might be able to mount a brute force attack to guess a time based UUID, but it would not be easy. You would need to guess an effectively random 59 bit number (the low order bits) and then step through all possible time stamps mil

Re: clj-uuid: time-based uuid now 350% faster than java.util.UUID/randomUUID

2015-03-04 Thread danle...@gmail.com
My pleasure! Just to be clear, clj-uuid does NOT use the hardware MAC address and does NOT pose any security concern. -- 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

Re: [ANN] Understanding the Persistent Vector

2015-03-04 Thread Frank Castellucci
Jean It's been added to the must reads list. Will you be doing this for other data types? Again, Great Work! Frank On Saturday, February 28, 2015 at 11:14:17 AM UTC-5, Jean Niklas L'orange wrote: > > Hello fellow Clojurians, > > I am happy to announce that I have finished my blogpost series on

Re: [ANN] Understanding the Persistent Vector

2015-03-04 Thread Jean Niklas L'orange
Hi Bost, Thanks for the input! Yeah, I agree it might be a bit confusing right now. I'll definitely change it to something that's a bit easier to grok, probably with some inspiration from your suggestion. On Tuesday, March 3, 2015 at 11:58:00 AM UTC+1, Bost wrote: > > Hi Jean > > > The tail o