Re: Do you recommend the book: Web Development with Clojure

2014-02-19 Thread Laurent Droin
For what it worth... I bought this book because I thought it would be a 
great way for me to learn Clojure. I am familiar with web frameworks such 
as Rails and Play, but didn't know much about Clojure.
Unfortunately, it proved too difficult for me to follow because Clojure is 
way different from imperative languages. This is not the book's fault.
So in order to really be able to read this book, I had to take a step back 
and focus on learning Clojure first, which is what I'm doing now. Once I 
have a better understanding, I will get back to the book.

So the bottom line (for me) is that
- I am not able to tell whether this book is good or not (although I'm 
pretty confident it is). I am actually impatient to be able to reopen it :-)
- Because I didn't know Clojure, I was not ready for this book. Of course, 
your mileage may vary. I think the author says that you don't need to be an 
expert at Clojure, but I think you still need to have played with and get 
functional programming, which makes total sense.

On a side note, the first few chapters of this book introduced me to Light 
Table, and after having had a rough start with it, I now very much like it.
Also, the author appears to be responsive on the book web page over at 
pragpub.

Laurent.

On Wednesday, February 19, 2014 7:54:25 AM UTC-8, Erlis Vidal wrote:

 Hi all, 

 Have any of you read the book *Web Development with Clojure*?


 http://www.amazon.com/Web-Development-Clojure-Build-Bulletproof/dp/1937785645

 There's only one review on amazon, and it's a fantastic review but I'm 
 wondering if this is the book I should read if I wanted to start using 
 Clojure for web programming. 

 Any advice will be greatly appreciated. 

 Thanks, 
 Erlis 



-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Looking for advice to fine tune a simple function

2014-02-18 Thread Laurent Droin
Wow, that's amazing. Thanks Billy and Johanna. I'm going to try all this 
tonight.

What I'm not sure of (I don't have a good understanding yet about lazy 
sequences) is whether or not the sequence given to some is lazy or not.
For example, if I have thousands of parameters but x is = the first 
boundary value (i.e. the first element in the sequence), I don't really 
want to test x against all the other boundary values in the sequence since 
I already know it's not nil.
Otherwise, I was thinking I could use recursion, take the two first 
elements of the sequence, and see if I could conclude. If not, I would call 
the function again against the rest of the sequence.

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Looking for advice to fine tune a simple function

2014-02-18 Thread Laurent Droin
He he... more research work for me tonight. Thanks Johanna for the pointers.

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Looking for advice to fine tune a simple function

2014-02-18 Thread Laurent Droin
Now that I have a better understanding of what some does (i didn't 
interpret the doc properly), it does totally make sense that it would be 
recursive, so that's great.

While reducing my code with Johanna's feedback, I noticed I kept using 
cond and not if.

Is there any meaningful difference between

(if (= x y) z)

and

(cond (= x y) z)

?

I see that if is a special form and cone is macro. I haven't reached the 
chapter about macros yet in  the book I'm reading (programming Clojure). 
Not sure if it's relevant.

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Function that weaves two collections together - looking for feedback

2014-02-18 Thread Laurent Droin
Hi,

Continuing my little pet project (small program really) to learn Clojure, I 
am now working on a function whose description would be something like:
  Returns a collection 'weaving' 2 collections (boundaries into 
categories).
  Boundaries must have one element less than categories.
  For example, if categories is [:z1 :z2 :z3 :z4 :z5]  
  and boundaries is [120 150 165 180] 
  returns [:z1 120 :z2 150 :z3 165 :z4 180 :z5]

Assume the precondition is enforced.
If categories has n elements, boundaries has n-1.

I have tried to come up with a good implementation. I actually came up with 
two, one that is non recursive, and one that is recursive. But I'm not 
fully satisfied. I have the feeling that it's possible to make the function 
simpler, and more elegant but I only know a subset of Clojure and am surely 
missing some good idioms that I could/should be using.
So once again, relying on feedback from experienced Clojurists to show me 
the way :-)

Here is what I have so far:

1- the non recursive function - based on mapcat

