Re: clojure.spec regression bug for 1.9.0-alpha6
Maybe, the following is the same reason. ``` (defn ranged-rand ;; BROKEN! "Returns random integer in range start <= rand < end" [start end] (+ start (rand-int (- start end (s/fdef ranged-rand :args (s/and (s/cat :start integer? :end integer?) #(< (:start %) (:end %))) :ret integer? :fn (s/and #(>= (:ret %) (-> % :args :start)) #(< (:ret %) (-> % :args :end (ranged-rand 8 10) ;;=> ExceptionInfo Call to #'spec-example.core/ranged-rand did not conform to spec: ;;=> At: [:fn] val: {:args {:start 8, :end 10}, :ret 7} fails predicate: (>= (:ret %) (-> % :args :start)) ;;=> :clojure.spec/args (8 10) ;;=> clojure.core/ex-info (core.clj:4617) (println *clojure-version*) ;;=> {:major 1, :minor 9, :incremental 0, :qualifier alpha1} (s/instrument #'ranged-rand) (ranged-rand 8 10) ;;=> 7 (println *clojure-version*) ;;=> {:major 1, :minor 9, :incremental 0, :qualifier alpha6} ``` > user=> (require '[clojure.spec :as s]) > user=> (defn dummy [x] (if x "yes" "no")) > user=> (s/fdef dummy > #_=> :args (s/cat :x integer?) > #_=> :ret integer?) > user=> (s/instrument #'dummy) > user=> (dummy 3) (println *clojure-version*) > ExceptionInfo Call to #'user/dummy did not conform to spec: > val: "yes" fails at: [:ret] predicate: integer? > :clojure.spec/args (3) > clojure.core/ex-info (core.clj:4703) > {:major 1, :minor 9, :incremental 0, :qualifier alpha5} > > ;--- > > user=> (dummy 3) (println *clojure-version*) > "yes" > {:major 1, :minor 9, :incremental 0, :qualifier alpha6} > -- 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.
JDK versions for clojure 1.7
Hi, I'd like to ask a question. Which versions of JDK does Clojure 1.7 support ? 1.6 or later, 1.7 or later ? Thanks, MH -- 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.
Re: a simple question about Arrays.asList
Hi Mauricio, The into-array worked fine ! Thanks, MH > There are many things that need to be understood in a call like this. > > First of all, that method receives an array as its argument: > https://docs.oracle.com/javase/7/docs/api/java/util/Arrays.html#asList(T...) > > From your first example I think you are trying to translate to clojure the > following java call: > > java.util.Arrays.asList(1, 2, 3); > > In java this is a varargs call, which means java will change the call to > one using an array as the parameter > (http://docs.oracle.com/javase/8/docs/technotes/guides/language/varargs.html). > > So, in order to make that call we need to wrap those arguments in an > array. The easiest way to do this would be to wrap the arguments in a > vector an turn that into an array: > > user> (java.util.Arrays/asList (into-array [1 2 3])) > [1 2 3] > > If you don't already have a sequence (the vector in the previous example) > then you can use a function to do the work: > > user> (defn as-list [& args] (java.util.Arrays/asList (into-array args))) > #'user/as-list > user> (as-list 1 2 3) > [1 2 3] > user> (type (as-list 1 2 3)) > java.util.Arrays$ArrayList > > > Cheers, > Mauricio > -- 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.
Re: a simple question about Arrays.asList
Hi Aaron, Thank you for your reply. I was able to understand. > Why are you trying to use Arrays#asList btw? There are probably better ways to do what you're trying to do. I just wanted to test reify to implement java.util.Comarator as follows: (java.util.Collections/sort x (reify java.util.Comparator (compare [this x y] (Integer/compare x y Initially, I gave a test data like this. (def x (doto (java.util.ArrayList.) (.add 3)(.add 1)(.add 2))) However, I thought asList is better. Are there better ways to do ? Thanks, MH Since Arrays.asList is a variadic method, the Java compiler is magically > creating an array behind the scenes for you when you write Java code > invoking it. > > Clojure does variadic functions differently for native clojure code. > > To do interop with a Java variadic method have to create the array > yourself: > (java.util.Arrays/asList (make-array Object 1 2 3)) > > Why are you trying to use Arrays#asList btw? There are probably better > ways to do what you're trying to do. > > --Aaron > > On Thu, May 21, 2015 at 5:08 PM, webber > > wrote: > >> I am trying to use java.util.Arrays/asList in Clojure. >> >> (java.util.Arrays/asList 1 2 3) >> >> CompilerException java.lang.IllegalArgumentException: No matching method: >> asList, compiling:(NO_SOURCE_PATH:1:1) >> >> (java.util.Arrays/asList 1) >> >> ClassCastException java.lang.Long cannot be cast to [Ljava.lang.Object; >> user/eval7195 (NO_SOURCE_FILE:1) >> >> What should I do to work it ? >> >> -- >> 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.
a simple question about Arrays.asList
I am trying to use java.util.Arrays/asList in Clojure. (java.util.Arrays/asList 1 2 3) CompilerException java.lang.IllegalArgumentException: No matching method: asList, compiling:(NO_SOURCE_PATH:1:1) (java.util.Arrays/asList 1) ClassCastException java.lang.Long cannot be cast to [Ljava.lang.Object; user/eval7195 (NO_SOURCE_FILE:1) What should I do to work 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 --- 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.
Re: [ANN] Chestnut 0.7.0
I've commented chestnut/lein-template from the ~/.lein/projects.clj as follows, then it worked. It worked using 0.6.0 if there was the chestnut/lein-template definition. Was my usage wrong ? {:user {:plugins [ [lein-try "0.4.3"] ;[lein-pprint "1.1.1"] [lein-ancient "0.6.4" :exclusions [org.clojure/core.cache]] [lein-bikeshed "0.2.0"] [lein-ritz "0.7.0"] [lein-marginalia "0.8.0"] [http-kit/lein-template "1.0.0-SNAPSHOT"] [cider/cider-nrepl "0.9.0-SNAPSHOT"] [cljs-complete "0.1.1"] ;;[chestnut/lein-template "0.7.0"] ;;[chestnut/lein-template "0.6.0"] ] :dependencies [;;[nrepl-inspect "0.4.1"] [compliment "0.2.0"] [ritz/ritz-nrepl-middleware "0.7.0"] [cider/cider-nrepl "0.9.0-SNAPSHOT"] [alembic "0.2.1"] [org.clojure/tools.nrepl "0.2.7"] ] :repl-options {:nrepl-middleware [cider.nrepl.middleware.classpath/wrap-classpath cider.nrepl.middleware.complete/wrap-complete cider.nrepl.middleware.info/wrap-info cider.nrepl.middleware.inspect/wrap-inspect cider.nrepl.middleware.stacktrace/wrap-stacktrace cider.nrepl.middleware.trace/wrap-trace ]} }} Makoto > I ran into this same behavior, and then I realized it only happened if I > run the "lein new" command if I'm *already in* a previously-created > project created with "lein new chestnut". I'm guessing that something in > the generated project.clj interferes some of the lein new behavior somehow. > At any rate, running lein new in a directory without a project.clj file in > it is working fine for me. > > Tim > > On Saturday, March 7, 2015 at 5:38:41 AM UTC-5, webber wrote: >> >> I tested the v 0.7.0 of chestnut and I encountered the following error. >> The v 0.6.0 works fine. >> >> $ lein new chestnut test-app >> Retrieving chestnut/lein-template/0.7.0/lein-template-0.7.0.pom from >> clojars >> Retrieving chestnut/lein-template/0.7.0/lein-template-0.7.0.jar from >> clojars >> Exception in thread "main" java.lang.ExceptionInInitializerError >> at java.lang.Class.forName0(Native Method) >> at java.lang.Class.forName(Class.java:270) >> at clojure.lang.RT.loadClassForName(RT.java:2093) >> at clojure.lang.RT.load(RT.java:430) >> at clojure.lang.RT.load(RT.java:411) >> at clojure.core$load$fn__5066.invoke(core.clj:5641) >> at clojure.core$load.doInvoke(core.clj:5640) >> at clojure.lang.RestFn.invoke(RestFn.java:408) >> at clojure.core$load_one.invoke(core.clj:5446) >> at clojure.core$load_lib$fn__5015.invoke(core.clj:5486) >> at clojure.core$load_lib.doInvoke(core.clj:5485) >> at clojure.lang.RestFn.applyTo(RestFn.java:142) >> at clojure.core$apply.invoke(core.clj:626) >> at clojure.core$load_libs.doInvoke(core.clj:5524) >> at clojure.lang.RestFn.applyTo(RestFn.java:137) >> at clojure.core$apply.invoke(core.clj:626) >> at clojure.core$require.doInvoke(core.clj:5607) >> at clojure.lang.RestFn.invoke(RestFn.java:421) >> at stencil.core$loading__4958__auto__.invoke(core.clj:1) >> at stencil.core__init.load(Unknown Source) >> at stencil.core__init.(Unknown Source) >> at java.lang.Class.forName0(Native Method) >> at java.lang.Class.forName(Class.java:270) >> at clojure.lang.RT.loadClassForName(RT.java:2093) >> at clojure.lang.RT.load(RT.java:430) >> at clojure.lang.RT.load(RT.java:411) >> at clojure.core$load$fn__5066.invoke(core.clj:5641) >> at clojure.core$load.doInvoke(core.clj:5640) >> at clojure.lang.RestFn.invoke(RestFn.java:408) >> at clojure.core$load_one.invoke(core.clj:5446) >> at clojure.core$load_lib$fn__5015.invoke(core.clj:5486) >> at clojure.core$load_lib.doInvoke(core.clj:5485) >> at clojure.lang.RestFn.applyTo(RestFn.java:142) >> at clojure.core$apply.invoke(core.clj:626) >> at clojure.core$load_libs.doInvoke(core.clj:5524) >> at clojure.lang.RestFn.applyTo(RestFn.java:137) >> at clojure.core$apply.invoke(core.clj:626) >> at clojure.core$require.doInvoke(core.clj:5607) >> at clojure.lang.RestFn.invoke(RestFn.java:512) >> at leiningen.new.templates$loading__4958__auto__.in
Re: [ANN] Chestnut 0.7.0
I tested the v 0.7.0 of chestnut and I encountered the following error. The v 0.6.0 works fine. $ lein new chestnut test-app Retrieving chestnut/lein-template/0.7.0/lein-template-0.7.0.pom from clojars Retrieving chestnut/lein-template/0.7.0/lein-template-0.7.0.jar from clojars Exception in thread "main" java.lang.ExceptionInInitializerError at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:270) at clojure.lang.RT.loadClassForName(RT.java:2093) at clojure.lang.RT.load(RT.java:430) at clojure.lang.RT.load(RT.java:411) at clojure.core$load$fn__5066.invoke(core.clj:5641) at clojure.core$load.doInvoke(core.clj:5640) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invoke(core.clj:5446) at clojure.core$load_lib$fn__5015.invoke(core.clj:5486) at clojure.core$load_lib.doInvoke(core.clj:5485) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invoke(core.clj:626) at clojure.core$load_libs.doInvoke(core.clj:5524) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invoke(core.clj:626) at clojure.core$require.doInvoke(core.clj:5607) at clojure.lang.RestFn.invoke(RestFn.java:421) at stencil.core$loading__4958__auto__.invoke(core.clj:1) at stencil.core__init.load(Unknown Source) at stencil.core__init.(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:270) at clojure.lang.RT.loadClassForName(RT.java:2093) at clojure.lang.RT.load(RT.java:430) at clojure.lang.RT.load(RT.java:411) at clojure.core$load$fn__5066.invoke(core.clj:5641) at clojure.core$load.doInvoke(core.clj:5640) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invoke(core.clj:5446) at clojure.core$load_lib$fn__5015.invoke(core.clj:5486) at clojure.core$load_lib.doInvoke(core.clj:5485) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invoke(core.clj:626) at clojure.core$load_libs.doInvoke(core.clj:5524) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invoke(core.clj:626) at clojure.core$require.doInvoke(core.clj:5607) at clojure.lang.RestFn.invoke(RestFn.java:512) at leiningen.new.templates$loading__4958__auto__.invoke(templates.clj:11) at leiningen.new.templates__init.load(Unknown Source) at leiningen.new.templates__init.(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:270) at clojure.lang.RT.loadClassForName(RT.java:2093) at clojure.lang.RT.load(RT.java:430) at clojure.lang.RT.load(RT.java:411) at clojure.core$load$fn__5066.invoke(core.clj:5641) at clojure.core$load.doInvoke(core.clj:5640) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invoke(core.clj:5446) at clojure.core$load_lib$fn__5015.invoke(core.clj:5486) at clojure.core$load_lib.doInvoke(core.clj:5485) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invoke(core.clj:626) at clojure.core$load_libs.doInvoke(core.clj:5524) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invoke(core.clj:626) at clojure.core$require.doInvoke(core.clj:5607) at clojure.lang.RestFn.invoke(RestFn.java:512) at leiningen.new$loading__4958__auto__.invoke(new.clj:1) at leiningen.new__init.load(Unknown Source) at leiningen.new__init.(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:270) at clojure.lang.RT.loadClassForName(RT.java:2093) at clojure.lang.RT.load(RT.java:430) at clojure.lang.RT.load(RT.java:411) at clojure.core$load$fn__5066.invoke(core.clj:5641) at clojure.core$load.doInvoke(core.clj:5640) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invoke(core.clj:5446) at clojure.core$load_lib$fn__5015.invoke(core.clj:5486) at clojure.core$load_lib.doInvoke(core.clj:5485) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invoke(core.clj:626) at clojure.core$load_libs.doInvoke(core.clj:5524) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invoke(core.clj:626) at clojure.core$require.doInvoke(core.clj:5607) at clojure.lang.RestFn.invoke(RestFn.java:408) at leiningen.core.utils$require_resolve.invoke(utils.clj:80) at leiningen.core.utils$require_resolve.invoke(utils.clj:83) at leiningen.core.main$lookup_task_var.invoke(main.clj:68) at leiningen.core.main$pass_through_help_QMARK_.invoke(main.clj:78) at leiningen.core.main$task_args.invoke(main.clj:81) at leiningen.core.main$resolve_and_apply.invoke(main.clj:318) at leiningen.core.main$_main$fn__6160.invoke(main.clj:392) at leiningen.core.main$_main.doInvoke(main.clj:385) at clojure.lang.RestFn.invoke(RestFn.java:436) at clojure.lang.Var.invoke(Var.java:388) at clojure.lang.AFn.applyToHelper(AFn.java:160) at clojure.lang.Var.applyTo(Var.java:700) at clojure.core$apply.invoke(core.clj:624) at clojure.main$main_opt.invoke(main.clj:315) at clojure.main$main.doInvoke(main.clj:420) at clojure.lang.RestFn.invoke(RestFn.java:482) at clojure.lang.Var.invoke(Var.
Re: convert between PersistentArrayMap and HashMap
You are right. As you pointed out, my java interface design is not good. I've changed java interface into java.util.Map and I could pass Clojure's map to the java interface. I've also tested clojure.walk/postwork. The clojure.walk library is fine ! Thanks, Makoto -- 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.