Re: Performance of seq on empty collections

2010-11-15 Thread Christophe Grand
On Sun, Nov 14, 2010 at 9:36 PM, Eric Kobrin erl...@gmail.com wrote: This brought to mind the general case of detecting emptiness. The current practice of using `seq` to check for non-emptiness wastes resources. It depends: in many cases you need to call seq anyway in the non-empty branch so

Re: LabREPL status ... github returning 404's

2010-11-15 Thread Rick Moynihan
On 14 November 2010 20:47, Victor Olteanu bluestar...@gmail.com wrote: Github is down at the moment unfortunately... Ahhh great, it's back up... Looks like github was partially down as other pages were returning for me. Thanks R. -- You received this message because you are subscribed to

Re: max-key taking a list rather than different number of args

2010-11-15 Thread Tom Hall
You should be able to use (apply max-key f someseq); apply takes a variable number of args, and only the last is expanded. Thanks, thought there would be something like this! -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group,

Re: LabREPL status ... github returning 404's

2010-11-15 Thread Rick Moynihan
On 15 November 2010 09:46, Rick Moynihan rick.moyni...@gmail.com wrote: On 14 November 2010 20:47, Victor Olteanu bluestar...@gmail.com wrote: Github is down at the moment unfortunately... Ahhh great, it's back up...  Looks like github was partially down as other pages were returning for me.

Clojure typing test

2010-11-15 Thread David Sletten
The StackOverflowError jumps over the lazy seq. Have all good days, David Sletten -- 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

Land of Lisp's Conrad Barski M.D. speaking about Clojure (Nov. 18, DC/VA/MD area)

