Hi,

Nice solution, but don't we need to distinguish between the array types ? 
(cf. inline comment below )

Cheers,

B.

On Monday, February 25, 2013 12:08:39 AM UTC+1, Aria Haghighi wrote:
>
> […] Here, I think it's a macro you'll probably use all over the place, 
> arr-max, which will find the largest value of an expression looping over an 
> array's index and values. Then lcs is just nested uses of arr-max that I 
> think is pretty reasonable. The thing which clutters the remaining code are 
> the prev/cur swapping which I don't have a slick way of handling.   
>
> (defmacro arr-max 
>   "return maximum value of `expr` over the indices
>    and values of array `arr`, where `idx-symb` and `val-symb`
>    are bound to index and values of `arr`"
>   [arr idx-symb val-symb expr]
>   `(let [arr# ~arr
>          n# (alength arr#)]
>      (loop [~idx-symb 0 max-val# java.lang.Long/MIN_VALUE]
>
>
Shouldn't we select java.lang.Double/NEGATIVE_INFINITY for arrays of 
Doubles ?

       (if (= ~idx-symb n#)
>          max-val#
>          (let [~val-symb (aget arr# ~idx-symb)
>                val# ~expr]
>            (recur (inc ~idx-symb)
>                   (if (> val# max-val#)
>                     val# max-val#)))))))
>  
>
>

-- 
-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to