Interop with strange java type: java.lang.String

2015-08-20 Thread Andy Dwelly
I'm having to do some interop with a proprietary - and erroneously documented - Java SDK. There's a class C with a method described as 'translate(java.lang.String). Trying to call the method with a Clojure on an object of class C I got a 'no matching method found' error. So I used the following

Re: Memoize in the real world

2014-12-15 Thread Andy Dwelly
It looks very similar to the pattern I was trying to avoid in the first place. I've also got the problem of multiple threads (and its been pointed out that my original solution was not thread safe). In my experience bugs of an 'extremely rare but could conceivably happen' nature are the sort of

Re: what do you think about this code?

2014-12-14 Thread Andy Dwelly
I'm somewhat late to the party, but what the hey - it's a quiet Sunday afternoon, and for my own amusement I came up with: (defn spaces [n] (apply str (take n (repeat . (defn n-a [n] (char (+ n (int \A (defn a-n [a] (- (int a) (int \A))) (defn gap [n] (spaces (dec (* 2 n (defn

Re: Memoize in the real world

2014-12-10 Thread Andy Dwelly
Thanks to everyone for the responses. I was completely unaware of core.memoize although I think there is a very convincing case for delay; I certainly accept the thread safety problem with the existing code. Action this day on that one! I'm inclined to go down the @@ syntactic route, simply in

Re: Memoize in the real world

2014-12-10 Thread Andy Dwelly
strictly once but also (atom) allow for changing the underlying value (i.e. clear the cache). On Wednesday, 10 December 2014, Andy Dwelly andyd...@gmail.com javascript: wrote: Thanks to everyone for the responses. I was completely unaware of core.memoize although I think there is a very

Memoize in the real world

2014-12-09 Thread Andy Dwelly
Looking through my recent work I see that a number of atoms, swap! and reset! calls have snuck into my work, usually when there's an expensive operation like reading and parsing a large file or connecting to a database. I find I'm doing things like (def conf (atom nil)) (defn config [] (if

Re: Backslashes in Edn

2014-11-26 Thread Andy Dwelly
. *grumble* On the positive side, I'm now in a position to add a useful example to the grimoire. -A On Wednesday, November 26, 2014 7:41:46 AM UTC, Andy Dwelly wrote: Thanks for both suggestions guys, and yes - I'm using prn-str - apparently the wrong one. It's a trivial change so I will start

Backslashes in Edn

2014-11-25 Thread Andy Dwelly
I've recently been serialising some data using Edn, and to date this has caused no problems. During some tests today, I serialised a string representing a file path that originated on a windows machine \My Documents\somedoc.txt. Edn throws a runtime exception when reading this back claiming:

Re: Backslashes in Edn

2014-11-25 Thread Andy Dwelly
Thanks for both suggestions guys, and yes - I'm using prn-str - apparently the wrong one. It's a trivial change so I will start there. Thanks again, appreciate it. Andy On Tuesday, November 25, 2014 2:00:44 PM UTC, James Reeves wrote: On 25 November 2014 at 12:23, Andy Dwelly andyd

Re: [ANN] om-bootstrap 0.2.5 - Bootstrap 3 components in Om

2014-08-29 Thread Andy Dwelly
on this barebones, TODO Getting Started page: http://om-bootstrap.herokuapp.com/getting-started Andy Dwelly javascript: August 28, 2014 at 6:05 AM I've got a working knowledge of Clojure and I'm trying to extend my reach into Clojurescript, om, and bootstrap as I want the resulting website

Re: [ANN] om-bootstrap 0.2.5 - Bootstrap 3 components in Om

2014-08-28 Thread Andy Dwelly
I've got a working knowledge of Clojure and I'm trying to extend my reach into Clojurescript, om, and bootstrap as I want the resulting website to look reasonable. I've worked my way through the om tutorials and I have a simple plain om example of my own which doesn't use bootstrap. Apart

Re: [ANN] Leiningen 2.4.3

2014-08-11 Thread Andy Dwelly
On Wednesday, August 6, 2014 12:54:16 AM UTC+1, Phil Hagelberg wrote: Hello everyone. I'm happy to announce the release of Leiningen 2.4.3. This release includes a number of small fixes and one big fix: access to the Central repository now occurs over HTTPS since Sonatype opened up