Difficulty finding correct way to type hint inside a deftype in Clojure 1.3 alpha4

2011-01-31 Thread Andy Fingerhut
I wanted to compare some similar code for 1.2 versus 1.3 alpha4, and I'm having trouble finding something I want that compiles with 1.3 alpha4. Here is one try, stored in a file knucleotide.clj. It is not the complete program, but it does exhibit the error I'm having trouble with, and is

Re: Ridiculously massive slowdown when working with images

2011-01-31 Thread B Smith-Mannschott
On Mon, Jan 31, 2011 at 08:00, Bill James wrote: > Benny Tsai wrote: >> Nice!  That version runs in 6 milliseconds on my machine, fastest of >> all the code posted so far.  One more idea: use 'unchecked-inc' >> instead of 'unchecked-add'.  This takes it under 3 milliseconds in my >> tests. >> >> (

Re: Difficulty finding correct way to type hint inside a deftype in Clojure 1.3 alpha4

2011-01-31 Thread Ken Wesson
On Mon, Jan 31, 2011 at 3:10 AM, Andy Fingerhut wrote: > I wanted to compare some similar code for 1.2 versus 1.3 alpha4, and I'm > having trouble finding something I want that compiles with 1.3 alpha4. ... >      (loop [i (int 0) >             offset (int offset) >             temp (int 0)] As

how to print-dup records?

2011-01-31 Thread Seth
This is my attempt: (defn record? [a] (and (map? a) (not (instance? clojure.lang.APersistentMap a (defmethod print-dup clojure.lang.IPersistentMap [m, ^Writer w] (if (record? m) (do (.write w "#=(") (print-dup (class m) w) (.write w ". ") (doall (map #(do (print-dup %

Re: Ridiculously massive slowdown when working with images

2011-01-31 Thread Bill James
On Jan 31, 5:46 am, B Smith-Mannschott wrote: > > Yes, that speeds it up considerably.  If I can get Java server > > installed > > on my machine, I'll post some timings. > > What is this "java server" of which you speak.  In JVMs I'm familiar > with (Sun/Oracle, OpenJDK) it's just a matter of p

Re: Ridiculously massive slowdown when working with images

2011-01-31 Thread Bill James
(set! *warn-on-reflection* true) (def buffer-size 192) (def array (byte-array buffer-size)) (defmacro add [m n] `(unchecked-add (int ~m) (int ~n))) (defmacro uinc [m] `(unchecked-inc ~m)) (defmacro amove[a i j] `(aset ~a ~j (aget ~a ~i))) (defn java-like0 [^bytes cpu_array] (loop [i (int

Re: Ridiculously massive slowdown when working with images

2011-01-31 Thread Bill James
On Jan 31, 1:40 pm, Bill James wrote: > (set! *warn-on-reflection* true) > > (def buffer-size 192) > (def array (byte-array buffer-size)) > > (defmacro add [m n] `(unchecked-add (int ~m) (int ~n))) > (defmacro uinc [m] `(unchecked-inc ~m)) > (defmacro amove[a i j] `(aset ~a ~j (aget ~a ~i))) >

Re: how to print-dup records?

2011-01-31 Thread Alex Miller
We wrapped defrecord in a macro that created a factory function then had print-dup print a call to that function. https://github.com/david-mcneil/defrecord2 You can also find pprint in there too. On Jan 31, 11:26 am, Seth wrote: > This is my attempt: > > (defn record? [a] >   (and (map? a) (no

Defrecord and = docstring clarifications (regarding record equality)

2011-01-31 Thread Jason Wolfe
I just ran into the following surprise: user> (defrecord P []) user.P user> (defrecord Q []) user.Q user> (= (P.) (Q.)) false user> (.equals (P.) (Q.)) true This is not a bug (but I do find it confusing -- I did not expect (P.) and (Q.) to collide as map keys): http://groups.google.com/group/cloj

Re: Defrecord and = docstring clarifications (regarding record equality)

2011-01-31 Thread Ken Wesson
On Mon, Jan 31, 2011 at 11:33 PM, Jason Wolfe wrote: > I just ran into the following surprise: > > user> (defrecord P []) > user.P > user> (defrecord Q []) > user.Q > user> (= (P.) (Q.)) > false > user> (.equals (P.) (Q.)) > true > > This is not a bug (but I do find it confusing -- I did not expec

Re: Ridiculously massive slowdown when working with images

2011-01-31 Thread Bill James
On Jan 31, 1:33 pm, Bill James wrote: > On Jan 31, 5:46 am, B Smith-Mannschott wrote: > > > > Yes, that speeds it up considerably.  If I can get Java server > > > installed > > > on my machine, I'll post some timings. > > > What is this "java server" of which you speak.  In JVMs I'm familiar > >

Re: How to disallow unlisted optional argument keys?

2011-01-31 Thread Robert McIntyre
You win sir. That is the most beautiful way. sincerely, --Robert McIntyre On Sun, Jan 30, 2011 at 7:59 PM, Bill James wrote: > Alexander Yakushev wrote: >> Why not use a constraint? It looks much cleaner. >> >> (defn hello [& {:keys [a b] :as input}] >>          {:pre [(= (set (keys input)) #{: