Re: finding a key which does not exist in the map

2011-05-27 Thread Ken Wesson
On Fri, May 27, 2011 at 2:27 AM, Sunil S Nandihalli wrote: > I don't think yours is going to be anymore efficient than the one I had > initially posted .. In fact it might be slower in majority of the cases.. Yes; yours will terminate as soon as it finds a "hole" in the numbering, whereas Walter'

a chaing macro with named-intermediate values

2011-05-27 Thread Sunil S Nandihalli
Hello everybody, I had previously seen a conversation where some body had a macro where they would give a name to the intermediate values .. I am not able find it via google .. can some body help me here? The problem is (-> x f g) being re-written as (g (f x)) I can't refer to intermediate value

Aw: a chaing macro with named-intermediate values

2011-05-27 Thread Meikel Brandmeyer
Hi, a quick'n'works-now way is: (-> x abc ((fn [x] (do-stuff-with x (refering-twice x (xyz fgh)) Or: (#(do-stuff-with % (refering-twice %))) Sincerely Meikel -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send ema

Re: a chaing macro with named-intermediate values

2011-05-27 Thread Sunil S Nandihalli
Hi Miekel Yea I have done that but it seems clunky .. :( however here is my first attempt at it .. which is not working .. may be you can help me here.. (defmacro ->var [first & exprs] (if (seq exprs) `(let [~'var ~first] (->var ~@exprs)) ~first)) I don't understand

Re: a chaing macro with named-intermediate values

2011-05-27 Thread Sunil S Nandihalli
(->var 10 (* 2 var)) should be returning 20 ... On Fri, May 27, 2011 at 1:08 PM, Sunil S Nandihalli < sunil.nandiha...@gmail.com> wrote: > Hi Miekel > > Yea I have done that but it seems clunky .. :( > > however here is my first attempt at it .. which is not working .. may be > you can help me he

Re: a chaing macro with named-intermediate values

2011-05-27 Thread Sunil S Nandihalli
ah it works now .. I had to just remove the ~ behind first .. Thanks, Sunil On Fri, May 27, 2011 at 1:09 PM, Sunil S Nandihalli < sunil.nandiha...@gmail.com> wrote: > (->var 10 (* 2 var)) should be returning 20 ... > > > On Fri, May 27, 2011 at 1:08 PM, Sunil S Nandihalli < > sunil.nandiha...@gma

Aw: Re: a chaing macro with named-intermediate values

2011-05-27 Thread Meikel Brandmeyer
Hi, the ~ in front of first is too much, because first is not in a syntax-quote. Also I wouldn't capture var because it is special form. (defmacro bound-> [fst & more] (if (seq more) `(let [~'v ~fst] (bound-> ~@more)) fst)) Sincerely Meikel -- You received this message beca

Re: Re: a chaing macro with named-intermediate values

2011-05-27 Thread Sunil S Nandihalli
(defmacro thrush-with-sym [[sym] first & exprs] (if (seq exprs) `(let [~sym ~first] (thrush-with-sym [~sym] ~@exprs)) first)) a small variation with the ability to chose any symbol for intermediate values.. Just thought of sharing it ... Thanks, Sunil. On Fri, May 27, 2011 at 1:15 PM, Meikel

fs and with-tempdir

2011-05-27 Thread David Jagoe
G'day all, Thanks Miki for fs, also coming from a Python background I am enjoying the familiarity! The thing that I most often use tempdir for is unit testing where I want to clean up immediately in a finally block. (defmacro with-tempdir "bindings => [name path] Evaluates body in a try ex

Gradle + cojuresque + SLIME?

2011-05-27 Thread sthuebner
Hi, can anybody recommend a way to integrate clojuresque (1.4.1) with SLIME? I did some googling but couldn't find any helpful pointers. Thanks! Stefan -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@goog

Re: Radically simplified Emacs and SLIME setup

2011-05-27 Thread Wolodja Wentland
On Thu, May 26, 2011 at 20:37 -0700, J.R. Garcia wrote: > I compiled a new version of emacs from source and started it up. > clojure-jack-in just worked flawlessly. This is stupid simple! Thanks > for your hard work! It's much appreciated for emacs newcomers like me > (I'm a vim user)! I am curiou

Aw: Gradle + cojuresque + SLIME?

2011-05-27 Thread Meikel Brandmeyer
Hi, Am Freitag, 27. Mai 2011 12:19:55 UTC+2 schrieb sthu...@googlemail.com: > > can anybody recommend a way to integrate clojuresque (1.4.1) with SLIME? I > did > some googling but couldn't find any helpful pointers. > You do something like: dependencies { compile "org.clojure:clojure:1.3.

Re: Radically simplified Emacs and SLIME setup

2011-05-27 Thread Ambrose Bonnaire-Sergeant
On Fri, May 27, 2011 at 6:31 PM, Wolodja Wentland wrote: > On Thu, May 26, 2011 at 20:37 -0700, J.R. Garcia wrote: > > I compiled a new version of emacs from source and started it up. > > clojure-jack-in just worked flawlessly. This is stupid simple! Thanks > > for your hard work! It's much appre

Re: Aw: Gradle + cojuresque + SLIME?

2011-05-27 Thread sthuebner
Hi Meikel, it's been a while :) Thanks a lot for getting me started! I had to tweak it a little, but here's what now works for me: dependencies { compile 'org.clojure:clojure:1.2.0' compile 'org.clojure:clojure-contrib:1.2.0' development "swank-clojure:swank-clojure:1.2.1" // <- NOTE

Aw: Re: Aw: Gradle + cojuresque + SLIME?

2011-05-27 Thread Meikel Brandmeyer
Hallo, Am Freitag, 27. Mai 2011 14:38:35 UTC+2 schrieb sthu...@googlemail.com: > development "swank-clojure:swank-clojure:1.2.1" // <- NOTE the difference > main = "swank.swank/start-repl" // <- NOTE the difference I'm a vim guy. :) So I don't know the swank details. :) > task runSwank(type: cl

Re: Re: a chaing macro with named-intermediate values

2011-05-27 Thread Sam Ritchie
Hey all, pallet.thread-expr contains arg->, which can be used liked (-> 1 (arg-> [x] (+ x))) => 2. Here's the library, with a bunch of other threading macros: https://github.com/pallet/thread-expr and the implementation of that particular one: (defmacro arg-> "Lexically assign the threaded ar

find first non nil element of sequence

2011-05-27 Thread MarisO
To find first defined Option in scala I do this: sol.find(_.isDefined).getOrElse(None) I managed to do the same in clojure: (some #(if (nil? %) false %) sol) Is there a better way ? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this

Re: find first non nil element of sequence

2011-05-27 Thread Sam Ritchie
Hey, how about this? (defn first-non-nil [xs] (first (filter (complement nil?) xs))) On Fri, May 27, 2011 at 9:56 AM, MarisO wrote: > To find first defined Option in scala I do this: > > sol.find(_.isDefined).getOrElse(None) > > I managed to do the same in clojure: > > (so

Re: find first non nil element of sequence

2011-05-27 Thread Ulises
You could use identity as a predicate to filter: user=> (def s [nil nil 1 2 3]) #'user/s user=> (first (filter identity s)) 1 user=> U -- 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

Re: find first non nil element of sequence

2011-05-27 Thread B Smith-Mannschott
On Fri, May 27, 2011 at 16:03, Ulises wrote: > You could use identity as a predicate to filter: > > user=> (def s [nil nil 1 2 3]) > #'user/s > user=> (first (filter identity s)) > 1 > user=> (first (filter identity [nil false :oops])) --> :oops false is not nil. -- You received this message b

Re: find first non nil element of sequence

2011-05-27 Thread Ulises
> false is not nil. Ugh! Well spotted :) U -- 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 uns

Aw: find first non nil element of sequence

2011-05-27 Thread Meikel Brandmeyer
Hi, Am Freitag, 27. Mai 2011 15:56:47 UTC+2 schrieb MarisO: > > To find first defined Option in scala I do this: > > sol.find(_.isDefined).getOrElse(None) > > I managed to do the same in clojure: > > (some #(if (nil? %) false %) sol) > > Is there a better way ? Another way: (first (keep ide

Re: Recur and primitives?!?

2011-05-27 Thread Armando Blancas
> I doubt it. Rather, m is now an int so (dec m) can be a valid recur for h. Yeap, that makes more sense, after all the change was on m. Maybe the error message could read "h must receive matching primitive." -- You received this message because you are subscribed to the Google Groups "Clojure"

Re: Debian packages

2011-05-27 Thread Wolodja Wentland
On Tue, May 24, 2011 at 21:41 -0700, Phil Hagelberg wrote: > It looks like Clojure 1.1.0 and the corresponding version of contrib > were packaged for Debian. Is the fellow who packaged that still > around? Are there any plans to package 1.2.1 and contrib 1.2.0? Great to see some interest for Debia

Re: Clojure, Swank, and Leiningen with Emacs on Mac OS X

2011-05-27 Thread Sathish Kumar
Hi, This is a step by step guide to setup Leiningen, Swank-Clojure and SLIME for Emacs. http://languageagnostic.blogspot.com/2011/05/clojure-in-emacs.html It is partly based on technomancy's post here http://technomancy.us/126 Thanks, Sathish On Wed, May 25, 2011 at 12:21 PM, michele wrote:

Re: Recur and primitives?!?

2011-05-27 Thread David Nolen
On Thu, May 26, 2011 at 7:54 PM, Andreas Kostler < andreas.koestler.le...@gmail.com> wrote: > Hi guys, > I'm kinda lost as to what's going on here...With clojure-1.2.0 > > (defn bin-search [v k c] > (loop [l 0 > h (dec (count v))] >(if (> l h) false >(let [m (quot (+ l h) 2) >

Re: fs and with-tempdir

2011-05-27 Thread Miki
I've opened https://bitbucket.org/tebeka/fs/issue/5/with-tempdir-macro and will try to get to it soon. If you'd like to submit a patch (with test and documentation) ... ;) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send em

Re: find first non nil element of sequence

2011-05-27 Thread MarisO
there is find-first in contrib (find-first #(not (nil? %)) sol) On May 27, 3:12 pm, Meikel Brandmeyer wrote: > Hi, > > Am Freitag, 27. Mai 2011 15:56:47 UTC+2 schrieb MarisO: > > > > > To find first defined Option in scala  I do this: > > > sol.find(_.isDefined).getOrElse(None) > > > I managed

Re: fs and with-tempdir

2011-05-27 Thread David Jagoe
Cool, I'll clean up the code and submit it along with tests and docs. While Im about it i may as well write the equivalent macro for tempfile. Cheers David On 27 May 2011 5:52 PM, "Miki" wrote: I've opened https://bitbucket.org/tebeka/fs/issue/5/with-tempdir-macro and will try to get to it soon

pmap causes waiting

2011-05-27 Thread Marek Kubica
Hi, I wrote this script: (def number (ref 0)) (def add1 (partial + 1)) (def num-threads (Integer/parseInt (first *command-line-args*))) (def increments (Integer/parseInt (second *command-line-args*))) (defn add-number [field times] (dorun (repeatedly times (fn []

Re: find first non nil element of sequence

2011-05-27 Thread Michael Wood
On 27 May 2011 18:01, MarisO wrote: > there is find-first in contrib > > (find-first #(not (nil? %)) sol) Or: (find-first (complement nil?) coll) or: (first (filter (complement nil?) coll)) but I like Meikel's (first (keep identity coll)) suggestion, even if I find it less straight-forward.

Re: find first non nil element of sequence

2011-05-27 Thread Michael Wood
On 27 May 2011 18:30, Michael Wood wrote: [...] > or: > > (first (filter (complement nil?) coll)) Ah, sorry, I see Sam already suggested this one. -- Michael Wood -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email t

Re: pmap causes waiting

2011-05-27 Thread Michael Wood
On 27 May 2011 18:28, Marek Kubica wrote: > Hi, > > I wrote this script: > > (def number (ref 0)) > (def add1 (partial + 1)) > (def num-threads (Integer/parseInt (first *command-line-args*))) > (def increments (Integer/parseInt (second *command-line-args*))) > > (defn add-number [field times] >  (

Re: pmap causes waiting

2011-05-27 Thread Marek Kubica
On Fri, 27 May 2011 18:35:47 +0200 Michael Wood wrote: > > And instead of exiting, it "hangs" in this state for a number of > > seconds before finally quitting. Why is that so and how can I fix > > that? > > > > I tried calling (System/exit 0) in the end, but then it didn't even > > display anyth

Re: Debian packages

2011-05-27 Thread Phil Hagelberg
On May 27, 7:35 am, Wolodja Wentland wrote: > On Thu, May 26, 2011 at 16:36 -0700, Phil Hagelberg wrote: > > No, I am working on a Leiningen package and want an up-to-date .deb on > > which to depend. > > That is great! The ITP for leiningen [3] is currently owned by Ramakrishnan > Muthukrishnan a

Re: Architecture for a Clojure project

2011-05-27 Thread Paul deGrandis
The architecture of a large system should designed independent of the language in which you're working You should strive to identify the architecture styles you need for your problem domain, and then intelligently compose them with connectors that help fulfill your nonfunctional requirements/guara

Re: Architecture for a Clojure project

2011-05-27 Thread László Török
IMHO, CQRS and CEP are identical at conceptual level, but they have been established by people having different backgrounds, thus cooking up different vocabulary for these practices. Practitioners tend stress different aspects of the system but essentially they're rather trying to solve same class

macro says Can't use qualified name as parameter

2011-05-27 Thread nil
I was looking at http://saucelabs.com/blog/index.php/2009/12/running-your-selenium-tests-in-parallel-clojure/ and in the comments, :Scott suggested that a macro could reduce some of the boilerplate that you see here: (def test-google { :name "google" :test (fn [client] (doto cl

Re: macro says Can't use qualified name as parameter

2011-05-27 Thread Jonathan Fischer Friberg
"client" is a qualified name. So either use "client#", but you don't want that since the macro should be anaphoric. The other option, which you're close to, is using "~'client", which essentially makes "client" 'unqualified'. Jonathan On Fri, May 27, 2011 at 7:46 PM, nil wrote: > I was looking

Re: macro says Can't use qualified name as parameter

2011-05-27 Thread Ken Wesson
On Fri, May 27, 2011 at 1:46 PM, nil wrote: > I was looking at > http://saucelabs.com/blog/index.php/2009/12/running-your-selenium-tests-in-parallel-clojure/ > and in the comments, :Scott suggested that a macro could reduce some > of the boilerplate that you see here: > > (def test-google >  { >

Clojure 1.3 Alpha 8

2011-05-27 Thread Chris Redinger
Clojure 1.3 Alpha 8 is now available at http://clojure.org/downloads = CONTENTS = 0 Changes from 1.3 Alpha 7 to 1.3 Alpha 8 1 Changes from 1.3 Alpha 6 to 1.3 Alpha 7 2 Changes from 1.3 Alpha 5 to 1.3 Alpha 6 3 Changes from 1.3 Alpha 4 to 1.3 Alpha 5 4 Changes from 1.3 Alpha 3 to 1.3 Alpha 4

[ANN] GUI FTW -- a declarative GUI framework for Swing and SWT

2011-05-27 Thread Szymon Witamborski
Greetings :) I'm happy to announce GUI FTW. It's a declarative GUI framework that works on top of both Swing and SWT (it's not tied to any particular toolkit at it's core). Because it's abstract, any custom widgets are supported. >From a programmer perspective it borrows familiar concepts from