I handled preconditions, and added a new patch. Thanks, Ambrose
On Sat, Jul 26, 2014 at 11:52 PM, Michael O'Keefe < michael.p.oke...@gmail.com> wrote: > Nice work everyone on the patches -- I'm very impressed! > > There's been a couple of questions about how to interpret this. My thought > is we should try and mimic an explicit recursion: > > In other words: > > (defn g > [xs acc] > {:pre [(or (nil? xs) (sequential? xs)) (number? acc)] > :post [(number? %)]} > (if (seq xs) > (recur (next xs) (+ (first xs) acc)) > acc)) > > ... should act like: > > (defn g3 > [xs acc] > {:pre [(or (sequential? xs) (nil? xs)) (number? acc)] > :post [(number? %)]} > (if (seq xs) > (g3 (next xs) (+ (first xs) acc)) > acc)) > > (g [1 2 3] 0) > (g3 [1 2 3] 0) > > ... where g3 actually works (but runs the risk of blowing the stack). > > Michael > > > On Saturday, July 26, 2014 9:34:48 AM UTC-6, Ambrose Bonnaire-Sergeant > wrote: > >> Doh! I forgot preconditions :D >> >> Fixing.. >> Ambrose >> >> >> On Sat, Jul 26, 2014 at 11:30 PM, Ambrose Bonnaire-Sergeant < >> abonnair...@gmail.com> wrote: >> >>> Hi Steve, >>> >>> I think I got it right, please have a look: http://dev.clojure.org/ >>> jira/browse/CLJ-1475 >>> >>> Thanks, >>> Ambrose >>> >>> >>> On Sat, Jul 26, 2014 at 10:38 PM, Ambrose Bonnaire-Sergeant < >>> abonnair...@gmail.com> wrote: >>> >>>> I'll give it a shot.. >>>> >>>> >>>> On Sat, Jul 26, 2014 at 9:59 PM, Steve Miner <steve...@gmail.com> >>>> wrote: >>>> >>>>> I'm giving up on this bug. My approach was adding too much complexity >>>>> to handle an edge case. Hacking the fn macro is not as easy as it looks. >>>>> :-) >>>>> >>>>> I recommend the loop work-around if you run into this problem. Or >>>>> refactor the recursive code into a separate function and call it from >>>>> another function with the :pre and :post conditions in the non-recursive >>>>> function. >>>>> >>>>> http://dev.clojure.org/jira/browse/CLJ-1475 >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Clojure" group. >>>>> To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com. >>>>> >>>>> For more options, visit https://groups.google.com/d/optout. >>>>> >>>> >>>> >>> >> -- > 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/d/optout. > -- 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/d/optout.