Re: (count (filter ...)) much slower in 1.3 Alpha 2?

2010-10-29 Thread Btsai
Awesome, thank you :) On Oct 29, 2:29 pm, Stuart Halloway wrote: > Rich has fixed this on > master:http://github.com/clojure/clojure/commit/e354b01133e7cff8dc0d0eb9e90c... > > Thanks for the report! > > Stu > > > > > > > > > I have some code that counts the elements in a list that map to true >

Re: (count (filter ...)) much slower in 1.3 Alpha 2?

2010-10-29 Thread Btsai
Could someone else also try the sample code I included to see if they also experience the same ~10x slowdown for (count (filter ...)) in 1.3 Alpha 2? On Oct 28, 12:34 pm, Btsai wrote: > I have some code that counts the elements in a list that map to true > in a lookup table, looking som

(count (filter ...)) much slower in 1.3 Alpha 2?

2010-10-28 Thread Btsai
I have some code that counts the elements in a list that map to true in a lookup table, looking something like this: (def lookup-table {1 true, 2 false}) (def elements (range 100)) (count (filter lookup-table elements)) On my machine, with server mode enabled, the count + filter got ~10 times

Re: clojure-contrib 1.3.0-alpha2 deployed to build.clojure.org

2010-10-27 Thread Btsai
d.clojure.org/releases/org/clojure/contrib/ > and depend on: > >   groupId: org.clojure.contrib >   artifactId: NAME-OF-THE-LIBRARY >   version: 1.3.0-alpha2 > >   Or in Leiningen: [org.clojure.contrib/NAME-OF-THE-LIBRARY "1.3.0- > alpha2"] > > -S > > On Oct 26, 10

Re: clojure-contrib 1.3.0-alpha2 deployed to build.clojure.org

2010-10-27 Thread Btsai
Ah, excellent. Thank you :) On Oct 27, 12:25 am, Jacek Laskowski wrote: > On Wed, Oct 27, 2010 at 4:37 AM, Btsai wrote: > > Is there still a complete jar somewhere that has all the modules?  If > > so, I can't seem to find it.  Or is that a thing of the past now? >

Re: Getting this error regarding duck-streams/spit ...

2010-10-26 Thread Btsai
im and I are working to have clojuredocs pull data from the > autodoc system and, at that point, I assume that he'll add deprecation > info over there as well. > > Sorry for any confusion! Clojure's still a fast moving target. > > Tom > > On Oct 26, 12:48 pm, Btsai

Re: clojure-contrib 1.3.0-alpha2 deployed to build.clojure.org

2010-10-26 Thread Btsai
Is there still a complete jar somewhere that has all the modules? If so, I can't seem to find it. Or is that a thing of the past now? On Oct 26, 6:03 pm, Stuart Sierra wrote: > blah -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this g

Re: challenge with vectors