(defn build-quantize-defs
  [categories boundaries]
(conj (into [] (mapcat #(vector %1 %2) categories boundaries)) (last 
categories)))


2 - the recursive function

(defn build-quantize-defs-recur [categories boundaries]
  (let [c (first categories) b (first boundaries)]
(if (nil? b) 
  [c] 
  (into [] (concat [c] [b] (build-quantize-defs-recur (rest categories) 
(rest boundaries)))


Both functions work (on my example at least).

One of the things I don't like, is my abusing (or the feeling that I am 
abusing anyway) of this into []  idiom. I find myself constantly turning 
things into vectors. That doesn't seem right and maybe I am using it in 
places it's not needed. That's probably because I don't quite have a very 
good idea of how collections work just yet. 

Thanks for any feedback.

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Function that weaves two collections together - looking for feedback

2014-02-18 Thread Laurent Droin
Ah, thank you. interleave is what I was looking for. I looked for 
weave, zip, map, concat, and all the see also but did not find 
interleave.
Interleave will of course not handle the last value in the categories 
collection so my first instinct will be to call (into [] ) on the map 
returned by interleave, and to add (using conj) the (last categories) to 
the vector. Not sure whether there is a better way.

On Tuesday, February 18, 2014 9:17:54 PM UTC-8, Michael Gardner wrote:

 You may be interested in the core function 'interleave'. As for (into []), 
 it's perfectly idiomatic as long as you actually need to return a vector 
 and not just some kind of sequence (the more common case). But note also 
 the mapv/filterv/reduce-kv family of functions, though they're not directly 
 applicable here. 

 On Feb 18, 2014, at 22:58 , Laurent Droin lauren...@gmail.comjavascript: 
 wrote: 

  Hi, 
  
  Continuing my little pet project (small program really) to learn 
 Clojure, I am now working on a function whose description would be 
 something like: 
Returns a collection 'weaving' 2 collections (boundaries into 
 categories). 
Boundaries must have one element less than categories. 
For example, if categories is [:z1 :z2 :z3 :z4 :z5]   
and boundaries is [120 150 165 180] 
returns [:z1 120 :z2 150 :z3 165 :z4 180 :z5] 
  
  Assume the precondition is enforced. 
  If categories has n elements, boundaries has n-1. 
  
  I have tried to come up with a good implementation. I actually came up 
 with two, one that is non recursive, and one that is recursive. But I'm not 
 fully satisfied. I have the feeling that it's possible to make the function 
 simpler, and more elegant but I only know a subset of Clojure and am surely 
 missing some good idioms that I could/should be using. 
  So once again, relying on feedback from experienced Clojurists to show 
 me the way :-) 
  
  Here is what I have so far: 
  
  1- the non recursive function - based on mapcat 
  (defn build-quantize-defs 
  

  [categories boundaries] 
  
  
  (conj (into [] (mapcat #(vector %1 %2) categories boundaries)) (last 
 categories))) 
  
  2 - the recursive function 
  (defn build-quantize-defs-recur [categories boundaries] 
  

  (let [c (first categories) b (first boundaries)] 
  
  
  (if (nil? b) 


  [c] 


  (into [] (concat [c] [b] (build-quantize-defs-recur (rest categories) 
 (rest boundaries))) 
  
  Both functions work (on my example at least). 
  
  One of the things I don't like, is my abusing (or the feeling that I am 
 abusing anyway) of this into []  idiom. I find myself constantly turning 
 things into vectors. That doesn't seem right and maybe I am using it in 
 places it's not needed. That's probably because I don't quite have a very 
 good idea of how collections work just yet. 
  
  Thanks for any feedback. 


-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Looking for advice to fine tune a simple function

2014-02-17 Thread Laurent Droin
Wow, thanks Gianluco, Andy and Bruno. Lots of good feedback I am trying to 
process. It's amazing how coming up with a satisfying functional 
programing style function is a complex process when you've been doing 
imperative programing all your life. It's really a whole different way of 
thinking. I like it but it will take some practice and your feedback really 
helps. It looks like I'm going to spend more time on it. I'll update.

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Looking for advice to fine tune a simple function

2014-02-17 Thread Laurent Droin
All the good feedback here had me thinking a lot... Especially Andy who 
pushed me towards more abstraction.
I loved the idea of functions that return functions and researching all 
this led me to embrace partials.

Here is my current implementation of quantize. It came out of a lot of 
trial and errors (gotta love the REPL) and even though, it became more 
concise,
- I think it can be improved
- I am wondering if I'm going too far. I'm worried that it makes the 
function hard to understand for someone who would maintain it. I don't have 
enough FP experience to get an idea whether this function is well written, 
or if it's just impossible to understand. From an imperative programming 
background, it is certainly impossible to understand.

(def inf Long/MAX_VALUE)
(defn quantize
  Given a collection of ordered numeric 'markers' such as [m n],  given a 
collection of values such as [a b c],  returns a if x = m, returns b if m  x 
= n, returns c if n  x  This should work for any size collections, but the 
values neeed to have  one more element than the markers.
  [x markers values]
  (let 
[f (partial (fn([%1 %2 %3] (cond (= %1 %2) %3))) x)]
(first (filter #(not (nil? %))(map f (conj markers inf) values)


A few things I don't like:
- (conj markers inf) to artificially add an infinite enough value to my 
markers collection so that it turns [120 150 165 180] into [120 150 165 
180 infinity]. Too bad there is no infinity in Clojure.
- I hate the #(not (nil? %)) but I could not find a predicate such as 
not-nil?
- I was not able to get (some) to work in this context so I used (first 
(filter instead.
- I could probably make this more readable by applying the Clojure styling 
guide (I will)

Any idea how I could improve this function further for more elegance and 
clarity?

With this function working, I can stick it to some foundation library and 
create a simpler hr library.

My hr library would contain:

(def hr-zones [:z1 :z2 :z3 :z4 :z5])
(defn get-hr-zone [hr-zones-def bpm]
  (quantize bpm hr-zones-def hr-zones))



And then, my client application would have:

(def get-my-hr-zone 
  (partial get-hr-zone [120 150 165 180]))
(get-my-hr-zone 119)(get-my-hr-zone 120)(get-my-hr-zone 149)(get-my-hr-zone 
150)(get-my-hr-zone 151)



BTW, thanks Andy for the tip about Pygments.

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Looking for advice to fine tune a simple function

2014-02-17 Thread Laurent Droin
All good points Andy. Thanks. I'll continue working on it until I'm happy.

I am almost never happy with anonymous functions either. In this particular 
case, though, the function is so simple that I felt it would be overkill to 
externalize it into another function (unless I'm really going to use it 
somewhere else). The fact that we don't know what the parameters are didn't 
bother me too much:

(cond (= %1 %2) %3))
I just wanted something that return the third parameter if parameter 1 = 
parameter 2. It seemed too abstract to try to label the parameters.

About the Long/MAX_VALUE, I didn't like it and you're right that it will 
only work for integers (if I read correctly, they are actually long in 
Clojure) but that won't work for all other numerical types. I don't see any 
solution to my problem besides having to do a test that is different from 
all the other tests in the function.
I also like the function signature you came up with initially. It does make 
sense and it's probably more elegant than passing two collections.

But as you said, there are many ways to implement the same thing. I would 
like to follow best practices as much as possible.

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Looking for advice to fine tune a simple function

2014-02-17 Thread Laurent Droin
So here is a new attempt at the quantize function so that I no longer have 
to deal with the infinity problem:

(defn quantize-2 
  [x params]
  (let [f (partial (fn [a [b c]] (cond(= a c) b)) x)]
(or 
 (first (filter #(not (nil? %)) (map f (into [](partition 2 2 params))) 
 (last params))


params now has this form: 

[:zone-1 120 :zone-2 150 :zone-3 165 :zone-4 180 :zone-5]


i.e. the values to return are intermingled with the boundaries. I 
normally don't like mixing things but you've gotta admit that it looks just 
like how you would draw heart rates on a schema on paper: zone1 | zone 2 | 
zone 3 | zone 4 | zone 5 and you would probably have the values 120, 150, 
165 and 180 written in between the zone names, just above the | characters.

The way I got rid of the infinity is by using the or. I'm looking for the 
first non null value (when trying to find whether x is = 120, = 150, 
=165, =180, and if I don't find any, then it must be that we're in the 
last category of my params collection.

Still not sure whether it's the optimum way to do it but I'll continue 
researching (after all, this is not a professional project, I have no 
deadline, and I can keep trying to improve  - great way to learn).
The feedback I got on this post got me working and scratching my head all 
weekend. This is great. 

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Looking for advice to fine tune a simple function

2014-02-17 Thread Laurent Droin
So here is a new attempt at the quantize function so that I no longer have 
to deal with the infinity problem:

(defn quantize-2 
  [x params]
  (let [f (partial (fn [a [b c]] (cond(= a c) b)) x)]
(println (first (filter #(not (nil? %))(map f (into [](partition 2 
params))
(or 
 (first (filter #(not (nil? %)) (map f (into [](partition 2 params) 
 (last params


params now has this form: 

[:zone-1 120 :zone-2 150 :zone-3 165 :zone-4 180 :zone-5]


i.e. the values to return are intermingled with the boundaries. I 
normally don't like mixing things but you've gotta admit that it looks just 
like how you would draw heart rates on a schema on paper: zone1 | zone 2 | 
zone 3 | zone 4 | zone 5 and you would probably have the values 120, 150, 
165 and 180 written in between the zone names, just above the | characters.

The way I got rid of the infinity is by using the or. I'm looking for the 
first non null value (when trying to find whether x is = 120, = 150, 
=165, =180, and if I don't find any, then it must be that we're in the 
last category of my params collection.

Still not sure whether it's the optimum way to do it but I'll continue 
researching (after all, this is not a professional project, I have no 
deadline, and I can keep trying to improve  - great way to learn).
The feedback I got on this post got me working and scratching my head all 
weekend. This is great. 

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Looking for advice to fine tune a simple function

2014-02-17 Thread Laurent Droin

So here is a new attempt at the quantize function so that I no longer have 
to deal with the infinity problem:

(defn quantize-2 
  [x params]
  (let [f (partial (fn [a [b c]] (cond(= a c) b)) x)]
(or 
 (first (filter #(not (nil? %)) (map f (into [](partition 2 params) 
 (last params


params now has this form: 

[:zone-1 120 :zone-2 150 :zone-3 165 :zone-4 180 :zone-5]


i.e. the values to return are intermingled with the boundaries. I 
normally don't like mixing things but you've gotta admit that it looks just 
like how you would draw heart rates on a schema on paper: zone1 | zone 2 | 
zone 3 | zone 4 | zone 5 and you would probably have the values 120, 150, 
165 and 180 written in between the zone names, just above the | characters.

The way I got rid of the infinity is by using the or. I'm looking for the 
first non null value (when trying to find whether x is = 120, = 150, 
=165, =180, and if I don't find any, then it must be that we're in the 
last category of my params collection.

Still not sure whether it's the optimum way to do it but I'll continue 
researching (after all, this is not a professional project, I have no 
deadline, and I can keep trying to improve  - great way to learn).
The feedback I got on this post got me working and scratching my head all 
weekend. This is great. 

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Looking for advice to fine tune a simple function

2014-02-17 Thread Laurent Droin
Hmmm, looks like I can replace

#(not (nil? %))

by
(complement nil?)

which seems more elegant.

Also, it looks like I don't need that (into [] ), which will keep the code 
cleaner.

I think I could also get rid of the (or) by always adding (last params) 
at the end of the sequence from which I pick the first non null element. 
The problem with this is that I need to make sure I add this element at the 
end of the collection, and map returns a list, which means that I would 
need to convert it into a vector if I want to use conj.
Or maybe there's a way to guarantee that I can add an element at the end of 
the list.  I know it's not cheap but I'm not sure if it will make a 
significant difference for what I'm doing. 
I think I could really abuse the into function and that doesn't seem 
quite right.

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Looking for advice to fine tune a simple function

2014-02-16 Thread Laurent Droin
Hi,

Disclaimer - I am completely new to Clojure. I just implemented my very 
first (simple) program, letting me find out, from a GPX file, how much time 
is spent in the various heart rate zones. Now that it's working, I'm 
reviewing the code and trying to use best practices. From what I have read 
so far, there are many ways in Clojure to do the same thing and for a 
newbie, it's not always obvious to get a good grasp on what is the best way 
to  code a feature.
As a developer, and even though I love how concise Clojure programs can be, 
I am very concerned with readability and ease of maintenance so I would 
like to keep functions as short and tight as possible, but not to the point 
where it becomes hard to understand what it does.

Here is a function that I came up with that takes  a bpm (heart beats per 
minute) value, as well as a sequence of 4 values that represent the 
boundaries defining the 5 different heart rate zones for a particular 
person.
The function needs to finds out in what heart zone the bpm value falls into 
and return that zone (as a keyword - I later use that keyword in a map).

If you're an experienced Clojure developer, what would you have done 
differently (and why) ?

*(defn hr-zone*
*  Return the HR zone as a keyword according to the bpm value.*
*  [bpm [max-zone-1 max-zone-2 max-zone-3 max-zone-4]] *
*  (cond *
*(= bpm max-zone-1) :hr-zone-1*
*(and ( max-zone-1 bpm) (= max-zone-2 bpm)) :hr-zone-2 *
*(and ( max-zone-2 bpm) (= max-zone-3 bpm)) :hr-zone-3 *
*(and ( max-zone-3 bpm) (= max-zone-4 bpm)) :hr-zone-4 *
*( max-zone-4 bpm) :hr-zone-5))*

FYI, here is how I call this function in the REPL:
(def my-hr-zones-defs [120 150 165 180])

(hr-zone 115 my-hr-zones-defs)
(hr-zone 133 my-hr-zones-defs)
(hr-zone 161 my-hr-zones-defs)
(hr-zone 175 my-hr-zones-defs)
(hr-zone 192 my-hr-zones-refs)

Questions I have:
Would that make sense to consider (and maybe enforce) that the sequence 
received as parameter is sorted? If this was the case, I would assume I 
could avoid the and calls- assuming that all the conditions in the cone 
form are evaluated in order. 
Assuming that I need to test bpm against the two boundaries of each range, 
would there be a better way to do this:
*(and ( max-zone-1 bpm) (= max-zone-2 bpm))*
?
Maybe this would work, but is it preferable?
*( max-zone-1 bpm (dec **max-zone-2**))*

*Thanks in advance for the advice.*

*Laurent. *

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.