Re: Question on eliminating recur

2011-07-13 Thread FL
On Jul 13, 1:16 am, Christian Marks <9fv...@gmail.com> wrote: > Thank you. Based on this I've simplified the code further. You could combine the test for a cycle leader with the cycle length count--but your original code, which calculates cycle lengths only if a cycle leader is identified, is mo

Re: Question on eliminating recur

2011-07-12 Thread Christian Marks
On Jul 10, 10:16 pm, FL wrote: \> If you replace your ... > > (defn order-perm [perm] > >         (let [n (count perm)] ... > with the more compact > > (defn order-permo [perm] >              (reduce (fn [order i] (if (= i (next-cycle-leader perm i)) >                              

Re: Question on eliminating recur

2011-07-10 Thread FL
On Jul 9, 8:58 am, Christian Marks <9fv...@gmail.com> wrote: > The clojure code below applies the constant space algorithm ... of C. J. Gower ... to the computation of the order of a permutation [Knuth, D. E., “Selected Papers on Analysis of > Algorithms,” CSLI Lecture Notes Number 102, CSLI Pub

Re: Question on eliminating recur

2011-07-10 Thread Joost
On Jul 10, 7:15 am, Michael Gardner wrote: > > I think Christian wanted to know *why* one "should" eliminate recur. I can't > think of a reason to avoid it myself, though I also don't recall hearing any > recommendations against using recur. Just my two cents, but the main reason to consider ma

Re: Question on eliminating recur

2011-07-09 Thread Michael Gardner
On Jul 9, 2011, at 8:47 AM, Brian Hurt wrote: > If there is an obvious way to rewrite the code using doseq or fold (or reduce > or map or etc), then yes- you should do it. However, if this way to rewrite > the code isn't obvious in 10 seconds of thought, don't worry about it. Use > loop/recur.

Re: Question on eliminating recur

2011-07-09 Thread Brian Hurt
On Sat, Jul 9, 2011 at 8:58 AM, Christian Marks <9fv...@gmail.com> wrote: > > I'm using recur, however some clojure programmers inform me that recur > "should" be eliminated in favor of doseq or fold. I see nothing wrong > with recur myself--am I missing > something? > > If there is an obvious way

Question on eliminating recur

2011-07-09 Thread Christian Marks
The clojure code below applies the constant space algorithm to apply a permutation to an array of C. J. Gower to the computation of the order of a permutation [Knuth, D. E., “Selected Papers on Analysis of Algorithms,” CSLI Lecture Notes Number 102, CSLI Publications, (2000), p 4]. The order of a p