Furthermore, The syntax you're using is not correct. If you want to define functions inside your function ex1_17, use letfn.
Something along the line: (defn ex1_17 [] (letfn [(double [x] (+ x x)) (halve [x] (/ x 2)) (mult [a b] (cond (= b 0) 0 (even? b) (* (double a) (halve b)) :else (+ a (* a (- b 1)))))] (println (mult 5 5)))) I prefer not to mess with the default function so i redefined your * by mult Antoine 2012/5/17 eniotna <eniotn...@gmail.com> > Hi, > > Look at your parenthesis. > You did not close your first function. > > Antoine > > > 2012/5/17 Sargash <gerby...@gmail.com> > >> Hi! >> >> I have a problem. With that code: >> >> ; ======================================= >> ; ex 1.17 multiply >> (defn ex1_17 [] >> (defn double [x] (+ x x)) >> (defn halve [x] (/ x 2)) >> >> (defn * [a b] >> (cond >> (= b 0) 0 >> (even? b) (* (double a) (halve b)) >> :else (+ a (* a (- b 1))))) >> >> (println (* 5 5)) >> ) >> (ex1_17 ) >> >> I gave that exception: >> >> Exception in thread "main" java.lang.NullPointerException, compiling: >> (D:\workprivate\ll\1\src\first.clj:3) >> at clojure.lang.Compiler.analyzeSeq(Compiler.java:6462) >> at clojure.lang.Compiler.analyze(Compiler.java:6262) >> at clojure.lang.Compiler.analyzeSeq(Compiler.java:6443) >> at clojure.lang.Compiler.analyze(Compiler.java:6262) >> at clojure.lang.Compiler.access$100(Compiler.java:37) >> at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:518) >> at clojure.lang.Compiler.analyzeSeq(Compiler.java:6455) >> at clojure.lang.Compiler.analyze(Compiler.java:6262) >> at clojure.lang.Compiler.analyze(Compiler.java:6223) >> at clojure.lang.Compiler.eval(Compiler.java:6515) >> at clojure.lang.Compiler.load(Compiler.java:6952) >> at clojure.lang.Compiler.loadFile(Compiler.java:6912) >> at clojure.main$load_script.invoke(main.clj:283) >> at clojure.main$script_opt.invoke(main.clj:343) >> at clojure.main$main.doInvoke(main.clj:427) >> at clojure.lang.RestFn.invoke(RestFn.java:408) >> at clojure.lang.Var.invoke(Var.java:415) >> at clojure.lang.AFn.applyToHelper(AFn.java:161) >> at clojure.lang.Var.applyTo(Var.java:532) >> at clojure.main.main(main.java:37) >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >> at >> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: >> 39) >> at >> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java: >> 25) >> at java.lang.reflect.Method.invoke(Method.java:597) >> at com.intellij.rt.execution.application.AppMain.main(AppMain.java: >> 120) >> Caused by: java.lang.NullPointerException >> at clojure.lang.Compiler$ObjExpr.emitVar(Compiler.java:4774) >> at clojure.lang.Compiler$DefExpr.emit(Compiler.java:418) >> at clojure.lang.Compiler$BodyExpr.emit(Compiler.java:5659) >> at clojure.lang.Compiler$FnMethod.doEmit(Compiler.java:5215) >> at clojure.lang.Compiler$FnMethod.emit(Compiler.java:5069) >> at clojure.lang.Compiler$FnExpr.emitMethods(Compiler.java:3600) >> at clojure.lang.Compiler$ObjExpr.compile(Compiler.java:4233) >> at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3732) >> at clojure.lang.Compiler.analyzeSeq(Compiler.java:6453) >> ... 24 more >> >> Could you tell me where I wrong? >> >> -- >> 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