I actually believe it will throw an overflow exception if col contains
more than Integer.MAX_VALUE elements. Hard to confirm without getting
bored though.

-- Aaron

On Sat, Jun 19, 2010 at 10:19 PM, Rob Lachlan <robertlach...@gmail.com> wrote:
> Actually, Mike, your two functions work just fine.  (Equal branch).
> Mind you I checked that out over two hours ago, so this information
> might be out of date.
>
> Rob
>
> On Jun 19, 6:59 pm, Mike Meyer <mwm-keyword-googlegroups.
> 620...@mired.org> wrote:
>> On Sat, 19 Jun 2010 20:40:13 -0400
>>
>> David Nolen <dnolen.li...@gmail.com> wrote:
>> > Mark and Mike you fail to address my deeper question.
>>
>> Maybe because you've failed to ask in your hurry to claim code is
>> non-idiomatic or calling our example rhetoric.
>>
>> > I've been using
>> > many different Clojure libraries all day long with the latest equals
>> > branch. Guess
>> > what?
>>
>> > No loop/recur bugs.
>>
>> I wouldn't expect anything else, for two reasons:
>>
>> 1) Most clojure code doesn't deal with integers - it deals with
>>    symbols, strings, and sequences. Hence it won't run into this problem.
>> 2) The libraries are generally written by experienced users who will
>>    have tweaked them for performance - meaning they've typed hinted
>>    them, and thus avoided this problem.
>>
>> > When you guys start postIng your broken code that has this problem
>> > then people can start believing it is an issue for working code.
>>
>> I guess a perfectly natural expression of a reasonable algorithm that
>> works under 1.1 and doesn't on the equal branch isn't "broken" because
>> it's the same function we've been using all along. So here's some new
>> examples, pulled in sequence from some of my combinatorics code:
>>
>> (defn count-in [value col]
>>    (loop [value value col col res 0]
>>       (if (empty? col)
>>           res
>>           (recur value (rest col) (if (= (first col) value) (inc res) 
>> res)))))
>>
>> (defn ones-n-zeros [vectors]
>>   (loop [vectors vectors m-zeros 0 m-ones 0]
>>      (if (empty? vectors)
>>          [m-zeros m-ones]
>>          (let [data (first vectors)
>>                zeros (count-in 0 data)
>>                ones (count-in 1 data)]
>>             (recur (rest vectors) (if (> zeros ones) (inc m-zeros) m-zeros)
>>                                   (if (> ones zeros) (inc m-ones) 
>> m-ones))))))
>>
>> No, I haven't verified it fails - I've given up trying to check out
>> the branch, as hg convert failed, and git (after reinstalling over a
>> broken version) keeps complaining about "warning: remote HEAD refers
>> to nonexistent ref, unable to checkout." However, my reading of the
>> proposal is that the inc's here will cause the same problems as the
>> *'s in the perfectly reasonable factorial example.
>>
>> Now go ahead and claim that that's not very good code, because an
>> expert would have type hinted it or written it with map & apply or
>> some such, or that there's a contrib library somewhere with a faster
>> implementation of count-in in it. That, after all, is your rhetoric.
>>
>> But that's my point. I want the *obvious* code to work. I'll worry
>> about making it fast after I've made it right. If you want a read-only
>> language that requires an expert to get working code in a reasonable
>> amount of time, you can always write in Perl or C.
>>
>>        <mike
>> --
>> Mike Meyer <m...@mired.org>          http://www.mired.org/consulting.html
>> Independent Network/Unix/Perforce consultant, email for more information.
>>
>> O< ascii ribbon campaign - stop html mail -www.asciiribbon.org
>
> --
> 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 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

Reply via email to