Re: A simulation of the Monty Hall Problem

2011-05-10 Thread Konrad Hinsen
On 10 May 2011, at 22:46, Ken Wesson wrote: Interesting. It is, as I thought, very short with monads -- though that version doesn't really use randomness, but instead enumerates all the possibilities. You'd need slightly different monads to thread a random bit-stream through instead of enumerati

Re: possibly non-intuitive behaviour of clojure.set/rename-keys and possible enhancement suggestion

2011-05-10 Thread Sunil S Nandihalli
I agree there are going to be problems with implementation as-well .. for example if not all the keys in the current map are not in the kmap ... but situation can be handled however, if we passed a function this is going to be harder .. .. On Wed, May 11, 2011 at 8:26 AM, Sunil S Nandihalli < suni

Re: Ok, so code is data...

2011-05-10 Thread Bill Robertson
Thanks for the feedback and pointers. On May 10, 11:37 am, Timothy Baldridge wrote: > On Tue, May 10, 2011 at 10:26 AM, Jonathan Fischer Friberg < > > odysso...@gmail.com> wrote: > > "How do I actually just load code w/o evaluating it?" > > mostly when you want something like this, you want a m

Re: can this program be sped up?

2011-05-10 Thread Ken Wesson
On Tue, May 10, 2011 at 10:14 PM, Carl Cotner wrote: > Thanks for your thorough reply, Ken. You're welcome. >> 3: Technical speedups. Avoid function calls inside inner loops, which >> cause boxing and require var dereferencing. Fold divQ into primes, >> since it's only used once in there. > > Ju

Re: can this program be sped up?

2011-05-10 Thread Carl Cotner
Thanks, David, for your reply. I enjoyed your blog post, and I will try 1.3 alpha! Carl On May 10, 5:58 pm, David Nolen wrote: > It doesn't answer your question but maybe this will help you get some ideas > on how to optimize your > code:http://dosync.posterous.com/lispers-know-the-value-of-ev

Re: can this program be sped up?

2011-05-10 Thread Carl Cotner
On May 10, 5:47 pm, Ken Wesson wrote: > Addendum: if you are using Clojure 1.3 alpha, function calls may avoid > boxing, but still have a call overhead, so you probably still want to > avoid them in your loops, and unchecked primitive math is done > differently. Check the documentation on that. T

Re: can this program be sped up?

2011-05-10 Thread Carl Cotner
Thanks for your thorough reply, Ken. On May 10, 5:43 pm, Ken Wesson wrote: > > [...] > > 1: Algorithmic smarts. Division is expensive. Replace divQ's > implementation in terms of mod with the algorithm binary GCD and it > will probably be faster. Likewise the / n 2 in primeQ can be changed > to a

possibly non-intuitive behaviour of clojure.set/rename-keys and possible enhancement suggestion

2011-05-10 Thread Sunil S Nandihalli
Hello everybody, I tried to use clojure.set/rename-keys .. I kind of felt it has a little odd behaviour... for example .. (clojure.set/rename-keys {1 :a 2 :b 3 :c} {1 2 2 3 3 4}) returns {4 :a} I think a more reasonable behavior would be to have it return {2 :a 3 :b 4 :c} a further enhancem

Re: [OFF-TOPIC] - CA Status

2011-05-10 Thread Christopher Redinger
Hi Bruno, Unless Rich has received your CA within the past couple weeks, I would say he never received it. The compete list of CAs that he is received (within the past couple weeks) is here: http://clojure.org/contributing I'm assuming you sent it to the PO Box listed? Did you do anything spec

Re: sessions in Ring, Sandbar, Compojure, etc...

2011-05-10 Thread Matthew Boston
Maybe try looking at the source of a project on github using logins/ sessions. One I'm currently using for reference is from 4clojure https://github.com/dbyrne/4clojure On May 10, 2:24 am, Shree Mulay wrote: > For the life of me, I can't get sessions to work, immaterial of which > tutorial I try