2010-10-26 Thread Btsai
Is it ok if the index starts at 0? (use '[clojure.contrib.seq :only (indexed)]) (defn get-min-and-index [coll] (apply min-key #(second (second %)) (indexed coll))) user=> (get-min-and-index [[22 5] [56 8] [99 3] [43 76]]) [2 [99 3]] On Oct 26, 7:54 pm, Glen Rubin wrote: > I have a sequence l

Re: Getting this error regarding duck-streams/spit ...

2010-10-26 Thread Btsai
clojure-contrib point to the current repository. On Oct 26, 12:44 pm, Victor Olteanu wrote: > Thank you Btsai. I checked > bothhttp://richhickey.github.com/clojure-contrib/io-api.html#clojure.cont... > andhttp://clojuredocs.org/clojure_contrib/clojure.contrib.duck-streams/s... > and

Re: Getting this error regarding duck-streams/spit ...

2010-10-25 Thread Btsai
I don't think it's a mistake or accident that spit exists in clojure.core. In 1.2, duck-streams became deprecated and functions such as spit were incorporated into clojure.core: http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/spit http://clojure.github.com/clojure-contrib/duc

Re: Help to optimize palindrome search from input file

2010-10-13 Thread Btsai
I think the indexing in all-combs may be off, causing it to miss certain combinations/substrings. user=> (all-combs "abc") ("a" "ab") I used this instead: (defn substrings [s] (let [length (count s)] (for [i (range length) j (range (inc i) (inc length))] (subs s i j us

Re: Clojure 1.3 alpha 1 report - bitwise operations extremely slow

2010-09-30 Thread Btsai
Some more data points on 1.3 alpha 1 performance: bit operations appear to be much faster on hinted args. For example, (defn unhinted-shift [n] (bit-shift-left n 1)) (defn ^:static hinted-shift [^long n] (bit-shift-left n 1)) user=> (time (doseq [x (range 10)] (unhinted-shift x))) "

Re: Some code dramatically slower in Clojure 1.3 Alpha 1?

2010-09-28 Thread Btsai
Hi Mark, I tested the change to expt-int. Unfortunately, still no performance gain. I'm afraid I don't have a solid enough grasp of Clojure to know what tweaks are needed to get performance fast again. Do you think you'll have time to play with 1.3 soon? On Sep 27, 1:00 am, Mark Engelberg wro

Re: Some code dramatically slower in Clojure 1.3 Alpha 1?

2010-09-26 Thread Btsai
I found that even without patching, most functions in clojure.contrib.math already correctly handle big nums in 1.3: Handles big nums in 1.3? absYes ceil Yes exact-integer-sqrt No expt No floor Yes gcdYes lcmY

Re: Some code dramatically slower in Clojure 1.3 Alpha 1?

2010-09-25 Thread Btsai
> I haven't tried 1.3 yet, but I'd recommend downloading a copy of > clojure.contrib.math locally and replace any instances of +, -, *, > inc, dec with +', -', *', inc', dec'.  This should at least make the > functions produce the correct results.  I'd be curious to know whether > performance conti

Re: Some code dramatically slower in Clojure 1.3 Alpha 1?

2010-09-25 Thread Btsai
Awesome, thanks :) On Sep 25, 8:44 pm, Mark Engelberg wrote: > >>http://code.google.com/p/clojure/issues/detail?id=95 > > I just looked over this code.  You can speed it up even more by > manually encoding the loop, rather than using reduce. > (defn faster-max-key >   ([k x] x) >   ([k x &  more]

Re: Some code dramatically slower in Clojure 1.3 Alpha 1?

2010-09-25 Thread Btsai
I went through the rest of my Project Euler code. In addition to even?, there are some functions in clojure.contrib that are also much slower in 1.3 Alpha 1. clojure.contrib.math -> expt (Clojure 1.2) user=> (time (doseq [x (range 10)] (expt x 2))) "Elapsed time: 119.417971 msecs" (

Re: Some code dramatically slower in Clojure 1.3 Alpha 1?

2010-09-25 Thread Btsai
Thanks Eric :) Have you considered submitting that change as a patch? On Sep 24, 5:35 pm, Eric Lavigne wrote: > > I think I read somewhere that max-key applies f more times than is > > necessary, so should not be pass any f that takes significant time to > > compute. > > Yes, max-key calls f mor

Re: Some code dramatically slower in Clojure 1.3 Alpha 1?

2010-09-24 Thread Btsai
Thank you David. Time for me to dig in! On Sep 24, 3:36 pm, David Nolen wrote: > On Fri, Sep 24, 2010 at 5:25 PM, Btsai wrote: > > David, Nicolas, thank you for finding the culprit so quickly :) > > > What profiling technique/tool did you use?  I have some other code >

Re: Some code dramatically slower in Clojure 1.3 Alpha 1?

2010-09-24 Thread Btsai
David, Nicolas, thank you for finding the culprit so quickly :) What profiling technique/tool did you use? I have some other code that is also much slower in 1.3, and thought I'd take a crack at finding the culprit myself before spamming the list again. On Sep 24, 11:26 am, Nicolas Oury wrote:

Re: Some code dramatically slower in Clojure 1.3 Alpha 1?

2010-09-24 Thread Btsai
53.43 msecs Clojure 1.3 Alpha 1 = 190769.86 msecs On Sep 24, 10:41 am, Btsai wrote: > After updating from Clojure 1.2 to Clojure 1.3 Alpha 1, I noticed that > one of my Project Euler solutions became dramatically slower.  The > solution was for Problem 14, finding the number less than N t

Some code dramatically slower in Clojure 1.3 Alpha 1?

2010-09-24 Thread Btsai
After updating from Clojure 1.2 to Clojure 1.3 Alpha 1, I noticed that one of my Project Euler solutions became dramatically slower. The solution was for Problem 14, finding the number less than N that produces the longest Collatz sequence. For N = 100,000, the time required to find the answer wa

Re: Clojure meetup group listing

2010-09-20 Thread Btsai
I second the motion. Just moved to Edmonton, and have been looking around for fellow Clojurians. I've created an Edmonton meetup (I think), and hopefully some kindred souls will turn up :) On Sep 20, 9:33 am, Andrew Gwozdziewycz wrote: > Hey All, > > I know there are certainly a few groups out

Re: thinking in clojure

2010-09-16 Thread Btsai
; (update-in {} [:a] (fnil update-in {:label "great label"}) [:b] identity) > > => {:a {:b nil, :label "great label"}} > > > or you can also decide that it's not a map which should be the default > > value, imagine you want to modify a path [:a 2] : &

Re: thinking in clojure

2010-09-16 Thread Btsai
My poor brain can't handle nested calls to update-in, so this is what I came up with: (defn add-meetings [data k meetings] (cond (nil? (data k)) (assoc data k {:title "title" :meetings meetings}) :else (update-in data [k :meetings] concat meetings))) On Sep 16, 8:53 am, Laurent PETIT wro

Re: Generating functions programmatically

2010-09-11 Thread Btsai
Ah ok. I couldn't come up with anything, but I think Kent has a nice eval-free (and macro-free) solution. My thanks to you, and everyone who chimed in, for helping me better understand the read-time/compile-time/run-time distinction. On Sep 11, 8:29 am, icemaze wrote: > Hi Btsai, thank

Re: Generating functions programmatically

2010-09-11 Thread Btsai
t McIntyre wrote: > That is very elegant but has the exact same problem in that the macro > must be called on a literal vector of keywords. > > --Robert McIntyre > > > > On Fri, Sep 10, 2010 at 5:41 PM, Btsai wrote: > > This is probably not the prettiest way to do

Re: Generating functions programmatically

2010-09-10 Thread Btsai
This is probably not the prettiest way to do it, but I think it gets the job done: (defn make-sym [keyword] (->> keyword name (str "prefix-") symbol)) (defn make-fn [keyword] (let [n (gensym)] (list 'defn (make-sym keyword) [n] (list '= n keyword (defmacro make-fns [keywords] `(do ~

Re: 1.2 contrib shuffles

2010-08-27 Thread Btsai
How are you grabbing the sources? I'm also running under Windows, and get the source from github via msysgit, which handles the crlf vs. cr issue nicely. On Aug 27, 8:07 am, gary ng wrote: > > I need to exclude/modify a few test when running under windows, due to > the crlf vs cr stuff -- You

Re: trouble using nested map fn

2010-08-23 Thread Btsai
Ah, so this is the context for your previous thread about multiplying lists. Re-using some of the code from that thread: (def target [[1 2 3 4] [2 3 4 5]]) (def signal [[[1 2 3 4] [2 3 4 5] [3 4 5 6]] [[2 3 4 5] [3 4 5 6] [4 5 6 7]]]) (defn correlate [target signal] (let [mult-lists (fn [x y]

Re: Feedback on idiomatic clojure

2010-08-20 Thread Btsai
I believe duck-streams is deprecated since clojure 1.2. You may want to consider bringing back f-to-seq, which can be simplified slightly using reader from clojure.java.io: (ns clojure.example.anagrams (:use [clojure.java.io :only (reader)]) (:gen-class)) (defn f-to-seq [file] (with-open [

Re: multiplying lists

2010-08-19 Thread Btsai
This should work: (defn mult-list-by-lists [a b] (let [mult-lists (fn [x y] (map * x y))] (map #(mult-lists a %) b))) On Aug 19, 5:56 pm, Glen Rubin wrote: > I want to multiply a list of n items by h lists of n items, so that > for example if i have list 'a' and 'b' > > (def a (list 1 2 3)

Re: What is the reason Lisp code is not written with closing parenthesis on new lines?

2010-08-19 Thread Btsai
Yet another one for Emacs users that don't use paredit: I have Paren Match Highlighting enabled and set to highlight the entire expression within matching parens (the highlighting kicks in when the cursor is before the opening paren or after the closing paren): (show-paren-mode 1) (setq show-pare

Re: Clojure 1.2 Release

2010-08-19 Thread Btsai
Congratulations! Just as a heads-up, the download link for Clojure Contrib on http://clojure.org/downloads is currently broken. It's pointing to: http://github.com/downloads/clojure/clojure/clojure-contrib-1.2.0.zip .. when I'm guessing it should be: http://github.com/downloads/clojure/clojure

Re: Argument order / Documentation Mismatch

2010-08-16 Thread Btsai
No worries :) On Aug 16, 12:55 pm, Timothy Washington wrote: > Ahh, my bad. > > Cheers > Tim > > > > On Sun, Aug 15, 2010 at 8:40 PM, Btsai wrote: > > I think the mismatch is because page you looked at is for > > clojure.string, not clojure-contrib.string.

Re: Argument order / Documentation Mismatch

2010-08-16 Thread Btsai
I think the mismatch is because page you looked at is for clojure.string, not clojure-contrib.string. The documentation for the split from clojure-contrib.string is here: http://clojure.github.com/clojure-contrib/string-api.html#clojure.contrib.string/split On Aug 15, 5:12 pm, Timothy Washington

Re: Game development in Clojure

2010-08-14 Thread Btsai
Continuing this train of thought... 1. The "declare" macro may be handy for declaring multiple names at once. 2. Maybe one could use the functions in clojure.repl or clojure- contrib.ns-utils to write something that automatically forward declares everything needed? On Aug 13, 10:49 pm, Tim Daly

Re: Exception when trying to require clojure.contrib.io

2010-08-11 Thread Btsai
Hmmm. Actually, as Meikel noted, this should be fine, and it does indeed work for me: (ns your-namespace (:require clojure.contrib.io)) The only time I got the "Don't know how to create ISeq from: clojure.lang.Symbol" exception is when I erroneously copy-pasted and tried to evaluate this: (ns

Re: Exception when trying to require clojure.contrib.io

2010-08-11 Thread Btsai
The following worked for me: (ns your-namespace (:require (clojure.contrib io))) (See: http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/ns) This also works: (ns your-namespace (:require [clojure.contrib.io])) On Aug 11, 2:46 am, Meikel Brandmeyer wrote: > Hi, > > On 11

Re: Clojure 1.2 RC1

2010-08-01 Thread Btsai
The jar can be located in the target sub-directory. On Aug 1, 2:37 am, Mark Engelberg wrote: > Meant to say, "...zip doesn't have a compiled jar..." > > On Sun, Aug 1, 2010 at 1:36 AM, Mark Engelberg > wrote: > > > > > On Fri, Jul 30, 2010 at 8:00 AM, Stuart Halloway < > > stuart.hallo...@gmail.

Re: clojure.string namespace missing from API page?

2010-07-19 Thread Btsai
Thank you Tom :) On Jul 18, 12:10 pm, Tom Faulhaber wrote: > The official doc for clojure and clojure-contrib have moved as well. > They are now at: > > http://clojure.github.com/clojure/ > > and > > http://clojure.github.com/clojure-contrib/ > > I have not got them completely up-to-date with the

Re: clojure.string namespace missing from API page?

2010-07-17 Thread Btsai
show up just fine there, which is why I'm confounded why clojure.string is not there. On Jul 17, 8:57 am, Adrian Cuthbertson wrote: > Hi Benny, > > The 1.2 release source site has moved tohttp://github.com/clojure/ > > -Regards, Adrian > > > > On Sat, Jul 17, 2010

clojure.string namespace missing from API page?

2010-07-17 Thread Btsai
Hi Clojurians, The recent 1.2 beta release is the first time I played with 1.2. When reading the release notes, I saw a number of new namespaces. I was able to find most of them (clojure.java.io, etc.) on the API site (http://richhickey.github.com/clojure/). However, I could not find the clojur

Re: Clojure 1.2 Beta 1

2010-07-15 Thread Btsai
Congrats to Clojure on hitting this fantastic milestone :) Question: the release notes mentions a new clojure.string namespace. But I've had no luck finding it in the online API at http://richhickey.github.com/clojure/. Am I missing something? On Jul 14, 9:03 am, Stuart Halloway wrote: > Clojur