Question regarding java array

2015-06-10 Thread Ritchie Cai
I'm working on a java array of double with 128 elements. I need the max and min values of the array. So I initially tried areduce and loop, both gives runs around 20 seconds. But when try (apply max (vec array)) I get result under 90 ms. Can anyone explain why there is such a big difference?

Re: Question regarding java array

2015-06-11 Thread Ritchie Cai
ccur when loading the file: > > (set! *warn-on-reflection* true) > > If there are none, probably best to post a link to your code, or paste it > in a message here if it is short enough, so others can give more precise > suggestions. > > Andy > > On Wed, Jun 10, 2015 at

Re: Question regarding java array

2015-06-11 Thread Ritchie Cai
as a lot of helpful > array operations already defined. > > (use 'clojure.core.matrix) > (def v (array :vectorz (range 128))) > > (time (emax v)) > => 1279999.0 > "Elapsed time: 1.179533 msecs" > > > On Wednesday, 10 June 2015 21:07:09 UTC+1, Ritchie Cai wrote: &

Re: Question regarding java array

2015-06-11 Thread Ritchie Cai
warning, > /private/var/folders/0k/xj_drd990xxf4q99n2bdknrcgn/T/form-init1595291808747030463.clj:2:3 > > - call: public static boolean clojure.lang.Numbers.lt > (long,java.lang.Object). > > Reflection warning, > /private/var/folders/0k/xj_drd990xxf4q99n2bdknrcgn/T/form-in

Re: Question regarding java array

2015-06-11 Thread Ritchie Cai
at 7:30:07 AM UTC-5, Andy- wrote: > > On Thursday, June 11, 2015 at 5:32:02 AM UTC-4, Ritchie Cai wrote: >> >> Just wondering though, is there a faster way to load an array than this >> way? >> https://github.com/malloc82/imaging/blob/45475b99f564b1ac77e668e04b91cb9c01

Re: Question regarding java array

2015-06-15 Thread Ritchie Cai
1] > 281 invokestatic > clojure.lang.RT.uncheckedDoubleCast(java.lang.Object) : double [135] > 284 dconst_1 > 285 invokestatic clojure.lang.Numbers.unchecked_add(double, > double) : double [141] > > I'd try using a loop-recur here as well instead

Re: Question regarding java array

2015-06-15 Thread Ritchie Cai
8.0_45-b14 > > > > On Mon, Jun 15, 2015 at 2:22 PM, Ritchie Cai > wrote: > > Ha, you are right. That really make things a lot faster now. All three > > different implementations now pretty much runs about the same speed, no > one > > is significantly faster

Re: Question regarding java array

2015-06-15 Thread Ritchie Cai
Aww ... with that it's around 3ms now. Thanks :) On Monday, June 15, 2015 at 7:34:36 PM UTC-5, Jason Wolfe wrote: > > Might also be something to do with this: > > https://github.com/Prismatic/hiphip#performance-know-your-options > > > > On Monday, June 15, 2015 at

Basic question: what's the difference between "require as" and "use as"?

2015-06-22 Thread Ritchie Cai
For example: (:require [clojure.java.io :as io]) vs (:use [clojure.java.io :as io]) In both cases, we can end up using it with "(io/ ... )". Is there a difference at all? Thanks Ritchie -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to t

Re: Basic question: what's the difference between "require as" and "use as"?