[OFF-TOPIC] - CA Status

2011-05-10 Thread Bruno Oliveira
I sent my contributor agreement through mail, months ago. I would to know if was received, my requests was to clojure and clojure-contrib projects I didn't received any feedback yet. Thanks a lot -- “Success is having to worry about every damn thing in the world, except money.” - Johnny Cash -

Re: Bug? (vary-meta (promise) assoc :foo 1) hangs in Clojure 1.2

2011-05-10 Thread Ken Wesson
On Tue, May 10, 2011 at 8:04 PM, Alan wrote: > (promise) hangs in 1.2, if you try to print it from the repl. There's > a ticket somewhere for better handling of non-delivered promises. Ah, damn. It should see if it's delivered or not and print # or similar in that case rather than try to print it

Re: Bug? (vary-meta (promise) assoc :foo 1) hangs in Clojure 1.2

2011-05-10 Thread Alan
(promise) hangs in 1.2, if you try to print it from the repl. There's a ticket somewhere for better handling of non-delivered promises. On May 10, 5:01 pm, Ken Wesson wrote: > (vary-meta (promise) assoc :foo 1) hangs in Clojure 1.2. I suspect > that vary-meta is somehow triggering an attempt to d

Bug? (vary-meta (promise) assoc :foo 1) hangs in Clojure 1.2

2011-05-10 Thread Ken Wesson
(vary-meta (promise) assoc :foo 1) hangs in Clojure 1.2. I suspect that vary-meta is somehow triggering an attempt to deref the promise. -- 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

Re: San Francisco Clojure Users

2011-05-10 Thread David Jagoe
On 10 May 2011 15:00, Zach Tellman wrote: > Unfortunately, you just missed the monthly Bay Area user group meetup, Yeah I saw that... gutted! > which was yesterday.  But with Google I/O going on, maybe there are > enough people around that an impromptu meetup would be plausible. That would be g

Re: How Clojure protocols are implemented internally?

2011-05-10 Thread Christophe Grand
On Tue, May 10, 2011 at 7:13 PM, Krukow wrote: > > > And I've got an impression that protocols are described to be as fast > as > > > interface dispatch (callvirt). > > Almost as fast in case one. There is an indirection because of > dispatch. > There is special support at the call site by the c

Re: San Francisco Clojure Users

2011-05-10 Thread Zach Tellman
Unfortunately, you just missed the monthly Bay Area user group meetup, which was yesterday. But with Google I/O going on, maybe there are enough people around that an impromptu meetup would be plausible. Zach On May 10, 1:07 pm, David Jagoe wrote: > G'day everyone, > > Forgive me if this is not

Re: can this program be sped up?

