What are good ways to iterate through two seqs at once for side-
effects?
This doesn't seem so great since I'm not interested in the collection
that's built by map. I also learned the hard way that map is lazy.
Hence, the dorun.
(dorun (map #(println %1 %2) [1 2 3] [11 22 33]))
--
You receive
I would use something like this:
(defn zip [& xss]
(apply map vector xss))
(doseq [[x y] (zip [1 2 3] [11 22 33])]
(println x y))
Most of the time I use parallel mapping directly. But in cases like
this one I think the intention of the code is better expressed by the
above se
This happens for me on a Mac OS X system, and an Ubuntu Linux system,
and with Clojure 1.2.0 and 1.3.0-alpha1. Here are steps for me to
reproduce with Clojure 1.2.0.
Install Leiningen.
% lein new clj-1.2.0
% cd clj-1.2.0
[ Optionally edit project.clj to remove dependency on contrib, leavin
On Sep 24, 10:33 am, Thomas Wagner wrote:
> I've just ordered my copy.
:-)
Hope, you'll like it.
Best regards,
Stefan
--
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 f
> Your code was simple enough for me to make a couple of educated guesses. For
> more complex code I'd use VisualVM, https://visualvm.dev.java.net/
> David
>
I use that too.
Sampling for a first look, profiling with instrumentation for a more
precise answer.
(Here, the sampling gives even? and th
Hi everybody,
The following is a
http://pastebin.com/0r9BBdmK
code which is using clojuratica.
I am trying to write a function .. But when evaluated it is not behaving as
expected.
The function definition is
(defn irreducibleQ [x]
(With [f 10 g 20]
(* f (+ g x
The output expecte
Looks very awesome - I'll be giving this a try in my current projects.
Thanks for such a cool library!
sg
On Sep 24, 2010, at 12:38 PM, Stuart Sierra wrote:
> http://github.com/stuartsierra/lazytest
>
> My attempt to steal all the good ideas from clojure.test, Circumspec,
> ClojureCheck, RSpec
I'd use my clj-iterate library at http://github.com/jpalmucci/clj-iterate.
user> (iter {for x in [1 2 3]}
{for y in [11 22 33]}
(println x y))
1 11
2 22
3 33
nil
Won't collect the sequence if you don't ask for it, and its eager (and
fast).
It's also available at clojars.
I got the same results. lein repl vs cake repl
eric-mans-macbook-2:perfect-number Eric$ lein repl
"REPL started; server listening on localhost:64419."
user=> (defn swapping [#^ints a n]
(let [n (long n)
size-1 (int (dec (count a)))]
(loop [i (long n)
j 0
k
Thank you for your reply.
> Perhaps you'd be interested in a related but slightly different approach to
> solving a related but slightly different problem.
The game from my program is from Serbian TV quiz Slagalica (http://
en.wikipedia.org/wiki/TV_Slagalica). As you said Krypto is only
slightly
On Sep 25, 2010, at 7:14 AM, Goran Jovic wrote:
> I will definitively try using Clojush too, especially since GP was my
> initial intention, so thanks again.
Great -- I'd love to hear about your experiences. You can find more about
Push/PushGP at http://hampshire.edu/lspector/push.html.
>> Als
I have a list of numbers and I want to find the one that is closest to
136. Is there an operator for performing this kind of operation or do
I need to to do it algorithmically?
thanks!
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this
the vector form. in idiomatic clojure, lists are practically only used
for code and macro's.
2010/9/25 HiHeelHottie :
> For a literal collection of numbers which would be more idiomatic and
> why?
>
> (reduce + '(1 2 3)) vs (reduce + [1 2 3])
>
> --
> You received this message because you are subs
Maybe this: (min-key #(abs (- % 136)) xs)
On Sep 25, 3:41 pm, Glen Rubin wrote:
> I have a list of numbers and I want to find the one that is closest to
> 136. Is there an operator for performing this kind of operation or do
> I need to to do it algorithmically?
>
> thanks!
--
You received thi
On Sat, Sep 25, 2010 at 3:40 PM, Jules wrote:
> Maybe this: (min-key #(abs (- % 136)) xs)
>
Wouldn't that be (apply min-key #(abs (- % 136)) xs)?
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroup
Yes, you're right.
On Sep 25, 4:44 pm, Nicolas Oury wrote:
> On Sat, Sep 25, 2010 at 3:40 PM, Jules wrote:
> > Maybe this: (min-key #(abs (- % 136)) xs)
>
> Wouldn't that be (apply min-key #(abs (- % 136)) xs)?
--
You received this message because you are subscribed to the Google
Groups "Cloju
(use 'clojure.contrib.math) ; for abs
(apply min-key #(abs (- 136 %)) [1 3 137 -137 135 0 50 75])
A recent thread in this group noted that min-key applies the function
multiple times and there's a better replacement. Also, if you're looking up
many such numbers you might want to sort and do binary
On Sat, Sep 25, 2010 at 10:44 AM, Nicolas Oury wrote:
> On Sat, Sep 25, 2010 at 3:40 PM, Jules wrote:
>> Maybe this: (min-key #(abs (- % 136)) xs)
>>
> Wouldn't that be (apply min-key #(abs (- % 136)) xs)?
Where's your 'abs' function coming from? This works for me:
(apply min-key #(Math/ab
Thanks for the great feedback, Shawn.
On Sep 23, 3:09 pm, Shawn Hoover wrote:
> On Thu, Sep 23, 2010 at 4:20 PM, Will Kennedy wrote:
> > Some background: I've been spending some of my free time providing by
> > basic Clojure support in VS 2010. To be honest, I'm a bit of a Clojure
> > newbie, so
min-key looks good! thx guys!!!
On Sep 25, 10:44 am, Nicolas Oury wrote:
> On Sat, Sep 25, 2010 at 3:40 PM, Jules wrote:
> > Maybe this: (min-key #(abs (- % 136)) xs)
>
> Wouldn't that be (apply min-key #(abs (- % 136)) xs)?
--
You received this message because you are subscribed to the Googl
Wow, really cool. I'm looking forward to seeing this!
Mike
--
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
On Sep 23, 2010, at 10:08 PM, David Nolen wrote:
> On Fri, Sep 24, 2010 at 1:06 AM, Greg wrote:
> Thanks! What about single files though? (i.e. no project.clj)
>
>
> cake has a global project.clj - ~/.cake/project.clj. Change this and single
> files will get access to those dependencies.
Grea
Thanx Mark. I'll try again today.
On Fri, Sep 24, 2010 at 11:07 PM, Mark Derricutt wrote:
> Looking at the repository now the poms don't seem to include the variable
> reference anymore so if you're still getting that it might be cached
> somewhere?
--
You received this message because you are
On Sat, Sep 25, 2010 at 1:20 AM, Andy Fingerhut
wrote:
> % lein repl
>
> [ Here, if I do load-file, the timing results are about the same as above.
> But if I copy and paste the forms one at a time, then I get a time like the
> one below for the last form:
>
> user=> (time (vec (swapping a1 1
On Fri, Sep 24, 2010 at 9:26 AM, Miki wrote:
> The clojure-contrib on Google code still points to the "old"
> richkickey github project. The download jars are for the 1.1 release.
>
> For me, this is one of the top hits in Google - it'll probably confuse
> new users.
On a similar note, I noticed
On Fri, Sep 24, 2010 at 8:13 AM, Stuart Sierra
wrote:
> The version string in the Clojure build was set incorrectly. It has
> now been restored to "1.3.0-master-SNAPSHOT"
Yup, confirmed. Thanx Stuart.
> If you depend on "-SNAPSHOT" versions, then Maven / Leiningen will
> always give you the lat
Take a look at:
http://github.com/talios/clojure-contrib/commit/58e4e49d569d285ef3dd5b64c80454a22743e1b4
I changed the "complete" artifact to use the maven-shape-plugin [1] which
embeds upstream dependencies into your jar, making an uber-jar, and
optionally "shading" those artifacts into a differ
Thanks Eric :) Have you considered submitting that change as a patch?
On Sep 24, 5:35 pm, Eric Lavigne wrote:
> > I think I read somewhere that max-key applies f more times than is
> > necessary, so should not be pass any f that takes significant time to
> > compute.
>
> Yes, max-key calls f mor
I went through the rest of my Project Euler code. In addition to
even?, there are some functions in clojure.contrib that are also much
slower in 1.3 Alpha 1.
clojure.contrib.math -> expt
(Clojure 1.2)
user=> (time (doseq [x (range 10)] (expt x 2)))
"Elapsed time: 119.417971 msecs"
(
>> http://code.google.com/p/clojure/issues/detail?id=95
I just looked over this code. You can speed it up even more by
manually encoding the loop, rather than using reduce.
(defn faster-max-key
([k x] x)
([k x & more]
(loop [x x,
kx (k x)
s more]
(if-not s
On Sat, Sep 25, 2010 at 7:02 PM, Btsai wrote:
> I went through the rest of my Project Euler code. In addition to
> even?, there are some functions in clojure.contrib that are also much
> slower in 1.3 Alpha 1.
>
> clojure.contrib.math -> expt
>
> (Clojure 1.2)
> user=> (time (doseq [x (range 10
Awesome, thanks :)
On Sep 25, 8:44 pm, Mark Engelberg wrote:
> >>http://code.google.com/p/clojure/issues/detail?id=95
>
> I just looked over this code. You can speed it up even more by
> manually encoding the loop, rather than using reduce.
> (defn faster-max-key
> ([k x] x)
> ([k x & more]
> I haven't tried 1.3 yet, but I'd recommend downloading a copy of
> clojure.contrib.math locally and replace any instances of +, -, *,
> inc, dec with +', -', *', inc', dec'. This should at least make the
> functions produce the correct results. I'd be curious to know whether
> performance conti
This sounds fantastic! Integrating the (doc) function with the F1 help
system in some way would be helpful.
On Sep 23, 3:20 pm, Will Kennedy wrote:
> Some background: I've been spending some of my free time providing by
> basic Clojure support in VS 2010. To be honest, I'm a bit of a Clojure
> n
34 matches
Mail list logo