(defn fac [n] (if (= n 1) 1 (* n fac (- n 1)))) your code tries to multiply n by function
this is correct: (defn fac [n] (if (= n 1) 1 (* n (fac (- n 1))))) On Aug 2, 8:11 am, recurve7 <dan.m...@gmail.com> wrote: > In browsing this group I see this topic has been brought up several > times over the past 3 years, so I apologize for revisiting it. > > I just downloaded Clojure and was excited to try it, but so far trying > to move beyond simple examples has often resulted in me making a > mistake that yields a Java exception that presumably is helpful to the > people who wrote Clojure, but doesn't provide me enough direction or > sense of what I did wrong. > > Maybe improvement has been made in Clojure's so far, but it's very > hard for me to think about working in a language that doesn't try to > identify on what line and where on that line it encountered an error > with my input. > > And when I get a Java-exception-style error from Clojure, it does me > no good to copy it in to Google, because I get all these responses > from Java programmers that have nothing to do with Clojure. > > I think it will be hard for Clojure to move beyond the fringe without > its own, unique, Google-searchable error messages and without helpful > positional error feedback for new people like me, who are maybe not > used to its syntax. > > Here's one example where recursion and lack of positional error > feedback make it hard for me, as someone coming from Java, to spot the > error (and seeing "ClassCastException" threw me off and had me > wondering where/how I had done something like that): > > user=> (defn fac [n] (if (= n 1) 1 (* n fac (- n 1)))) > #'user/fac > user=> (fac 3) > java.lang.ClassCastException: user$fac cannot be cast to > java.lang.Number (NO_SOURCE_FILE:0) > > I will check back in on Clojure to see if it becomes more friendly for > beginners and kids. Thanks for making it and working on it. =) -- 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