Re: Mapping a function over a map's values

2009-03-22 Thread Jeff Valk
On Sun, 22 Mar 2009 at 23:27, Jeff Valk wrote: > Ah, golf... :-) > > (defn mapmap [f m] > (into {} (for [[k v] m] [k (f v)]))) For the record, I think the original approach is the most clear. And it's actually shorter. (defn mapmap [f m] (zipmap (keys m) (map f (vals m --~--~---

Re: What makes Clojure an easier Lisp?

2009-03-22 Thread Rayne
Clojure is not a pure functional programming language. It allows side- effects everywhere. On Mar 22, 3:26 pm, Joshua Fox wrote: > I dove into Lisp and Scheme several times in the past, but only with Clojure > did Lisp  really "catch"? > 1. Clojure abandons the 1950's cruft, with all-caps and ab

Re: New release 20090320

2009-03-22 Thread Howard Lewis Ship
I'd like to remind people using Clojure and Maven that they can get nightly builds of Maven via the Tapestry360 maven snapshot repository: http://tapestry.formos.com/maven-snapshot-repository To access the nightly snapshot in Maven, you must update your pom.xml's element (creating it as necessa

Re: Mapping a function over a map's values

2009-03-22 Thread Kevin Downey
ooh for On Sun, Mar 22, 2009 at 9:27 PM, Jeff Valk wrote: > > On 22 March 2009 23:14, Timothy Pratley wrote: > >> Golf time! >> >> (defn mapmap [f m] >>     (into {} (map (fn [[x y]] [x (f y)]) m))) > > Ah, golf... :-) > > (defn mapmap [f m] >  (into {} (for [[k v] m] [k (f v)]))) > > > > --

Re: User contributed packages (Cabel, CPAN, etc)

2009-03-22 Thread Aaron Cohen
Maven also downloads jars and dependencies automatically as a typical part of its functionality. It typically saves them in "${user.home}/.m2/repository-.jar" The naming is pretty consistent because maven strongly encourages everyone to use the same conventions. (javadoc would be in the same

Re: Mapping a function over a map's values

2009-03-22 Thread Jeff Valk
On 22 March 2009 23:14, Timothy Pratley wrote: > Golf time! > > (defn mapmap [f m] > (into {} (map (fn [[x y]] [x (f y)]) m))) Ah, golf... :-) (defn mapmap [f m] (into {} (for [[k v] m] [k (f v)]))) --~--~-~--~~~---~--~~ You received this message becaus

Re: Mapping a function over a map's values

