Re: to macro or not?

2010-10-29 Thread andrei
Mike, I mean this is just one example to prove your ideas, not to disprove. On Oct 29, 4:26 am, Mike Meyer mwm-keyword-googlegroups. 620...@mired.org wrote: On Thu, 28 Oct 2010 18:12:39 -0700 (PDT) andrei andrei.zhabin...@gmail.com wrote: I'll try to extend Mike's answer by one more

Re: How to simplify cond statements

2010-10-29 Thread andrei
On Oct 29, 4:03 am, lprefonta...@softaddicts.ca wrote: user= (doc ffirst) - clojure.core/ffirst ([x])   Same as (first (first x)) nil user= That could help a bit : Nice! I didn't know about this function, and for this concrete case it is ideal! -- You

Re: How to simplify cond statements

2010-10-29 Thread andrei
On Oct 29, 4:03 am, Andrew Gwozdziewycz apg...@gmail.com wrote: I'd hoist the empty out of the cond using an if: (if (empty? ps)     ret     (let [fps (first (first ps))]         (cond             ...))) Yeah, I thought about it, but it is still a bit verbose, especially with a 3

Re: How to simplify cond statements

2010-10-29 Thread andrei
On Oct 29, 5:40 am, David Sletten da...@bosatsu.net wrote: You could just bind another local variable in the loop form: (loop [ps pairs        ret {}        ffps (ffirst ps)]   (cond (empty? ps) ret         (some-test ffps) (recur (rest ps) (add-to-result ret ffps) (ffirst (rest ps)))  

Re: How to simplify cond statements

2010-10-29 Thread Meikel Brandmeyer
Hi, On 29 Okt., 12:11, andrei andrei.zhabin...@gmail.com wrote: You could just bind another local variable in the loop form: (loop [ps pairs        ret {}        ffps (ffirst ps)]   (cond (empty? ps) ret         (some-test ffps) (recur (rest ps) (add-to-result ret ffps) (ffirst

Re: How to simplify cond statements

2010-10-29 Thread Andrew Gwozdziewycz
On Fri, Oct 29, 2010 at 7:14 AM, Meikel Brandmeyer m...@kotka.de wrote: There's nothing stoping you to put a let in a loop. (loop [ps  (seq pairs)       ret {}]  (let [ffps (ffirst ps)]    (cond      (not ps)         ret      (some-test ffps) (recur (next ps) (add-to-result ret ffps))    

Re: How to simplify cond statements

2010-10-29 Thread Andrew Gwozdziewycz
Errr... clarification Scheme would blow up when doing (first (first object that could be '())). On Fri, Oct 29, 2010 at 7:44 AM, Andrew Gwozdziewycz apg...@gmail.com wrote: On Fri, Oct 29, 2010 at 7:14 AM, Meikel Brandmeyer m...@kotka.de wrote: There's nothing stoping you to put a let in a

Pulling threads...

2010-10-29 Thread Brian Ericson
Please forgive the lengthy post... New to Clojure and trying to get a friend excited about it by demonstrating how Clojure's functional/STM heritage makes it easy to write concurrent/parallel code, but I can't get Clojure to I started with Java, where 256 threads are vying to increment a single

Re: Pulling threads...

2010-10-29 Thread Meikel Brandmeyer
Hi, On 29 Okt., 06:58, Brian Ericson li...@curvybits.org wrote: (map #(.start %) threads) map is not a loop. It creates a lazy sequences which does - nothing. At least not until it is realised. Here you throw it away immediatelly. Hence, no work is done. Use doseq instead when your main

Re: apply an higher order function on an arbitrary nested data structure

2010-10-29 Thread Sean Devlin
Does fmap remove enough complexity to warrant it's own fn? Here's what fmap would now look like. (def fmap (partial same map)) Granted, it's probably the #1 use for same, so you might have a point. Sean On Oct 29, 12:44 am, Konrad Hinsen konrad.hin...@fastmail.net wrote: On 28.10.2010, at

Jython Interoperability problem

2010-10-29 Thread Dilvan
Hi, It was possible in clojure 1.0.0 to include clojure Persistent collections in Jython: jython -Dpython.path=clojure_dist/clojure_1.0.0/clojure-1.0.0.jar from clojure.lang import PersistentList b= PersistentList.create([7, 8, 2]) b (7 8 2) But with clojure 1.1.0 or 1.2.0 I get:

Re: to macro or not?

2010-10-29 Thread Tim Robinson
one is told to avoid macros as long as possible. I've heard this before, but I believe it's intended to be interpreted differently. I believe, it's meant to more like don't use them unless you need them, which some people translate into avoid them. I have heard, as a rule of thumb, that less

Re: (count (filter ...)) much slower in 1.3 Alpha 2?

2010-10-29 Thread Btsai
Could someone else also try the sample code I included to see if they also experience the same ~10x slowdown for (count (filter ...)) in 1.3 Alpha 2? On Oct 28, 12:34 pm, Btsai benny.t...@gmail.com wrote: I have some code that counts the elements in a list that map to true in a lookup table,

Re: (count (filter ...)) much slower in 1.3 Alpha 2?

2010-10-29 Thread Miki
I see the same problem: Clojure 1.3.0-alpha1 user= (load-file /tmp/foo.clj) Elapsed time: 402.588654 msecs 1 Clojure 1.3.0-alpha2 user= (load-file /tmp/foo.clj) Elapsed time: 4584.271921 msecs 1 On Oct 29, 9:41 am, Btsai benny.t...@gmail.com wrote: Could someone else also try the sample code I

Re: (count (filter ...)) much slower in 1.3 Alpha 2?

2010-10-29 Thread Mark Hamstra
My results are actually worse. I get about a 40x slowdown, going from ~50ms in 1.2.0 to ~2000ms in 1.3.0-alpha2. On Oct 29, 12:41 pm, Btsai benny.t...@gmail.com wrote: Could someone else also try the sample code I included to see if they also experience the same ~10x slowdown for (count

Re: (count (filter ...)) much slower in 1.3 Alpha 2?

2010-10-29 Thread Stuart Halloway
Confirmed. I am looking into this. For some reason the call to filter is reflective in alpha 2. Could someone else also try the sample code I included to see if they also experience the same ~10x slowdown for (count (filter ...)) in 1.3 Alpha 2? On Oct 28, 12:34 pm, Btsai

Re: (count (filter ...)) much slower in 1.3 Alpha 2?

2010-10-29 Thread Stuart Halloway
Rich has fixed this on master: http://github.com/clojure/clojure/commit/e354b01133e7cff8dc0d0eb9e90cde894c12e127 Thanks for the report! Stu I have some code that counts the elements in a list that map to true in a lookup table, looking something like this: (def lookup-table {1 true, 2

Re: How to simplify cond statements

2010-10-29 Thread andrei
On Oct 29, 2:14 pm, Meikel Brandmeyer m...@kotka.de wrote: There's nothing stoping you to put a let in a loop. Yes, but imagine a bit more complicated case, for example, instead of '(first (first ps))' write (.foo (first ps)), and it will crash. I'm looking for elegant, but general case

Re: How to simplify cond statements

2010-10-29 Thread Joop Kiefte
(first (flatten ...)) ? 2010/10/29 andrei andrei.zhabin...@gmail.com: On Oct 29, 2:14 pm, Meikel Brandmeyer m...@kotka.de wrote: There's nothing stoping you to put a let in a loop. Yes, but imagine a bit more complicated case, for example, instead of '(first (first ps))' write (.foo (first

Re: (count (filter ...)) much slower in 1.3 Alpha 2?

2010-10-29 Thread Btsai
Awesome, thank you :) On Oct 29, 2:29 pm, Stuart Halloway stuart.hallo...@gmail.com wrote: Rich has fixed this on master:http://github.com/clojure/clojure/commit/e354b01133e7cff8dc0d0eb9e90c... Thanks for the report! Stu I have some code that counts the elements in a list that map

[OT] Photos from Clojure Conj 2010

2010-10-29 Thread Baishampayan Ghose
Hello, I had the pleasure of attending the first Clojure Conj and I have uploaded some photographs that I took there - http://www.flickr.com/photos/ghoseb/sets/72157625254615916/ Enjoy. Regards, BG -- Baishampayan Ghose b.ghose at gmail.com -- You received this message because you are

Re: Photos from Clojure Conj 2010

2010-10-29 Thread Sean Devlin
Thanks for sharing these! On Oct 29, 4:40 pm, Baishampayan Ghose b.gh...@gmail.com wrote: Hello, I had the pleasure of attending the first Clojure Conj and I have uploaded some photographs that I took there -http://www.flickr.com/photos/ghoseb/sets/72157625254615916/ Enjoy. Regards, BG

Re: [OT] Photos from Clojure Conj 2010

2010-10-29 Thread Terrance Davis
Nice pics. I am incredibly jealous of everyone that had the chance to attend. -Terrance Baishampayan Ghose wrote: Hello, I had the pleasure of attending the first Clojure Conj and I have uploaded some photographs that I took there -

Re: Test for whether a function accepts a particular arity.

2010-10-29 Thread AlexK
You can use some Reflection to find out if the function has implemented the matching invoke(args*) method see: http://gist.github.com/654851 On 29 Okt., 07:02, Ken Wesson kwess...@gmail.com wrote: (defn accepts-arity? [n f]   (reduce     #(or        %1        (= n (count %2))        (and

Clojure on Javascript

2010-10-29 Thread Tim Daly
Has anyone thought about putting clojure on javascript? Tim Daly -- 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

Re: Clojure on Javascript

2010-10-29 Thread Santosh Rajan
Now that server side javascript is growing with node.js, clojure on javascript will be usefull. Nodejs is event based and not thread based so I don't know the ramifications on clojure yet. On Sat, Oct 30, 2010 at 8:33 AM, Tim Daly d...@axiom-developer.org wrote: Has anyone thought about

Re: Test for whether a function accepts a particular arity.

2010-10-29 Thread Ken Wesson
There's also this, I suppose: (defn accepts-arity? [n f] (try (apply f (repeat n nil)) true (catch IllegalArgumentException e (not (.startsWith (.getMessage e) Wrong number of args))) (catch Throwable _ true))) This directly tests for the exception that's generated if the

Re: Clojure on Javascript

2010-10-29 Thread Victor Olteanu
cf. node js, I thought of mentioning this link http://dosync.posterous.com/22397098 On Fri, Oct 29, 2010 at 11:10 PM, Santosh Rajan santra...@gmail.com wrote: Now that server side javascript is growing with node.js, clojure on javascript will be usefull. Nodejs is event based and not thread

Re: to macro or not?

2010-10-29 Thread Tim Daly
Macros in lisp get used for three general purposes, at least in my experience. The first purpose is efficiency. In common lisp you will find that you can generate very machine-efficient (aka optimized fortran level) binary instruction sequences if you add type information. This gets tedious to

Re: Clojure on Javascript

2010-10-29 Thread David Nolen
A port of Clojure to JS would be interesting. Rich has expressed interest and Chouser's ClojureScript is a step in that direction. On Fri, Oct 29, 2010 at 11:28 PM, Victor Olteanu bluestar...@gmail.comwrote: cf. node js, I thought of mentioning this link http://dosync.posterous.com/22397098

Re: Clojure on Javascript

2010-10-29 Thread Michael Gardner
On Oct 29, 2010, at 11:09 PM, David Nolen wrote: JS brought me to Lisp, I would love to see the Clojure community bring Lisp back to JS. However I fail to see what advantage JS gives on the server side. From what I've seen the V8 GC and Node.js have a considerable number of years to go

Re: [OT] Photos from Clojure Conj 2010

2010-10-29 Thread Sean Corfield
On Fri, Oct 29, 2010 at 4:26 PM, Terrance Davis terrance.da...@gmail.com wrote: Nice pics. I am incredibly jealous of everyone that had the chance to attend. Me too! Although a friend of mine attended and got me a T shirt! (thanx Roger!) Hopefully next year's conj will get on the schedule