Literature or examples about "practical" functional program structure, architecture

2010-02-21 Thread soyrochus
Hi all, I've been playing around with Clojure off and on for a while now. I like it enough that I'm considering using it to implement an admin interface to MongoDB (a rather serious itch which I've been aching to scratch for a while now). Question is: how to tackle a program of considerable size?

Re: Testing Private Functions

2010-02-21 Thread Meikel Brandmeyer
Hi, On Feb 22, 5:40 am, Johnny Kwan wrote: > I'm trying to generalize it into a macro named use-private > > (defmacro >   #^{:private true} >   use-private >   [ns sym] >   `(def >      #^{:private true} >      ~sym (ns-resolve ~ns ~sym))) First some fixes: (defmacro #^{:private true} use-priv

Re: Newbie suggestion for an implementation - rosettacode pythagorean means

2010-02-21 Thread Meikel Brandmeyer
Hi, On Feb 22, 2:30 am, trptcolin wrote: > I do have a feeling I'm missing something really obvious that would > make my example simpler, so if anybody has any tips I'd be much > obliged! Using OP's code: (let [numbers (take 1000 (fibs))] (println (a-mean numbers) ">=" (g-mean numbers) ">="

Re: Newbie suggestion for an implementation - rosettacode pythagorean means

2010-02-21 Thread Meikel Brandmeyer
Hi, On Feb 22, 12:18 am, Johnny Kwan wrote: > I'm really new to Clojure, but I'm under the impression that reduce would > be better than apply, since I assume that apply would reify the entire > sequence at once, whereas reduce would consume the sequence one by one. > Could someone more familiar

Re: Common Lisp's append

2010-02-21 Thread Meikel Brandmeyer
Hi, On Feb 22, 7:22 am, Mike K wrote: > (defn join-vecs [v1 v2] >   (let [v2len (count v2)] >     (cond >      (zero? v2len) v1 >      (= v2len 1) (conj v1 (first v2)) >      true (recur (conj v1 (first v2)) (rest v2) > > (defn append [& vecs] (reduce join-vecs [] vecs)) > > user> (append '[

Re: Common Lisp's append

2010-02-21 Thread Mike K
Thanks, I ended up using Allegro via Lispbox here. http://www.gigamonkeys.com/lispbox/#download 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 ar

Re: Common Lisp's append

2010-02-21 Thread Mike K
On Feb 19, 6:23 am, Chouser wrote: > In Clojure, if you could use conj on a vector but instead use > concat on a list, you'll end up with code that is both > non-idiomatic and runs slower than necessary. I found the exercise of doing the equivalent with Clojure vectors pretty challenging. Give

Re: Newbie suggestion for an implementation - rosettacode pythagorean means

2010-02-21 Thread trptcolin
Aviad, Nice job! One nitpick is that won't work for infinite sequences, since reduce isn't lazy. If you wanted your definitions to work for arbitrary indexes of infinite sequences (like the Fibonacci numbers), you could provide sequences providing successive results for the input sequences. I d

Floyd-Warshall's APSP (All-Pairs-Shortest-Path) Algorithm

2010-02-21 Thread Volkan YAZICI
Hi, In case of need, here[1] is an optimized version of Floyd-Warshall's APSP (All-Pairs-Shortest-Path) algorithm in Clojure. Regards. [1] http://paste.lisp.org/display/95370 -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, s

Testing Private Functions

2010-02-21 Thread Johnny Kwan
Hi All, I'm trying to test some private functions using the Clojure convention of placing tests in a separate test- namespace. Of course, you can't reference private vars from other namespaces (please correct me if I'm wrong). Not knowing anything at all about how stuff is interned in Clojure

Re: Montreal Clojure User Group

2010-02-21 Thread Dan
I'm in. Should we go for a coffee to meet each other or something? On Sun, Feb 21, 2010 at 11:15 PM, Nicolas Buduroi wrote: > On Feb 21, 12:55 pm, Jeff Heon wrote: > > Would Montreal Clojurians be interested in starting a Clojure group? > > > > Or do you all piggyback on the Montreal/Scheme Lis

Re: Montreal Clojure User Group

2010-02-21 Thread Nicolas Buduroi
On Feb 21, 12:55 pm, Jeff Heon wrote: > Would Montreal Clojurians be interested in starting a Clojure group? > > Or do you all piggyback on the Montreal/Scheme Lisp User Group? That's a great idea, I'm in! I'd say that the Montreal Scheme/Lisp User Group doesn't seems to be quite active. I wonder

Re: Map transmogrification functions?

2010-02-21 Thread Sean Devlin
Actually, a combination of into & empty does the trick amazingly well... http://fulldisclojure.blogspot.com/2010/01/12-fn-proposal-same-multisame.html On Feb 21, 10:56 pm, Mike Meyer wrote: > In working through a recent project, I realized that Clojure has a > nice collection of functions for wo

Map transmogrification functions?

2010-02-21 Thread Mike Meyer
In working through a recent project, I realized that Clojure has a nice collection of functions for working with maps. However, it doesn't seem to have analogues of some of the important sequence tools (filter and map most noticeably, probably others). Given that map will take a map as a collectio

Re: generalize distinct

2010-02-21 Thread Wilson MacGyver
let me expand on my comment. What I meant is, the type of functionality you are adding into distinct, makes it feel less "distinct". to me. If I read what you are saying correctly, you want to be also be able to pass a set, so in addition to filter duplicate elements, it also will filter out anythi

Proxy

2010-02-21 Thread MiltondSilva
The code: (def app (proxy [SimpleApplication] [] (simpleInitApp [] (.attachChild (.getRoot this) ball-d) (.setLocalTranslation ground-d (com.g3d.math.Vector3f. 0 0 0)) (.attachChild (.getRoot this) ground-d)) (si

Re: generalize distinct

2010-02-21 Thread Wilson MacGyver
Any reason why you can't use distinct? http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/distinct On Feb 21, 2010 10:24 AM, "Eugen Dueck" wrote: Hi, Clojure is great! The gain in productivity from more low level languages like Java, but also more functional languages like

Re: Newbie suggestion for an implementation - rosettacode pythagorean means

2010-02-21 Thread Michael Kohl
On Mon, Feb 22, 2010 at 12:18 AM, Johnny Kwan wrote: > I'm really new to Clojure, but I'm under the impression that reduce would be > better than apply, since I assume that apply would reify the entire sequence > at once, whereas reduce would consume the sequence one by one. I was going by this

Re: Need advice on best concurrency model

2010-02-21 Thread Richard Newman
I'd be very thankful if I could get some advice here, sicne I am running out of ideas. You might be doing something wrong with the way you're arranging refs. I'll let others comment on that. One observation, though: parallelization doesn't always help. pmap runs your tasks on several thre

Re: Newbie suggestion for an implementation - rosettacode pythagorean means

2010-02-21 Thread Johnny Kwan
I'm really new to Clojure, but I'm under the impression that reduce would be better than apply, since I assume that apply would reify the entire sequence at once, whereas reduce would consume the sequence one by one. Could someone more familiar with the implementation weigh in on this? On Feb

Clojure Conference Dates

2010-02-21 Thread markgunnels
Have dates and location for the Clojure conference been picked? -- 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

Re: Newbie suggestion for an implementation - rosettacode pythagorean means

2010-02-21 Thread Michael Kohl
On Sun, Feb 21, 2010 at 9:41 PM, Aviad Reich wrote: > ANY comments will be great (including: this is all wrong - don't > post it). FWIW since I'm not exactly an expert on idiomatic Clojure either, I'd write h-mean like this: (defn h-mean [coll] (/ (count coll) (apply + (map #(/ 1 %) coll

Re: equality comparisons of finite and infinite collections?

2010-02-21 Thread Stuart Halloway
false, of course. :-) What would the post-patch result be of that operation? On Feb 20, 10:25 am, Stuart Halloway wrote: Current results vary based on arg order: (def xes (iterate #(str % "x") "x")) => #'user/xes ; infinite first ok (= xes ["x" "xx"]) => false ; finite first boom (= ["x" "

Newbie suggestion for an implementation - rosettacode pythagorean means

2010-02-21 Thread Aviad Reich
Hi everyone, being a newb to clojure, my ability to contribute to is still limited. However, I thought I'll try starting with something simple. http://rosettacode.org/wiki/Averages/Pythagorean_means seems straightforward enough, but since it's a comparative site, and implementations should be as

Re: Major changes in ClojureX

2010-02-21 Thread Michael Wood
On 21 February 2010 19:23, Brian Wolf wrote: > Michael Kohl wrote: >> >> I hope these mails don't annoy people, but from mails and Twitter I >> know that quite a few people actually seem to be using ClojureX, so I >> also wanted to post the information here: >> >> http://citizen428.net/archives/41

Re: Do I need to add "dosync" when I read the ref in this case

2010-02-21 Thread Michael Wood
On 21 February 2010 15:26, Michał Marczyk wrote: > On 21 February 2010 14:13, Michael Wood wrote: >> That does demonstrate the difference (or a difference), but I don't >> get 3 printlns. > > Ouch, I actually posted the wrong version of the function. Here's an > improvement in the context of a RE

Need advice on best concurrency model

2010-02-21 Thread Heinz N. Gies
Hi everyone, I've fiddled with making something concurrent and noticed I horribly failed. It gets 2-3 times slower when trying to work using pmap instead of map. What I want to do: I am working on a game, I have units, and a map fields (x,y coordinates). Now in every game turn each unit is allow

Montreal Clojure User Group

2010-02-21 Thread Jeff Heon
Would Montreal Clojurians be interested in starting a Clojure group? Or do you all piggyback on the Montreal/Scheme Lisp User Group? -- 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 th

Re: Major changes in ClojureX

2010-02-21 Thread Brian Wolf
Michael Kohl wrote: I hope these mails don't annoy people, but from mails and Twitter I know that quite a few people actually seem to be using ClojureX, so I also wanted to post the information here: http://citizen428.net/archives/415-Major-changes-in-ClojureX.html Cheers, Michael Hi, I t

Re: Do I need to add "dosync" when I read the ref in this case

2010-02-21 Thread Jack Fang
Thanks for you all On 2月21日, 下午10时26分, Michał Marczyk wrote: > On 21 February 2010 14:13, Michael Wood wrote: > > > That does demonstrate the difference (or a difference), but I don't > > get 3 printlns. > > Ouch, I actually posted the wrong version of the function. Here's an > improvement in th

Re: Do I need to add "dosync" when I read the ref in this case

2010-02-21 Thread Jack Fang
I try my code on my machine. 1. deref version (defn funk [r] (dosync (println "Start:" @r) (Thread/sleep 1) (println "End:" @r))) user> (.start (Thread. #(funk r))) Start: 1 nil user> (dosync (ref-set r 5)) Start: 5 End: 5 5 Actually, when I

Re: Simplenote Desktop App in Clojure

2010-02-21 Thread Joonas Pulakka
On Feb 20, 10:02 pm, Kasim wrote: > Hi, > I am a web developer and would like to write a small Desktop UI > application in Clojure for the popular Simplenote > app.http://simplenoteapp.com/ > I was wondering what UI framework I should use. Anyone out there care > to suggest one that works best wi

Major changes in ClojureX

2010-02-21 Thread Michael Kohl
I hope these mails don't annoy people, but from mails and Twitter I know that quite a few people actually seem to be using ClojureX, so I also wanted to post the information here: http://citizen428.net/archives/415-Major-changes-in-ClojureX.html Cheers, Michael -- You received this message beca

generalize distinct

2010-02-21 Thread Eugen Dueck
Hi, Clojure is great! The gain in productivity from more low level languages like Java, but also more functional languages like Ruby and Common LISP etc. amazes me every day. Like how adding a simple "map" in front of the count here: (count colls) changes the code from counting the number of colle

Re: Do I need to add "dosync" when I read the ref in this case

2010-02-21 Thread philipp siegmantel
You do not have to. Everything inside your dosync-block will happen atomically, meaning print-info will either see the values of source-account and dest-account before your transaction happened or after it's done his work. -- Ph. Siegmantel 2010/2/20 Jack Fang > Hi,all > > I am new to cloj

Re: Do I need to add "dosync" when I read the ref in this case

2010-02-21 Thread Michał Marczyk
On 21 February 2010 14:13, Michael Wood wrote: > That does demonstrate the difference (or a difference), but I don't > get 3 printlns. Ouch, I actually posted the wrong version of the function. Here's an improvement in the context of a REPL interaction: 1. ensure version: user> (defn funk [r]

Re: Do I need to add "dosync" when I read the ref in this case

2010-02-21 Thread Michael Wood
On 21 February 2010 13:47, Michał Marczyk wrote: > On 21 February 2010 09:37, Michael Wood wrote: >> (defn print-info [] >>  (let [[src dst] (dosync >>                    (ensure source-account) >>                    (ensure dest-account) >>                   �...@source-account @dest-account])]

Re: Do I need to add "dosync" when I read the ref in this case

2010-02-21 Thread Michael Wood
On 21 February 2010 12:55, Jarkko Oranen wrote: >> >> But surely in this case you could do: >> >> (defn print-info [] >>   (let [[src dst] (dosync [...@source-account @dest-account])] >>     (println src) >>     (println dst))) >> >> or maybe: >> >> (defn print-info [] >>   (let [[src dst] (dosync

Re: Clojure on Go

2010-02-21 Thread Angel Java Lopez
Hi people! Clojure could be compiled over another language, using another base library. This could be the "litmut test" for Clojure independence. I guess Clojure-CLR is an step towards such target. For now, Clojure consumes two library classes and VM: Java and .NET. It's good, IMO, to have such

Re: Do I need to add "dosync" when I read the ref in this case

2010-02-21 Thread Michał Marczyk
On 21 February 2010 09:37, Michael Wood wrote: > (defn print-info [] >  (let [[src dst] (dosync >                    (ensure source-account) >                    (ensure dest-account) >                   �...@source-account @dest-account])] >    (println src) >    (println dst))) This can be simp

Re: Do I need to add "dosync" when I read the ref in this case

2010-02-21 Thread Jarkko Oranen
> > But surely in this case you could do: > > (defn print-info [] >   (let [[src dst] (dosync [...@source-account @dest-account])] >     (println src) >     (println dst))) > > or maybe: > > (defn print-info [] >   (let [[src dst] (dosync >                     (ensure source-account) >            

Re: Do I need to add "dosync" when I read the ref in this case

2010-02-21 Thread Michael Wood
On 21 February 2010 09:24, ataggart wrote: > On Feb 20, 6:07 am, Jack Fang wrote: >>    Suppose the transfer-money and print-info are run in different >> thread. With the current Clojure STM, is it possible that print-info >> prints the old source-account information and modified dest-account >>