2009-03-22 Thread Timothy Pratley
Golf time! (defn mapmap [f m] (into {} (map (fn [[x y]] [x (f y)]) m))) On Mar 23, 2:51 pm, Kevin Downey wrote: > (defn mapmap [fn m] >     (into {} (map #(vector (first %) (fn (second %))) m))) --~--~-~--~~~---~--~~ You received this message because you ar

Re: The unshared part of two mostly-shared structures

2009-03-22 Thread e
> > > my programming language enchilada (www.enchiladacode.nl) interesting. I was thinking today about how STM reminds me of version control. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To pos

Re: Mapping a function over a map's values

2009-03-22 Thread Kevin Downey
(defn mapmap [fn m] (into {} (map #(vector (first %) (fn (second %))) m))) On Sun, Mar 22, 2009 at 1:10 PM, Jon Nadal wrote: > > I often need to map a function over the values of a map while > preserving keys--something like: > > [code] > (defn mapmap [fn m] >  (let [k (keys m) >        v (m

Re: STM and useful concurrency

2009-03-22 Thread e
i think it would be awesome if someone worked up a scenario . . . started using regular old java . . . and we could walk into a few gotchas, publicly/transparently, where a serious java guy could chime in ... and really see what the stm buys. Then we'd have an even richer appreciation for the STM

What makes Clojure an easier Lisp?

2009-03-22 Thread Joshua Fox
I dove into Lisp and Scheme several times in the past, but only with Clojure did Lisp really "catch"? 1. Clojure abandons the 1950's cruft, with all-caps and abbreviations like SETQ and CDR. However, Scheme does this too, without achieving the ease of Clojure. 2. Clojure is typically illustrated

Mapping a function over a map's values

2009-03-22 Thread Jon Nadal
I often need to map a function over the values of a map while preserving keys--something like: [code] (defn mapmap [fn m] (let [k (keys m) v (map fn (vals m))] (zipmap k v))) (mapmap inc {:a 0, :b 1}) [/code] Is there a more concise way to do this in Clojure? If not, is this some

Re: User contributed packages (Cabel, CPAN, etc)

2009-03-22 Thread Phil Hagelberg
Bradbev writes: > I feel that the next big growth phase for Clojure will be in the user > community and the code that we can generate. A good package manager > will help fuel that growth. I agree. The more I work with packages that have dependencies the more I realize that manually managing th

Re: version of -> short-circuiting on nil

2009-03-22 Thread Graham Fawcett
On Sun, Mar 22, 2009 at 9:05 PM, Stephen C. Gilardi wrote: > > On Mar 22, 2009, at 4:43 PM, Meikel Brandmeyer wrote: > >> Is .?. necessary? -> does the same job as .. by >> virtue of the .method notation, but is more general. >> So, why not get rid of .. and .?. completely? > > That sounds right

Re: contrib mmap/duck_streams for binary data

2009-03-22 Thread Sean
Could you throw this on github, so we can easily follow along with improvements? On Mar 22, 8:25 pm, "zoglma...@gmail.com" wrote: > While playing around and implementing straight up Humman compression, > I wrote a handful of utilities to conveinently play with byte and bit > streams because I di

STM and useful concurrency

2009-03-22 Thread Mark Volkmann
I'm trying to understand the degree to which Clojure's STM provides more concurrency than Java's blocking approach. I know it's difficult to make generalizations and that specific applications need to be measured, but I'll give it a go anyway. Clearly using STM (dosync with Refs) makes code easie

Re: Ant and debian 5.0 version issues

2009-03-22 Thread Dan Beauchesne
Michael Wood writes: > > Are you sure it's not trying to use gcj instead of Sun java? > > What do "java -version" and "javac -version" give you? And does > "update-alternatives --list java" or javac print anything? java -version: OpenJDK Runtime Environment (build 1.6.0_0-b11) OpenJDK Server

Re: version of -> short-circuiting on nil

2009-03-22 Thread Stephen C. Gilardi
On Mar 22, 2009, at 4:43 PM, Meikel Brandmeyer wrote: Is .?. necessary? -> does the same job as .. by virtue of the .method notation, but is more general. So, why not get rid of .. and .?. completely? That sounds right to me, Meikel. I'm in favor of keeping only -?> . --Steve smime.p7s De

Re: Behavior of clojure.set/union and hinting function arguments

2009-03-22 Thread Stuart Sierra
On Mar 22, 2:34 pm, Frantisek Sodomka wrote: > (defn f [#^Double x] (+ x 2)) => #'user/f > (f 3) => 5 > (f nil) => java.lang.NullPointerException (NO_SOURCE_FILE:0) > ; why NPE? nil is Java null. The Clojure "+" function eventually compiles to Java "+", which throws an exception on null. > (f

contrib mmap/duck_streams for binary data

2009-03-22 Thread zoglma...@gmail.com
While playing around and implementing straight up Humman compression, I wrote a handful of utilities to conveinently play with byte and bit streams because I didn't see anything too helpful in the mmap and duck_stream files. What I wrote would need to be changed to better work with the existing c

Re: User contributed packages (Cabel, CPAN, etc)

2009-03-22 Thread Stuart Sierra
On Mar 22, 12:57 pm, Bradbev wrote: > Is the clojure-contrib portion of Clojure meant to act as a package > system like Cabel, CPAN, etc? I suspect not. Clojure-contrib is more > like the standard library that comes with Clojure. Speaking as a contributor, I don't think it's big enough to qual

Java Posse exposure

2009-03-22 Thread Mark Volkmann
Many of you may be familiar with the "Java Posse" podcast. Their website is http://javaposse.com/. Near the end of the most recent episode, #235, they mentioned my Clojure article and provided a link on their website. So more press for Clojure! BTW, I have made many updates to the article since I

Re: Help with the dot operator special form

2009-03-22 Thread David Nolen
Thanks again to all for the help, clj-cont now supports the new and dot special forms. This also means that dosync, doto, .. all work perfectly fine from within a with-call-cc form. You can now write things like this: (let [cc (atom nil)] [(with-call-cc (. (let-cc k (reset! cc k) (k

Re: Method overloading & proxy method

2009-03-22 Thread ronen
Well it seems to be more complicated than that, defining a visit method overrides the call to the visit(CompilationUnit n, A arg) method which contains the basic visitation logic, what that I actually need is a way of overriding specific methods (like the visit (MethodDeclaration n, A arg) and no

Re: The unshared part of two mostly-shared structures

2009-03-22 Thread mikel
Thanks for the comments, folks. I may be able to raw some ideas from them. In my specific case, restrictive rules about the types of the objects may be quite workable. For example, I don't think I'd suffer if the state-preserving objects were all required to be hash-maps. I'll think some more abo

Re: User contributed packages (Cabel, CPAN, etc)

2009-03-22 Thread Christian Vest Hansen
I was hoping that we could piggy-back on one of Java's packaging systems, so our programs can depend on Java libraries just as easy as Clojure libraries. And in this regard, the Maven repository system is pretty popular and even supported by build tools other than Maven (such as Ivy, Buildr and Gr

Re: Help with the dot operator special form

2009-03-22 Thread David Nolen
That was it! At one point I knew these things. Thanks much. On Sun, Mar 22, 2009 at 2:18 PM, Eric Tschetter wrote: > > > (let [myref (ref {})] > > (dot > >clojure.lang.LockingTransaction > >(list 'runInTransaction (fn [] (commute myref assoc :mykey :myval) > > I'm getting a instanc

Re: version of -> short-circuiting on nil

2009-03-22 Thread Meikel Brandmeyer
Hi, Am 22.03.2009 um 20:45 schrieb Stephen C. Gilardi: clojure.contrib.core/.?. is a symbol. Thanks for pointing out that it is one that's reserved to Clojure. Rich, should we rename clojure.contrib.core/.?. to avoid using a name reserved to Clojure? I'd like to throw in another thought:

Re: I need help tracking down a performance problem.

2009-03-22 Thread Vincent Foley
How would I do that? Make a macro that expands into a map literal with the appropriate calls to .get, .getShort and .getInt? On Mar 22, 4:20 pm, Christophe Grand wrote: > Vincent Foley a écrit :> The code is available at this > URL:http://code.google.com/p/bwhf/ > > (look at the hu.becliza.and

Re: I need help tracking down a performance problem.

2009-03-22 Thread Christophe Grand
Vincent Foley a écrit : > The code is available at this URL: http://code.google.com/p/bwhf/ > (look at the hu.becliza.andras.bwhf.control.[BinRepParser, > BinReplayUnpacker] files) > > It is definitely not as dynamic, which helps quite a lot, but I wanted > to have something high level and declara

Re: What's a convenient way of calling super.method()?

2009-03-22 Thread CuppoJava
Thanks for the responses: I read into proxy-super, and it fulfills my needs. But I'm worried about my current approach for multi-methods now: As Mark put it: "Not only is it clumsy, but if mymethod returns a fresh object that is based off of this object in some way (e.g., a non-destructive "sett

Re: version of -> short-circuiting on nil

2009-03-22 Thread Stephen C. Gilardi
On Mar 22, 2009, at 2:28 PM, Michael Wood wrote: As was pointed out to me recently, http://clojure.org/reader says: "Symbols beginning or ending with '.' are reserved by Clojure." So, is .?. not a symbol (because it's called at compile time and at runtime there is no such thing as .?.)? i.e.

Re: March 20th 2009 Rich Hickey Appreciation Day!

2009-03-22 Thread Anand Patil
Clojure's great, thanks very much for making it available & supporting it! Anand On Fri, Mar 20, 2009 at 6:26 PM, Rayne wrote: > > I Anthony Simpson, with the support of fellow Clojurists hereby > declare March 20th, the first day of spring, Rich Hickey appreciation > day! > > Rich Hickey has ce

Re: User contributed packages (Cabel, CPAN, etc)

2009-03-22 Thread Paul Stadig
I had started on something like a package manager called Sauron ("one library to rule them all"). My idea was to be able to define dependencies with something like: (depends-on :name "clojure-json" :version "1.2.3") This would look into a ~/.sauron directory and either add a jar or a directory to

Behavior of clojure.set/union and hinting function arguments

2009-03-22 Thread Frantisek Sodomka
Hello Rich & everybody! clojure.set/union currently accepts 'nil' as a valid argument: (union nil) => nil (union nil nil) => nil (union nil #{1 2}) => #{1 2} (union #{1 2} nil) => #{1 2} (union #{} nil) => #{} (union nil #{}) => nil ; not consistent Possible solution would be to ban 'nil

Re: version of -> short-circuiting on nil

2009-03-22 Thread Michael Wood
On Sun, Mar 22, 2009 at 11:42 AM, Laurent PETIT wrote: > OK, Stephen checked this in, thank you very much ! > > Two new symbols: As was pointed out to me recently, http://clojure.org/reader says: "Symbols beginning or ending with '.' are reserved by Clojure." So, is .?. not a symbol (because i

Re: Help with the dot operator special form

2009-03-22 Thread Eric Tschetter
> (let [myref (ref {})] >   (dot >    clojure.lang.LockingTransaction >    (list 'runInTransaction (fn [] (commute myref assoc :mykey :myval) > I'm getting a instance method not found exception which seems odd. I looked > at LockingTransaction.java and I see that runInTransaction does in fact

Re: Help with the dot operator special form

2009-03-22 Thread David Nolen
Thanks all for the pointers, this looks like a workable approach. In my case I'm not bothered by the performance hit from reflection (CPS transformation creates an obscene number of anonymous functions anyway). However I am running into an issue. Here's my dot function: (def not-seq? (comp not se

User contributed packages (Cabel, CPAN, etc)

2009-03-22 Thread Bradbev
Is the clojure-contrib portion of Clojure meant to act as a package system like Cabel, CPAN, etc? I suspect not. Clojure-contrib is more like the standard library that comes with Clojure. I think that going forward, Clojure is going to want to have a large and easily accessible library of packa

Re: What's a convenient way of calling super.method()?

2009-03-22 Thread pmf
On Mar 22, 5:10 pm, Stuart Sierra wrote: > On Mar 21, 4:38 pm, CuppoJava wrote: > > > For proxies, I haven't figured out a way yet. > > Proxies cannot call superclass methods.  Classes generated with gen- > class can.  However, if you regularly need to call superclass methods > instead of subcla

Re: The unshared part of two mostly-shared structures

2009-03-22 Thread Stuart Sierra
On Mar 21, 6:01 pm, rapido wrote: > my programming language enchilada (www.enchiladacode.nl) has > hash=pointer equality build in. > i believe it shouldn't be to difficult to introduce some of > enchilada's internals to clojure. Hi Robbert, I imagine that hash-pointer equality would be difficul

Re: Method overloading & proxy method

2009-03-22 Thread Stuart Sierra
On Mar 21, 6:13 pm, ronen wrote: > Hello there, > Iv been trying to implement a proxy on a class > (http://code.google.com/p/javaparser/source/browse/trunk/JavaParser/sr...) > that has multiple overloaded methods (same arity different types), > trying > > (defn create-visitor [] >   (proxy [Void

Re: capturing stdout

2009-03-22 Thread Stuart Sierra
On Mar 22, 10:34 am, Mark Volkmann wrote: > (defn get-output [fn] >   (let [sw (StringWriter.)] >     (binding [*out* sw] (fn)) >     (.toString sw))) This is what clojure.core/with-out-str does. -Stuart Sierra --~--~-~--~~~---~--~~ You received this message beca

Re: What's a convenient way of calling super.method()?

2009-03-22 Thread Stuart Sierra
On Mar 21, 4:38 pm, CuppoJava wrote: > For proxies, I haven't figured out a way yet. Proxies cannot call superclass methods. Classes generated with gen- class can. However, if you regularly need to call superclass methods instead of subclass methods, then you may want to rethink your design, p

Re: Help with the dot operator special form

2009-03-22 Thread Stuart Sierra
On Mar 21, 10:23 pm, Timothy Pratley wrote: > You may be able to achieve what you want by directly accessing > Clojure's reflector class instead of using the special form: You could also call Java's reflection API directly. -Stuart Sierra --~--~-~--~~~---~--~~ Yo

Re: March 20th 2009 Rich Hickey Appreciation Day!

2009-03-22 Thread Jason Warner
Seriously, Rich, you are awesome. Great language. BTW. Does Rich have an Amazon wish list? On Mar 20, 11:26 am, Rayne wrote: > I Anthony Simpson, with the support of fellow Clojurists hereby > declare March 20th, the first day of spring, Rich Hickey appreciation > day! > > Rich Hickey has certa

Re: capturing stdout

2009-03-22 Thread Mark Volkmann
Never mind. I think I needed to make this a macro instead of a function like this: (defmacro get-output [fn] `(let [sw# (StringWriter.)] (binding [*out* sw#] ~fn) (.toString sw#))) On Mar 22, 9:34 am, Mark Volkmann wrote: > I can't figure out why this function seems to work, but also

capturing stdout

2009-03-22 Thread Mark Volkmann
I can't figure out why this function seems to work, but also produces a NullPointerException. (defn get-output [fn] (let [sw (StringWriter.)] (binding [*out* sw] (fn)) (.toString sw))) (get-output (println "foo")) -- R. Mark Volkmann Object Computing, Inc. --~--~-~--~~--

Re: Possible Bug In clojure.zip/remove

2009-03-22 Thread Frantisek Sodomka
On Mar 19, 12:58 pm, Jason Sankey wrote: > Also, is there somewhere I can contribute test cases for this to > prevent a future regression? Tests for clojure.zip can from now on go to test-clojure.clojure-zip: http://code.google.com/p/clojure-contrib/source/browse/trunk/src/clojure/contrib/test_c

Re: atom/swap! question

2009-03-22 Thread Mark Volkmann
Thanks for looking this over! It's interesting how often I find myself trying to use an Atom because I'm not coordinating changes multiple things, just one, but the solution still requires using a Ref. I guess it's wrong to think of what I'm doing as coordinating one value. I'm really coordinating

Re: atom/swap! question

2009-03-22 Thread Meikel Brandmeyer
Hi, Am 21.03.2009 um 23:26 schrieb Mark Volkmann: I'm looking for a suggestion on how I can get new-struct. The other aspects aside, here an answer for this question. (defn get-new-struct [the-new-map] (the-new-map (last (keys the-new-map Or, to be sure, (defn get-new-struct [the

Re: March 20th 2009 Rich Hickey Appreciation Day!

2009-03-22 Thread stephaner
I join the crowd too, I was looking for a language to develop some projects. Then Clojure appeared, the light was there. Thank you Rich Hickey Stephane On Mar 20, 2:26 pm, Rayne wrote: > I Anthony Simpson, with the support of fellow Clojurists hereby > declare March 20th, the first day of spr

Re: version of -> short-circuiting on nil

2009-03-22 Thread Laurent PETIT
OK, Stephen checked this in, thank you very much ! Two new symbols: clojure.contrib.core/.?. clojure.contrib.core/-?> Regards, -- Laurent 2009/3/14 Laurent PETIT > Issue 34 ( http://code.google.com/p/clojure-contrib/issues/detail?id=34 ) > created with patch (both -?> and .?. defined in c

Re: Calling `str' on a LazySeq

2009-03-22 Thread David Sletten
On Mar 21, 2009, at 11:30 PM, Mark Triggs wrote: >> > > Yep, that's fine. In my case I was actually relying on the fact that > `str' was effectively doing a `prn-str' because I would later read it > back using `read-string' elsewhere. Calling `prn-str' explicitly > isn't a problem--I just though

Re: Calling `str' on a LazySeq

2009-03-22 Thread Mark Triggs
Hi David, On Mar 22, 5:01 pm, David Sletten wrote: > On Mar 21, 2009, at 1:44 PM, Mark Triggs wrote: > > >   user=> (str (filter even? (range 1 10))) > >   "clojure.lang.lazy...@f1005" > > > Previously this would readably print the contents of the seq and some > > of my code was relying on this.