Re: LDAP lib

2009-11-19 Thread Aravind Gottipati
On Wed, Nov 18, 2009 at 9:39 PM, Sean Devlin wrote: > > I need to query an LDAP directory.  Is there an existing Clojure > library already?  Simply trying to avoid reinventing the wheel. > I worked on some wrapper code to call the Novell ldap library (http://developer.novell.com/documentation/jld

Re: positions

2009-11-19 Thread Alex Burka
Yesterday I need a similar function (interleave, but don't stop when the shortest seq ends), so I wrote it. I subsequently refactored the program and didn't need it anymore, but here it is anyway. It could probably be written more succinctly, but I followed the implementation of core/interleave

Re: take repeatedly alternative?

2009-11-19 Thread John Harrop
On Thu, Nov 19, 2009 at 9:17 PM, Mark Triggs wrote: > A good example is: > > (take 10 (repeatedly #(rand-int 100))) > > to get a bunch of random integers. I actually quite like this idiom, > even if there's a bit of ascii involved :) > Why not abstract it some, though? (defn rand-seq [range]

Re: "Oh, yeah, transients are fast!"

2009-11-19 Thread Richard Newman
> clojure-1.1.0-alpha-SNAPSHOT.jar for this. is there something about > having to have the jit warm up or something over a zillion runs? I see an immediate speed improvement from transients with a recent Clojure, and after a few runs the difference is obvious. user=> (time (def v (vrange 10

Re: "Oh, yeah, transients are fast!"

2009-11-19 Thread Stuart Halloway
I have seen perf consistent with the documentation when using Java 6 and server vm. Stu > hm. > > i copied and pasted the examples from the transient page into a local > test.clj, and i don't really see a significant performance difference > (it should be an order of magnitude according to the

Re: take repeatedly alternative?

2009-11-19 Thread Mark Triggs
A good example is: (take 10 (repeatedly #(rand-int 100))) to get a bunch of random integers. I actually quite like this idiom, even if there's a bit of ascii involved :) Mark Tom Hicks writes: > I'm not quite sure why you would want to say > > (take n (repeatedly fn)) > > It appears to

"Oh, yeah, transients are fast!"

2009-11-19 Thread Raoul Duke
hm. i copied and pasted the examples from the transient page into a local test.clj, and i don't really see a significant performance difference (it should be an order of magnitude according to the web page). macbook pro. just downloaded sources and built clojure-1.1.0-alpha-SNAPSHOT.jar for this.

Re: take repeatedly alternative?

2009-11-19 Thread Tom Hicks
I'm not quite sure why you would want to say (take n (repeatedly fn)) It appears to me that a fn called 'repeatedly' is really being executed for its side-effects. If you are interested in a sequence of values being returned from fn, then make fn return a lazy sequence and 'take' will work on t

Re: positions

2009-11-19 Thread John Harrop
On Thu, Nov 19, 2009 at 7:51 PM, Alex Osborne wrote: > John Harrop wrote: > > This is just (sort (concat [1 2 3 4 5 6 7] [3 2 7])) though. > > > > > > I think he also wants the original order of the first input coll to be > > preserved, though. Sort wouldn't do that. > > Hmmm.. that's a prett

Re: positions

2009-11-19 Thread Alex Osborne
John Harrop wrote: > This is just (sort (concat [1 2 3 4 5 6 7] [3 2 7])) though. > > > I think he also wants the original order of the first input coll to be > preserved, though. Sort wouldn't do that. Hmmm.. that's a pretty weird set of requirements. Usually a multiset/bag is unordered

Re: positions

2009-11-19 Thread John Harrop
On Thu, Nov 19, 2009 at 7:15 PM, Alex Osborne wrote: > John Harrop wrote: > > On Thu, Nov 19, 2009 at 7:00 PM, Sean Devlin > > wrote: > > > > That's why there are two separate functions do do what you suggest > > > > user=>(interleave [1 2 3 4] [1 2 3 4])

Re: positions

2009-11-19 Thread Alex Osborne
John Harrop wrote: > On Thu, Nov 19, 2009 at 7:00 PM, Sean Devlin > wrote: > > That's why there are two separate functions do do what you suggest > > user=>(interleave [1 2 3 4] [1 2 3 4]) > (1 1 2 2 3 3 4 4) > > user=> (concat [1 2 3 4] [1 2 3 4

Re: positions

2009-11-19 Thread John Harrop
On Thu, Nov 19, 2009 at 7:00 PM, Sean Devlin wrote: > That's why there are two separate functions do do what you suggest > > user=>(interleave [1 2 3 4] [1 2 3 4]) > (1 1 2 2 3 3 4 4) > > user=> (concat [1 2 3 4] [1 2 3 4]) > (1 2 3 4 1 2 3 4) > Poor choice of example. I think he meant even if he

Re: positions

2009-11-19 Thread Sean Devlin
That's why there are two separate functions do do what you suggest user=>(interleave [1 2 3 4] [1 2 3 4]) (1 1 2 2 3 3 4 4) user=> (concat [1 2 3 4] [1 2 3 4]) (1 2 3 4 1 2 3 4) There's also the doall function to override lazyness. On Nov 19, 6:38 pm, nchubrich wrote: > Yeah, remove will work

Re: positions

2009-11-19 Thread nchubrich
Yeah, remove will work for one kind of 'multiset' operator I am thinking of. The others might as well preserve as much order as possible. For instance, (add [1 2 3 4] [1 2 3 4]) could have two interpretations; you just append, or you add like elements to positions of like elements, so you get [1

Re: positions

2009-11-19 Thread Alex Osborne
ajuc wrote: > On 20 Lis, 01:49, nchubrich wrote: >> While we're on the topic, where is something like (subtract [1 2 3 3 4 >> 4 5 6] evens) -> (1 3 3 5)? Doesn't seem to be in seq-utils or API. >> Seems like there should be a parallel "multiset" library for colls, to >> clojure.set. (I guess the

Re: positions

2009-11-19 Thread ajuc
On 20 Lis, 01:49, nchubrich wrote: > While we're on the topic, where is something like (subtract [1 2 3 3 4 > 4 5 6] evens) -> (1 3 3 5)? Doesn't seem to be in seq-utils or API. > Seems like there should be a parallel "multiset" library for colls, to > clojure.set. (I guess there could be two ve

Re: positions

2009-11-19 Thread nchubrich
While we're on the topic, where is something like (subtract [1 2 3 3 4 4 5 6] evens) -> (1 3 3 5)? Doesn't seem to be in seq-utils or API. Seems like there should be a parallel "multiset" library for colls, to clojure.set. (I guess there could be two versions of subtract, one that removes \all, a

Re: leiningen - a Clojure build tool

2009-11-19 Thread Alex Osborne
meb wrote: > Was the name Leiningen inspired by the Esquire short story "Leiningen > vs. Ants"? That would be a brilliantly obscure way to challenge the > predominance of ant. Or did you have another reference in mind. From the Leiningen README: "Leiningen!" he shouted. "You're insane! They're

Re: leiningen - a Clojure build tool

2009-11-19 Thread meb
Was the name Leiningen inspired by the Esquire short story "Leiningen vs. Ants"? That would be a brilliantly obscure way to challenge the predominance of ant. Or did you have another reference in mind. Mark On Nov 18, 2:29 am, Phil Hagelberg wrote: > I'm pleased to announce the initial release

Re: [ANN] Clojars - a Clojure community jar repository

2009-11-19 Thread Alex Osborne
Laurent PETIT wrote: > Hello, > > Just an idea out of my head : could it be possible for the pom.xml to be > included in the jar, in the META-INF/ directory ? > > This would even further simplify the process, wouldn't it ? :) That's a great idea! Can't believe it didn't occur to me. :-) I loo

Re: [ANN] Clojars - a Clojure community jar repository

2009-11-19 Thread Laurent PETIT
Hello, Just an idea out of my head : could it be possible for the pom.xml to be included in the jar, in the META-INF/ directory ? This would even further simplify the process, wouldn't it ? :) 2009/11/19 Alex Osborne > Alex Osborne wrote: > > > But if even that's too long and complicated for y

Re: unsubscribe

2009-11-19 Thread John Harrop
On Thu, Nov 19, 2009 at 2:39 PM, Timothy McDowell wrote: > unsubscribe Interesting. Most mailing lists I subscribe to get one of these a week, or even a day. This is the first missent unsubscribe the clojure list's had in months. -- You received this message because you are subscribed to the G

Re: positions

2009-11-19 Thread John Harrop
On Thu, Nov 19, 2009 at 1:23 PM, Sean Devlin wrote: > Try clojure.contrib.seq-utils :) > > As a learning exercise, I'd recommend re-writing it to be lazy. Your > version is eager because it uses loop. In order to make it lazy, > you'd want to construct a lazy-seq. See the macro w/ the same name

Re: [ANN] Clojars - a Clojure community jar repository

2009-11-19 Thread Alex Osborne
Alex Osborne wrote: > But if even that's too long and complicated for you I wrote a Leiningen > plugin which makes it just: > > lein push Looks like JSch library that the lein-clojars plugin uses doesn't work with ssh-keygen's DSA keys and I overlooked adding passphrase support. I'm working o

unsubscribe

2009-11-19 Thread Timothy McDowell
unsubscribe -- 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 em

Re: positions

2009-11-19 Thread nchubrich
Thanks Sean, I'll do the exercise. I don't know how I missed it in seq-utils. After months of programming Clojure, I realize how much I still have to learn. (Knowledge is power; knowledge of lack of knowledge is power to power.) Nick. -- You received this message because you are subscribe

Re: positions

2009-11-19 Thread Sean Devlin
Try clojure.contrib.seq-utils :) As a learning exercise, I'd recommend re-writing it to be lazy. Your version is eager because it uses loop. In order to make it lazy, you'd want to construct a lazy-seq. See the macro w/ the same name. Another choice is to use built-in functions, like this: (d

positions

2009-11-19 Thread nchubrich
Is this function part of the API or any contrib? I couldn't find it: (defn positions [pred coll] (loop [coll coll i 0 accum []] (if (empty? coll) accum (if (pred (first coll)) (recur (rest coll) (inc i) (conj accum i)) (recur (rest coll) (inc i) accum) -- You rec

Re: swap two elements in an arbitrary collection

2009-11-19 Thread David Brown
On Thu, Nov 19, 2009 at 05:51:22AM -0500, John Harrop wrote: >On Thu, Nov 19, 2009 at 4:31 AM, Lauri Pesonen wrote: > >> (clojure.walk/macroexpand-all '(cond (even? 2) :foo (odd? 2) :bar :else >> :baz)) >> (if (even? 2) :foo (if (odd? 2) :bar (if :else :baz nil))) > >Eeeuw. Perhaps the cond macro

Re: Datatypes and Protocols - early experience program

2009-11-19 Thread Krukow
On Nov 19, 12:01 am, samppi wrote: > Question: are the general mechanisms for accessing and setting fields > their keywords and assoc respectively: >   (deftype Bar [a b c d e]) >   (def b (Bar 1 2 3 4 5)) >   (:c b) >   (def c (assoc b :e 2)) > Does (:c b) and (assoc b :e 2) take advantage of Bar

Re: [ANN] Clojars - a Clojure community jar repository

2009-11-19 Thread Baishampayan Ghose
Alex, > I've been working on an easy to use open source community repository to > complement Leiningen in making building and dependency management easier > for Clojure projects. Beautiful work, Alex. Really amazing. Kudos to you and the awesome Clojure community. Regards, BG -- Baishampaya

Re: Checked exceptions in LazySeq

2009-11-19 Thread Meikel Brandmeyer
Hi, On Nov 19, 1:42 pm, David Powell wrote: > LazySeq is wrapping my InterruptedExceptions in several layers of > RuntimeException, which is a > bit awkward, because then my top level code spews pages of exceptions, rather > than just reporting > that the process was cancelled. > > Is there an

[ANN] Clojars - a Clojure community jar repository

2009-11-19 Thread Alex Osborne
I've been working on an easy to use open source community repository to complement Leiningen in making building and dependency management easier for Clojure projects. http://clojars.org/ It's inspired by the fantastic Gemcutter.org website that the Ruby community uses. The repository is in th

Checked exceptions in LazySeq

2009-11-19 Thread David Powell
LazySeq is wrapping my InterruptedExceptions in several layers of RuntimeException, which is a bit awkward, because then my top level code spews pages of exceptions, rather than just reporting that the process was cancelled. Is there anything better that could be done? + Change the interfac

Re: leiningen - a Clojure build tool

2009-11-19 Thread mac
On Nov 19, 8:50 am, Martin DeMello wrote: > On Thu, Nov 19, 2009 at 10:52 AM, Phil Hagelberg wrote: > > > I must confess I don't understand the "avoid the command-line" mindset > > at all, so I need a little extra explanation. > > It's a matter of context switching. If I'm working in an IDE, I wa

Re: swap two elements in an arbitrary collection

2009-11-19 Thread John Harrop
On Thu, Nov 19, 2009 at 4:31 AM, Lauri Pesonen wrote: > (clojure.walk/macroexpand-all '(cond (even? 2) :foo (odd? 2) :bar :else > :baz)) > (if (even? 2) :foo (if (odd? 2) :bar (if :else :baz nil))) Eeeuw. Perhaps the cond macro should check if the last condition is self-evaluating and, if it is

Re: swap two elements in an arbitrary collection

2009-11-19 Thread Lauri Pesonen
2009/11/18 Jacek Laskowski : > > user=> (macroexpand '(-> v (assoc i (v j)) (assoc j (v i > (assoc (clojure.core/-> v (assoc i (v j))) j (v i)) > > How to expand the macro in the subform above? You can use clojure.walk/macroexpand-all: (clojure.walk/macroexpand-all '(cond (even? 2) :foo (odd?

BILFP User Group

2009-11-19 Thread Volkan YAZICI
Hi, Would anybody mind adding BILFP[1] (Bilkent University Comp. Eng. Dept. Functional Programming Society) to the "Clojure User Groups" page[2], please? Regards. [1] http://bilfp.wikidot.com/ [2] http://clojure.org/community -- You received this message because you are subscribed to the Goog