2010-11-15 Thread Fogus
Conrad Barski, author of Land of Lisp (http://www.amazon.com/gp/ product/1593272812) will be giving a talk entitled *Land of Lisp: The Clojure-ish Parts* at the National Capital Area Clojure Users Group (CAPCLUG) on November 18, 2010 at 6:15 pm. The meeting will be held at 12021 Sunset Hills Road

Re: LabREPL status ... github returning 404's

2010-11-15 Thread Victor Olteanu
That's right - but I'm happy they are back up. I was in the middle of working for something requiring the clj-time library, and all of a sudden GitHub starts reporting it's missing. I was thinking, wow, did the author suddenly decided to take to the hills, like someone once did (in the Rails

Re: Incorrect behaviour for large s-expressions :(

2010-11-15 Thread Alessio Stalla
On Nov 14, 6:48 am, Robert McIntyre r...@mit.edu wrote: So my friend and I were screwing around, battling versions of LISP as nerds are wont to do, when I came across this: (eval `(clojure.core/+ ~@(take 1e4 (iterate inc 1 Invalid method Code length 89884 in class file user$eval13607

Re: Clojure typing test

2010-11-15 Thread Michael Wood
On 15 November 2010 16:08, David Sletten da...@bosatsu.net wrote: The StackOverflowError jumps over the lazy seq. The quick, brown StackOverflowError jumps over the lazy seq? -- Michael Wood esiot...@gmail.com -- You received this message because you are subscribed to the Google Groups

Function Design: sequence or argument?

2010-11-15 Thread Chris
If you have a function that needs to treat multiple arguments as a group, what forces drive you to represent this as a single sequence argument vs. an argument? To give a concrete example, why does + work like (+ 1 2 3 4) instead of (+ [1 2 3 4]) Is it performance? Aesthetics?

Re: REQUEST for feedback on http://clojure.org

2010-11-15 Thread Rick Moynihan
Hi Alex, I have one more Clojure Group for you: The Manchester (UK) Clojure Dojo http://manchester.clojuredojo.com/ I'm currently in the process of organising our next meeting, but a link on the clojure.org website would be appreciated. R. On 31 October 2010 02:38, Alex Miller

Re: shorter alternatives for `comp' and `partial'

2010-11-15 Thread Alan
I think comp is nice and short, personally. Partial is okay, and the long name helps discourage me from using it when I should be using #() instead - partial is a bit slower. And if you find yourself wanting to nest #() forms, it's not that bad to switch to partial, and it may serve as a warning

Re: Incorrect behaviour for large s-expressions :(

2010-11-15 Thread Brian Goslinga
On Nov 13, 11:48 pm, Robert McIntyre r...@mit.edu wrote: So my friend and I were screwing around, battling versions of LISP as nerds are wont to do, when I came across this: (eval `(clojure.core/+ ~@(take 1e4 (iterate inc 1 Invalid method Code length 89884 in class file user$eval13607

Re: LabREPL status ... github returning 404's

2010-11-15 Thread Ken Wesson
On Mon, Nov 15, 2010 at 10:21 AM, Victor Olteanu bluestar...@gmail.com wrote: That's right - but I'm happy they are back up. I was in the middle of working for something requiring the clj-time library, and all of a sudden GitHub starts reporting it's missing. I was thinking, wow, did the

Re: Function Design: sequence or argument?

2010-11-15 Thread Ken Wesson
On Mon, Nov 15, 2010 at 11:52 AM, Chris christopher.ma...@gmail.com wrote: If you have a function that needs to treat multiple arguments as a group, what forces drive you to represent this as a single sequence argument vs. an argument?  To give a concrete example, why does + work like (+ 1

Re: Clojure typing test

2010-11-15 Thread Ken Wesson
On Mon, Nov 15, 2010 at 10:52 AM, Michael Wood esiot...@gmail.com wrote: On 15 November 2010 16:08, David Sletten da...@bosatsu.net wrote: The StackOverflowError jumps over the lazy seq. The quick, brown StackOverflowError jumps over the lazy seq? The reversible, associative vector jumps over

Re: shorter alternatives for `comp' and `partial'

2010-11-15 Thread Ken Wesson
On Mon, Nov 15, 2010 at 1:26 PM, Alan a...@malloys.org wrote: I think comp is nice and short, personally. Partial is okay, and the long name helps discourage me from using it when I should be using #() instead - partial is a bit slower. And if you find yourself wanting to nest #() forms, it's

Re: Function Design: sequence or argument?

2010-11-15 Thread Meikel Brandmeyer
Hi, Am 15.11.2010 um 17:52 schrieb Chris: If you have a function that needs to treat multiple arguments as a group, what forces drive you to represent this as a single sequence argument vs. an argument? To give a concrete example, why does + work like (+ 1 2 3 4) instead of (+ [1

Re: Function Design: sequence or argument?

2010-11-15 Thread Alyssa Kwan
Performance is part of it too. Allowing dispatch on arity leads to faster code. Many of the functions that operate on sequences are lazy so dispatch on arity doesn't apply. On Nov 15, 11:52 am, Chris christopher.ma...@gmail.com wrote: If you have a function that needs to treat multiple

Re: Incorrect behaviour for large s-expressions :(

2010-11-15 Thread Alyssa Kwan
I'm building an ETL app, so aggregate functions of arbitrarily large arity is a necessity. I've had to wrap a lot of core clojure functions with concrete arg lists to make them work with lazy sequences. In my limited experience, machine generated code of this nature should use lazy sequences

Re: Incorrect behaviour for large s-expressions :(

2010-11-15 Thread Alessio Stalla
On 15 Nov, 19:34, Brian Goslinga quickbasicg...@gmail.com wrote: Well, assuming the memory is available, at least Clojure is guaranteed to support vectors with more than 1024 elements... Unfair comparison. Clojure is not a standard, it's an implementation. SBCL is guaranteed to support vectors

Re: shorter alternatives for `comp' and `partial'

2010-11-15 Thread Sean Corfield
On Mon, Nov 15, 2010 at 10:26 AM, Alan a...@malloys.org wrote: The one that bugs me is complement - such a long name for a commonly- useful function. I often wind up defining ! as an alias for complement, but maybe others will think that is poor style. Possibly because bang functions indicate

Re: Closures eat permgen?

2010-11-15 Thread Alyssa Kwan
If you look at the bytecode for the closures, you'll see that the Var that *ns*/a points to is resolved at clinit time, and the Java reference is stored as a static final class member. That's a small use of additional permgen. In your example, my-generator isn't the concern. It's the call to

Dependency between files problem

2010-11-15 Thread trying clj
File example\some.clj (ns example.some (:use example.someother)) (defn helloworld [] (print helloworld)) File example\someother.clj: (ns example.someother (:use example.some)) (defn sample [] (helloworld)) A compile error Unable to resolve helloworld in this context is produced (on either

Re: REQUEST for feedback on http://clojure.org

2010-11-15 Thread Alex Miller
Done. On Nov 15, 12:21 pm, Rick Moynihan rick.moyni...@gmail.com wrote: Hi Alex, I have one more Clojure Group for you: The Manchester (UK) Clojure Dojo http://manchester.clojuredojo.com/ I'm currently in the process of organising our next meeting, but a link on the clojure.org website

Re: Closures eat permgen?

2010-11-15 Thread Alan
On Nov 15, 12:12 pm, Alyssa Kwan alyssa.c.k...@gmail.com wrote: In your example, my-generator isn't the concern.  It's the call to my- generator that creates functions, each of which creates bytecode, is loaded as a class, then is instantiated, and finally invoked. Not true. Compiling

Re: Performance of seq on empty collections

2010-11-15 Thread Alan
Yes, the API *does* suggest using seq to check for emptiness. (empty? x) is implemented as (not (seq x)). You certainly won't ever get improved performance by using empty? - at best you break even, most of the time you lose. For example: (if (empty? x) ; empty branch ; not-empty branch Can be

Re: Performance of seq on empty collections

2010-11-15 Thread David Sletten
On Nov 15, 2010, at 4:41 PM, Alan wrote: Yes, the API *does* suggest using seq to check for emptiness. (empty? x) is implemented as (not (seq x)). You certainly won't ever get improved performance by using empty? - at best you break even, most of the time you lose. For example: The only

Re: Dependency between files problem

2010-11-15 Thread Phil Hagelberg
On Mon, Nov 15, 2010 at 11:35 AM, trying clj trying...@gmail.com wrote: A compile error Unable to resolve helloworld in this context is produced (on either latest clojure-maven-plugin or Leiningen). If the two defn's are switched places, the build completes successfully. This is very basic

Re: Dependency between files problem

2010-11-15 Thread Ken Wesson
On Mon, Nov 15, 2010 at 2:35 PM, trying clj trying...@gmail.com wrote: File example\some.clj (ns example.some (:use example.someother)) (defn helloworld [] (print helloworld)) File example\someother.clj: (ns example.someother (:use example.some)) (defn sample [] (helloworld)) A

help to improve a multimethod with a vaguely interesting dispatch function

2010-11-15 Thread Bob Hutchison
Hi, I'm trying to work out a way to define a multimethod dispatch function that will allow me to make a decision based on two values. In the example below I'm using symbols for the values of the major and minor values, mostly for convenience. What I'm trying to do is dispatch a multifunction

Re: Closures eat permgen?

2010-11-15 Thread Ken Wesson
On Mon, Nov 15, 2010 at 4:24 PM, Alan a...@malloys.org wrote: On Nov 15, 12:12 pm, Alyssa Kwan alyssa.c.k...@gmail.com wrote: In your example, my-generator isn't the concern.  It's the call to my- generator that creates functions, each of which creates bytecode, is loaded as a class, then is

Re: Performance of seq on empty collections

2010-11-15 Thread Ken Wesson
On Mon, Nov 15, 2010 at 4:41 PM, Alan a...@malloys.org wrote: Yes, the API *does* suggest using seq to check for emptiness. (empty? x) is implemented as (not (seq x)). You certainly won't ever get improved performance by using empty? - at best you break even, most of the time you lose. For

Re: Performance of seq on empty collections

2010-11-15 Thread Meikel Brandmeyer
Hi, Am 15.11.2010 um 23:07 schrieb Ken Wesson: (loop [s some-coll o nil] (if (empty? s) o (let [f (first s)] (blah blah blah s blah blah blah f blah blah blah) (recur (rest s) (conj o foobar) or some similar control flow structure, where s gets first and rest

Re: shorter alternatives for `comp' and `partial'

2010-11-15 Thread Paul Hobbs
Coming from Haskell, where composition and partial functions are cheap and free in terms of character count, it is actually pretty discouraging to have to spell it out in Clojure for the same effect. Some of the cases where you should be using multiple expressions in Clojure would be perfectly

Re: shorter alternatives for `comp' and `partial'

2010-11-15 Thread Cyrus Harmon
I think the minimal character count for composition and partial functions in haskell are some of the reasons that haskell code is so impenetrable to non-haskell hackers. Feel free to rig up crazy unicode characters to any identifier you want in your own code, just don't ask me to read or debug

Re: Performance of seq on empty collections

2010-11-15 Thread Ken Wesson
On Mon, Nov 15, 2010 at 6:49 PM, Meikel Brandmeyer m...@kotka.de wrote: Changing the above code to the following (which is similarly readable) should give an immediate speed bump. Rich once stated something around 20%, although I have not verified the numbers and this was quite a while ago...

Re: REQUEST for feedback on http://clojure.org

2010-11-15 Thread Tim Robinson
The main page link to API is a little confusing/annoying. I expect it to go here: http://clojure.org/api ( I expect this because doing a google search on clojure api brings it up) However the main page link to API goes directly to here: http://clojure.github.com/clojure/ It's kind of

Re: Performance of seq on empty collections

2010-11-15 Thread Sean Corfield
On Mon, Nov 15, 2010 at 5:31 PM, Ken Wesson kwess...@gmail.com wrote: Eh. I'd heard first and rest had replaced next. No? rest and next do different things: rest - Returns a possibly empty seq of the items after the first. Calls seq on its argument. next - Returns a seq of the items after the

Re: (:multiplexing clojure.contrib.sql = nil?)

2010-11-15 Thread Daniel Bell
I may be using the term wrong; while concurrency isn't necessary, I'm really just looking to minimize the # of times I'm opening/closing connections, but also looking to minimize unnecessary open connections. I suspect what I'm really looking for is a macro to detect every instance of

Re: Closures eat permgen?

2010-11-15 Thread Alyssa Kwan
I totally misunderstood the role of the EVAL context flag in the compile method of ObjExpr. Is there a general writeup anywhere of how the compiler works, especially the interaction of parse and emit? On Nov 15, 4:59 pm, Ken Wesson kwess...@gmail.com wrote: On Mon, Nov 15, 2010 at 4:24 PM, Alan

Re: Performance of seq on empty collections

2010-11-15 Thread Meikel Brandmeyer
Hi, On 16 Nov., 02:31, Ken Wesson kwess...@gmail.com wrote: Eh. I'd heard first and rest had replaced next. No? No. This was a misinformation. To elaborate a bit more on the differences pointed out by Sean: next returns nil if there are no more items in the sequence, which is nice to use in

bimaps in clojure

2010-11-15 Thread Sunil S Nandihalli
Hello everybody, Is there something like a bimap in clojure? I know I can have two regular hash-maps .. but I was wondering if there is a better implementation..? a similar implementation in c++ is http://beta.boost.org/doc/libs/1_41_0/libs/bimap/doc/html/index.html Thanks, Sunil. -- You

Re: (:multiplexing clojure.contrib.sql = nil?)

2010-11-15 Thread Shantanu Kumar
The idiomatic JDBC solution to this problem is a DataSource: http://download.oracle.com/javase/6/docs/api/javax/sql/DataSource.html http://bitbucket.org/kumarshantanu/clj-dbcp/src A connection-pooling data source does exactly that - it recycles the connection for many statements. The close()

Re: shorter alternatives for `comp' and `partial'

2010-11-15 Thread Paul Hobbs
Well, for those who use emacs, you could always make it *look* like it was pretty... For example: (eval-after-load 'clojure-mode '(font-lock-add-keywords 'clojure-mode `((\\fn\\ (0 (progn (compose-region (match-beginning 0) (match-end 0) ,(make-char 'greek-iso8859-7 107)) ;; a lambda