Apologies in advance on a very newbie question.
I've constructed a sequence
(take 10 (iterate (fn [[a b]] [(* 2 a) (/ a (Math/log a))]) [2 (/ 2
(Math/log 2))])
doing a take 10 on it, produce the pairs I expect.
what I like to know is, how do I filter for with value b is < X
for example, the first 10 produces.
([2 2.8853900817779268] [4 2.8853900817779268] [8 2.8853900817779268]
[16 3.8471867757039027] [32 5.7707801635558535] [64 9.233248261689365]
[128 15.38874710281561] [256 26.380709319112476] [512
46.16624130844683] [1024 82.07331788168325])
what if I want to filter so I only get pairs for which the 2nd value
is < 10. I couldn't figure out how to get
filter to work for pair values.
a 2nd question is more of general clojure idiom, in trying to covert
the following java
code from michaelg's java 1 presentation
private int calcSize(){
int max = 2;
while ((max/Math.log(max)) < size &&
max < Integer.MAX_VALUE && max > 0){
max *=2;
}
return max;
}
My first reaction was to do it using a sequence. Is this the clojure
idiomatic way to convert a
while loop from other languages?
Thanks,
Mac
--
Omnem crede diem tibi diluxisse supremum.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---