Re: From Java to Clojure

2009-07-11 Thread Patrik Fredriksson
On Fri, Jul 10, 2009 at 3:04 PM, Benjamin Stewart wrote [...] > (defn count-hash-vals [coll] > ;; apply hash-map mapcat was the first thing > ;; I found that worked here... better options ++welcome. >               (apply hash-map >                      (mapcat #(let [[k v] %] >                

Re: From Java to Clojure

2009-07-11 Thread Patrik Fredriksson
Sean Devlin wrote: > If you're running "edge" Clojure, and not 1.0, I'd recommend writing > the tests in Clojure next, using the clojure.test namespace. I'd like to keep it 1.0 for now, so the tests are in clojure.contrib.test-is. But I'll make note, or add an alternative version for clojure.test.

Re: From Java to Clojure

2009-07-10 Thread Sean Devlin
To quote Benjamin Stewart: ;; the body of this fn should probably be a macro that takes ;; any number of comparisons and or-chain them correctly such that ;; ties cascade to the next comparison and obviates the need for ;; explicit calls to false-if-zero. Does it already exist? This could be do

Re: From Java to Clojure

2009-07-10 Thread Benjamin Stewart
I've been playing along at home for awhile now, but this example hit close to home -- I've written variations on this code countless times in perl, and figured I'd take a stab at clojuring it while also taking advantage of clojure.contrib.seq-utils's very useful to the matter at hand group-by. I'

Re: From Java to Clojure

2009-07-09 Thread Chouser
On Thu, Jul 9, 2009 at 7:31 AM, Patrik Fredriksson wrote: > > My shot at a Clojure implementation, with inspiration from a previous > post in this group on a similar problem: > > (ns step3.pnehm.clojure-orderer >  (:gen-class >    :name step3.pnehm.ClojureOrderer >    :implements [pnehm.Orderer] >

Re: From Java to Clojure

2009-07-09 Thread Sean Devlin
Okay, since you DO call the Clojure code from Java, I like what you did very much. If you're running "edge" Clojure, and not 1.0, I'd recommend writing the tests in Clojure next, using the clojure.test namespace. Sean On Jul 9, 10:16 am, Patrik Fredriksson wrote: > The idea is to gradually, ov

Re: From Java to Clojure

2009-07-09 Thread Patrik Fredriksson
The idea is to gradually, over a few steps, move from a Java implementation to a pure Clojure implementation. A this step the Clojure implementation is called by the Java JUnit-test (see complete test below). In the last step, the Java-references will be removed from the Clojure implementation and

Re: From Java to Clojure

2009-07-09 Thread Sean Devlin
One question on design intent before feedback. Is your intent to have this Clojure code called by Java code later? On Jul 9, 7:31 am, Patrik Fredriksson wrote: > Hi! > > I started to look closer at Clojure after Rich Hickey's presentation > at QCon London in March, this is my first post. I spe