(defn- subexpressions-of-sum** [[n p] terms] (let-print [sum (cons '+ (map #(factor-term % n p) terms)) prod (rest (make-product* n p))] (cons sum (map #(cons '* (cons sum (rest %))) (concat prod (subexpressions-of-product prod))))))
I look at the above, and something stupid just entered into my thought. What happened when this situation occurs (cons sum ())? I hope that's not possible with your code. Regards, Emeka On Sun, Jul 5, 2009 at 6:01 AM, John Harrop <jharrop...@gmail.com> wrote: > > I had this: > > (defn- subexpressions-of-sum** [[n p] terms] > (let-print [sum (cons '+ (map #(factor-term % n p) terms)) > prod (rest (make-product* n p))] > (concat [sum] (subexpressions-of-product (cons sum prod))))) > > in a source file with other definitions. Load-file worked. I then > changed it to this: > > (defn- subexpressions-of-sum** [[n p] terms] > (let-print [sum (cons '+ (map #(factor-term % n p) terms)) > prod (rest (make-product* n p))] > (cons sum > (map #(cons '* (cons sum (rest %))) > (concat prod (subexpressions-of-product prod)))))) > > and got: > > #<CompilerException java.lang.ClassFormatError: Unknown constant tag > 32 in class file com/mycompany/myfile$eval__14598 (NO_SOURCE_FILE:0)> > > when I tried to do a load-file. > > That function definition was the ONLY thing I changed, but I'm at a > loss to find any kind of error in it. Delimiters balance, all of the > referenced functions exist, basically there's nothing wrong. > > The full exception trace, which required evaluating (.printStackTrace > (.getCause *e)) at the repl, is: > > java.lang.ClassFormatError: Unknown constant tag 32 in class file > com/mycompany/myfile$eval__14598 > at java.lang.ClassLoader.defineClass1(Native Method) > at java.lang.ClassLoader.defineClass(ClassLoader.java:621) > at java.lang.ClassLoader.defineClass(ClassLoader.java:466) > at > clojure.lang.DynamicClassLoader.defineClass(DynamicClassLoader.java:42) > at clojure.lang.Compiler$FnExpr.getCompiledClass(Compiler.java:3417) > at clojure.lang.Compiler$FnExpr.eval(Compiler.java:3428) > at clojure.lang.Compiler.eval(Compiler.java:4531) > at clojure.core$eval__3990.invoke(core.clj:1728) > at > clojure.main$repl__5813$read_eval_print__5825.invoke(main.clj:176) > at clojure.main$repl__5813.doInvoke(main.clj:193) > at clojure.lang.RestFn.invoke(RestFn.java:548) > at > org.enclojure.repl.main$create_clojure_repl__53$repl_thread_fn__55.invoke(main.clj:96) > at clojure.lang.AFn.run(AFn.java:37) > at java.lang.Thread.run(Thread.java:619) > > It does not point to any line of my source file. > > Perhaps the rewritten version of the function provokes a compiler bug? > If there is a known bug that would cause this, let me know of the > known workaround. If there is an error in the second version of my > function, let me know. (It has intentionally different semantics from > the first version, so that's not an error in and of itself.) > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---