Re: Help with idiomatic clojure.

2015-11-13 Thread Colin Yates
Another tip when using seq then: cljs.user=> (or (seq [1 2 3]) false) (1 2 3) cljs.user=> (or (seq []) false) false cljs.user=> > On 13 Nov 2015, at 14:09, Brian wrote: > > I think I like 'seq' better than 'empty?'.I'm sure my opinions will firm > up after writing some more clojure. >

Re: Help with idiomatic clojure.

2015-11-13 Thread Brian
I think I like 'seq' better than 'empty?'.I'm sure my opinions will firm up after writing some more clojure. > Also, in no-errors branch you probably want to return status: 200? I picked the function where I knew there was a better way. This validation function is called from this bit code.

Re: Help with idiomatic clojure.

2015-11-13 Thread Colin Yates
Doh - I obviously hadn’t had enough coffee that early in the morning :-). > On 13 Nov 2015, at 01:47, Chris Murphy wrote: > > > I think true and false should be swapped around, because seq and empty? are > opposites, seq meaning it is not empty. > > On 13/11/2015 8:08 AM, Colin Yates wrote: >

Re: Help with idiomatic clojure.

2015-11-12 Thread Chris Murphy
I think true and false should be swapped around, because seq and empty? are opposites, seq meaning it is not empty. On 13/11/2015 8:08 AM, Colin Yates wrote: One other minor point (if (seq some-sequence) true false) is preferred by some (I won’t say more idiomatic) than (if (empty? some-seque

Re: Help with idiomatic clojure.

2015-11-12 Thread Alex Baranosky
The main thing to note is to not use atoms for things like this. Colin's cond-> approach is a good idea. On Thu, Nov 12, 2015 at 4:08 PM, Colin Yates wrote: > One other minor point (if (seq some-sequence) true false) is preferred by > some (I won’t say more idiomatic) than (if (empty? some-seque

Re: Help with idiomatic clojure.

2015-11-12 Thread Colin Yates
One other minor point (if (seq some-sequence) true false) is preferred by some (I won’t say more idiomatic) than (if (empty? some-sequence) true false). Also, in no-errors branch you probably want to return status: 200? > On 12 Nov 2015, at 19:44, Brian wrote: > > Thanks Colin, Thanks Erik >

Re: Help with idiomatic clojure.

2015-11-12 Thread Brian
Thanks Colin, Thanks Erik Exactly what I was looking for. I've updated the gist with Colin's suggestion and a bit of destructuring. If this project gets any bigger I will definitely look at vlad and Prismatic Schema . BDF. On

Re: Help with idiomatic clojure.

2015-11-12 Thread Erik Assum
There is also https://github.com/logaan/vlad which helps with validation. Erik. -- i farta > Den 12. nov. 2015 kl. 17.12 skrev Colin Yates : > > A nicer equivalent form would be: > > (cond-> [] > this-error? (conj “It failed with this error”) > that-error? (conj “It failed with that erro

Re: Help with idiomatic clojure.

2015-11-12 Thread Colin Yates
A nicer equivalent form would be: (cond-> [] this-error? (conj “It failed with this error”) that-error? (conj “It failed with that error”)) However, purely for validation there are a few utilities out there already. Checkout the ‘Validation’ section on http://www.clojure-toolbox.com

Help with idiomatic clojure.

2015-11-12 Thread Brian Forester
I'm writing a very small REST application in clojure using compojure and ring. One problem is that I don't have anyone who can review my work or provide feedback. I've written a small function to validate a simple JSON request. I'm validating the three values that are in the post and colle