2011-05-10 Thread David Nolen
On Tue, May 10, 2011 at 2:21 PM, Carl Cotner wrote: > Hi, > > Is it possible to make Clojure run the following toy program faster > (without changing the algorithm)? > > (defn primeQ [n] (primes 2 (/ n 2) n)) > > (defn divQ [d n] (= (mod n d) 0)) > > (defn primes [d2 t2 n2] > (loop [d (int d2) t

Re: can this program be sped up?

2011-05-10 Thread Ken Wesson
Addendum: if you are using Clojure 1.3 alpha, function calls may avoid boxing, but still have a call overhead, so you probably still want to avoid them in your loops, and unchecked primitive math is done differently. Check the documentation on that. -- You received this message because you are su

Re: can this program be sped up?

2011-05-10 Thread Ken Wesson
On Tue, May 10, 2011 at 2:21 PM, Carl Cotner wrote: > Hi, > > Is it possible to make Clojure run the following toy program faster > (without changing the algorithm)? > > (defn primeQ [n] (primes 2 (/ n 2) n)) > > (defn divQ [d n] (= (mod n d) 0)) > > (defn primes [d2 t2 n2] >  (loop [d (int d2) t

can this program be sped up?

2011-05-10 Thread Carl Cotner
Hi, Is it possible to make Clojure run the following toy program faster (without changing the algorithm)? (defn primeQ [n] (primes 2 (/ n 2) n)) (defn divQ [d n] (= (mod n d) 0)) (defn primes [d2 t2 n2] (loop [d (int d2) t (int t2) n (int n2)] (if (divQ d n) false (if (> d t) true

Re: A simulation of the Monty Hall Problem

2011-05-10 Thread Ken Wesson
On Tue, May 10, 2011 at 2:59 PM, Konrad Hinsen wrote: > On 10 May, 2011, at 13:50 , Adam Burry wrote: > >> FYI, the best treatment of this problem I have seen is this one: >> http://www.cs.utoronto.ca/~hehner/PPP.pdf > > There's also a compact Clojure solution based on the probability monad: > > h

San Francisco Clojure Users

2011-05-10 Thread David Jagoe
G'day everyone, Forgive me if this is not the appropriate place for this message, but I'm in San Francisco for a few days from Johannesburg, South Africa. Any clojure users keen on meeting up? Any clojure events going on that I haven't spotted on-line? I run a business using Clojure for web devel

Re: A simulation of the Monty Hall Problem

2011-05-10 Thread Konrad Hinsen
On 10 May, 2011, at 13:50 , Adam Burry wrote: > FYI, the best treatment of this problem I have seen is this one: > http://www.cs.utoronto.ca/~hehner/PPP.pdf There's also a compact Clojure solution based on the probability monad: https://github.com/richhickey/clojure-contrib/blob/master/src/examp

Re: How to merge two ArrayMaps?

2011-05-10 Thread Alan
user> (let [inputs (concat e1 e2)] (map (partial apply merge) (vals (group-by :a inputs ({:d "blah", :a 1, :b "b", :c 300} {:d "blah2", :a 2, :b "a", :c 500}) On May 10, 10:10 am, clj123123 wrote: > I wanted to merge ArrayMap in a vector. Is there a way to do that? > I pu

Re: How to merge two ArrayMaps?

2011-05-10 Thread clj123123
I wanted to merge ArrayMap in a vector. Is there a way to do that? I put this together but wondering it there's already a library for that. (defn merge-by-field "xt must have field vals unique" [xs xt field] (let [fmerge (fn [id s] (merge s (first (filter #(= id (val (find % f

Re: How Clojure protocols are implemented internally?

2011-05-10 Thread Krukow
On May 9, 12:09 am, David Nolen wrote: > On Sun, May 8, 2011 at 4:43 PM, Dmitry Kakurin > wrote: > > > Very well, something along these lines would be my guess too. > > But that would mean that in case 2 protocols are no faster > > than multimethods. They are much faster than multimethods beca

Re: How to merge two ArrayMaps?

2011-05-10 Thread Jonathan Fischer Friberg
use (merge e1 e2) Jonathan On Tue, May 10, 2011 at 6:11 PM, clj123123 wrote: > (def e1 {:a 1 :b "b" :c 300 }) > (def e2 {:a1 :d "blah"}) > > how to merge to get that? > > {:a 1 :b "b" :c 300 :d "blah"} > > > also is there a way to merge if the ArrayMap was in a vector? > > Thanks. > > -- > You

Re: Hi, simple problem from a newbie

2011-05-10 Thread Armando Blancas
Don't be put off by these initial difficulties; this stuff is really different. I found this paper a very good read: http://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf It puts the finger on a common problem: "Such a catalogue of “advantages” is all very well, but one must not be surpri

How to merge two ArrayMaps?

2011-05-10 Thread clj123123
(def e1 {:a 1 :b "b" :c 300 }) (def e2 {:a1 :d "blah"}) how to merge to get that? {:a 1 :b "b" :c 300 :d "blah"} also is there a way to merge if the ArrayMap was in a vector? Thanks. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this

Re: ANN: A Clojure library for the Facebook Graph API - clj-facebook-graph

2011-05-10 Thread Bojan Jovičić
Dear Max, this works like a charm. Thank you very much for real fast response. -- 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 pa

Re: Reading clojure code of larger domain specific projects

2011-05-10 Thread Paul deGrandis
You might want to take a look at the clojars project: https://github.com/ato/clojars-web It's not quite to the scale you're looking for, but it's a start. Also keep in mind that a lot of business apps in Clojure look more like libraries (for a specific domain problem) than applications, so lookin

Re: Ok, so code is data...

2011-05-10 Thread Timothy Baldridge
On Tue, May 10, 2011 at 10:26 AM, Jonathan Fischer Friberg < odysso...@gmail.com> wrote: > "How do I actually just load code w/o evaluating it?" > mostly when you want something like this, you want a macro. Manipulating > code is also done within macros. > Yeah, I would consider the whole code-i

Re: Ok, so code is data...

2011-05-10 Thread Jonathan Fischer Friberg
"How do I actually just load code w/o evaluating it?" mostly when you want something like this, you want a macro. Manipulating code is also done within macros. http://www.gigamonkeys.com/book/macros-standard-control-constructs.html http://www.gigamonkeys.com/book/macros-defining-your-own.html Jon

Re: Enlive update transformation

2011-05-10 Thread Thorsten Wilms
On 05/09/2011 10:15 PM, Thorsten Wilms wrote: I tried to turn that into a transformation: (defn substitute-token [& values] #(map (fn [m] (update-in m [:content] (fn [c] (apply (partial replace-str "token" %) c values)) Apparently I had my brain knotted, but raek and fliebel on IRC helped

Re: Creating instances of types not known at compile time

2011-05-10 Thread Simon Katz
On May 10, 8:27 am, Meikel Brandmeyer wrote: > Hi, > > Am 10.05.2011 um 01:49 schrieb Simon Katz: > > > Passing the class object does exactly what I want. > > Then passing a factory function will work, too—without reflection. Much more > performance impact then checking a short string for a dot.

Aw: Ok, so code is data...

2011-05-10 Thread Stefan Kamphausen
Hi, from what you write I get the feeling, that you may be doing things in a too complicated manner. Maybe I am wrong. In any case, although it may not be Clojure but Common Lisp, you might want to take a look at the HTML generation in Peter Seibels excellent Practical Common Lisp: See chapte

Re: A simulation of the Monty Hall Problem

2011-05-10 Thread Adam Burry
Ken: FYI, the best treatment of this problem I have seen is this one: http://www.cs.utoronto.ca/~hehner/PPP.pdf Adam -- 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 n

Re: Ok, so code is data...

2011-05-10 Thread Bill Robertson
Thank you very much. On May 10, 1:32 am, Justin Kramer wrote: > 'read' and 'read-string' are what you're looking for. They each read a > single Clojure object from an input source (PushbackReader for read, > String for read-string). > > Alternatively, something like this can read all top-level fo

Re: ANN: A Clojure library for the Facebook Graph API - clj-facebook-graph

2011-05-10 Thread Max Weber
Hi Bojan, I've added a basic support to post something against the Facebook Graph API. The documentation for this new feature can be found under https://github.com/maxweber/clj-facebook-graph Best regards Max On 9 Mai, 20:22, Bojan Jovičić wrote: > Hi Max, > I have started investigating this,

Re: sessions in Ring, Sandbar, Compojure, etc...

2011-05-10 Thread James Reeves
On 10 May 2011 07:24, Shree Mulay wrote: > For the life of me, I can't get sessions to work, immaterial of which > tutorial I try and get going???  Is there any tutorial out there that > explicitly explains everything for a newb like me? After several > round, I did successfully get form params to

Re: Creating instances of types not known at compile time

2011-05-10 Thread Meikel Brandmeyer
Hi, Am 10.05.2011 um 01:49 schrieb Simon Katz: > Passing the class object does exactly what I want. Then passing a factory function will work, too—without reflection. Much more performance impact then checking a short string for a dot. Sincerely Meikel -- You received this message because yo