2015-06-22 Thread Ritchie Cai
You mean (:use [clojure.java.io]) is equivalent to (:require [clojure.java.io :as io :refer :all])? Ritchie > On Jun 22, 2015, at 4:15 PM, Sean Corfield wrote: > > On Jun 22, 2015, at 1:50 PM, Ritchie Cai wrote: >> For example: >> (:require [clojure.java.io :as

Re: Basic question: what's the difference between "require as" and "use as"?

2015-06-22 Thread Ritchie Cai
Ok, so require without :refer will default to :refer :all? > On Jun 22, 2015, at 4:32 PM, Sean Corfield wrote: > > On Jun 22, 2015, at 2:22 PM, Ritchie Cai wrote: >> You mean (:use [clojure.java.io]) is equivalent to (:require >> [clojure.java.io :as io :refer :all])?

Re: Basic question: what's the difference between "require as" and "use as"?

2015-06-22 Thread Ritchie Cai
Ah, I see. I thought “use :as” will not intern all the symbols into current namespace, apparently that’s not the case. Thanks for clearing this up. Ritchie > On Jun 22, 2015, at 4:52 PM, Sean Corfield wrote: > > On Jun 22, 2015, at 2:39 PM, Ritchie Cai wrote: >> Ok, so require

Re: Basic question: what's the difference between "require as" and "use as"?

2015-06-23 Thread Ritchie Cai
It's mostly a > historical accident that's kept there for backwards compatibility. > > And try to avoid :refer :all if possible. There are legitimate use-cases for > it, but outside the REPL they are pretty rare. > > On Tuesday, 23 June 2015, Ritchie Cai <mailto:ritchie...@g

Re: Basic question: what's the difference between "require as" and "use as"?

2015-06-23 Thread Ritchie Cai
I see. Thanks. > On Jun 23, 2015, at 11:02 AM, Fluid Dynamics wrote: > > On Tuesday, June 23, 2015 at 10:40:25 AM UTC-4, Ritchie Cai wrote: > I always have (:use clojure.core) in a new namespace. Is that necessary or is > clojure.core is automatically interned when a new names

cider-error go to line

2015-07-02 Thread Ritchie Cai
When I get a cider-error, it tells me line number within the function that raised the error, but is there an easy way to go to that line? Since the line number is within the function, I've been counting lines manually at the moment ... getting tired of this. Anyone has any suggestions? Thanks R

Re: cider-error go to line

2015-07-03 Thread Ritchie Cai
es/1175 > > But as I said NREPL-59 has to be fixed eventually, as this is killing us > (and everyone using nREPL), so consider dropping by the issue and voicing > your support for the proposed patch. > > On 3 July 2015 at 02:44, Ritchie Cai > > wrote: > >> W

Re: Why we cannot do this now?

2016-06-22 Thread Ritchie Cai
Just curious, how do you add new dependencies to a running REPL? Do you just restart REPL? I used to able to add new dependencies using alembic, but it seems it's not really compatible with clojure 1.8, not an option anymore. Thanks Ritchie On Monday, June 20, 2016 at 3:42:02 PM UTC-5, Sean Co

Re: cider-error go to line

2015-09-16 Thread Ritchie Cai
It’s a beautiful day~~~!! > On Sep 16, 2015, at 5:42 PM, James Elliott wrote: > > W00t, look at what just was released! :D > > https://github.com/clojure/tools.nrepl/commit/64238a10a8465e0c590acb660ec5d54bf7cc3af4 > > On Friday, July 3, 2015 at 1:59:23 PM UTC-5, Ritchi

Transient map question

2015-11-10 Thread Ritchie Cai
Hi, I'm wondering if anyone can help me understand why transient map in my code stops adding entries. Here is my implementation of huffman code generation given a string: https://gist.github.com/malloc82/efeec1053b9af195e351#file-huffman-clj-L53-L55 Line 53-55 is where it adds a huffman code

Re: Transient map question

2015-11-10 Thread Ritchie Cai
btw, I'm using Java 1.8.0_60-b27, Clojure 1.7.0 On Tuesday, November 10, 2015 at 12:59:54 PM UTC-6, Ritchie Cai wrote: > > Hi, > > I'm wondering if anyone can help me understand why transient map in my > code stops adding entries. > Here is my implementation of huf

Re: Transient map question

2015-11-10 Thread Ritchie Cai
table object, which is not >> correct in the general case. You should only use the return value of >> assoc!/dissoc!/et cetera. >> >> >> lvh >> >> On Nov 10, 2015, at 1:03 PM, Ritchie Cai > > wrote: >> >> btw, I'm using Java 1.8.0_60-b

mexpand on macrolet

2015-12-04 Thread Ritchie Cai
I'm not sure how to print a macroexpand on macros that defined in macrolet or symbol-macrolet. with normal macros, I can do: (defmacro test-macro [] '(+ 1 2)) (pprint (macroexpand-1 '(test-macro))) ;; (+ 1 2) ;; nil but with macrolet or symbol-macrolet: (symbol-macrolet [(b [] '(+ 1 2))]

Re: [ANN] New clojure.org!

2016-01-14 Thread Ritchie Cai
New site looks great! I feel like https://clojuredocs.org should be added to the community resources. Personally, it's my main reference website, and it has been extremely helpful. I'm sure it will be for other people too. On Thursday, January 14, 2016 at 9:45:06 AM UTC-6, Alex Miller wrote: >

Java API type hint question

2016-01-17 Thread Ritchie Cai
Hi all, I'm trying to create a Java ArrayList object from a Clojure collection to pass to another Java API. I get reflection warnings when the elements are not primitive types, in this case I'm using SparseIndexedVector class from vectorz library. (ArrayList. [c0 c1 c2]) Reflection warning, *c

Re: Java API type hint question

2016-01-26 Thread Ritchie Cai
I thought it was considered more > idiomatic than doing (list ...) > > On Sunday, January 17, 2016 at 2:48:29 PM UTC-6, Ritchie Cai wrote: >> >> Hi all, >> >> I'm trying to create a Java ArrayList object from a Clojure collection to >> pass to anoth

Re: Java API type hint question

2016-01-26 Thread Ritchie Cai
gt; => java.util.Collection > (ArrayList. (list 1 2)) > Reflection warning, > /Users/bfabry/Library/Caches/IdeaIC15/tmp/form-init108635367050123227.clj:1:1 > - call to java.util.ArrayList ctor can't be resolved. > => [1 2] > (ArrayList. ^Collection (list 1 2)) > =&g

Re: Java API type hint question

2016-01-26 Thread Ritchie Cai
gt;> >> - call to java.util.ArrayList ctor can't be resolved. >> => [1 2] >> (ArrayList. ^Collection (list 1 2)) >> => [1 2] >> >> >> >> On Tuesday, January 26, 2016 at 1:56:19 PM UTC-8, Ritchie Cai wrote: >>> >>> Quoting