Re: A value that equals everything, or, ignoring things in multi-dispatch

2008-11-15 Thread Parth Malwankar
On Nov 16, 12:36 am, samppi <[EMAIL PROTECTED]> wrote: > Is there a way to get a value—call it 'anything—so that (isa? anything > x) is always true for any x? > > I need this for multimethod dispatch—sometimes, I want a method to > ignore some of the stuff its dispatch function returns: > >   (d

Re: (. Classname-symbol (method-symbol args*))

2008-11-15 Thread Chouser
On Sat, Nov 15, 2008 at 8:27 PM, lsmith <[EMAIL PROTECTED]> wrote: > > I've just started playing around with clojure, and can't quite make > out how the (.special form works. > > For example, > (. javax.swing.JOptionPane (showMessageDialog nil "Hello World")) > seems to work just fine, but > (

Re: reader macros

2008-11-15 Thread Stephen Gilardi
Clojure does not currently allow programs to define new reader macros. That is unlikely to change. There are more details here: http://groups.google.com/group/clojure/search?group=clojure&q=reader+macro&qt_g=Search+this+group There is a clever technique described on the wiki that allows Clojur

Re: reader macros

2008-11-15 Thread Adam Jones
On Nov 15, 4:52 pm, Jeff Rose <[EMAIL PROTECTED]> wrote: > Hi, I'm finding comments talking about reader macros, but nothing about > defining them.  Does anyone know of an example for adding new read > macros?  I'd like to define a #! macro that passes over the rest of the > line so we can use c

Re: reader macros

2008-11-15 Thread James Reeves
On Nov 16, 12:52 am, Jeff Rose <[EMAIL PROTECTED]> wrote: > Hi, I'm finding comments talking about reader macros, but nothing about > defining them.  Does anyone know of an example for adding new read > macros?  I'd like to define a #! macro that passes over the rest of the > line so we can use cl

Re: (. Classname-symbol (method-symbol args*))

2008-11-15 Thread Stephen Gilardi
In my opinion, idiomatic Clojure for this is: (.println System/out "smile") --Steve On Saturday, November 15, 2008, at 09:32PM, ".Bill Smith" <[EMAIL PROTECTED]> wrote: > >Clojure doesn't know what to do with "System.out"; you need to express >that as (. System out). Of course (.. System out

Re: (. Classname-symbol (method-symbol args*))

2008-11-15 Thread .Bill Smith
Clojure doesn't know what to do with "System.out"; you need to express that as (. System out). Of course (.. System out (println "wtf")) is equivalent to (. (. System out) (println "wtf")) I hope that helps. Bill On Nov 15, 7:27 pm, lsmith <[EMAIL PROTECTED]> wrote: > I've just started playing

Re: Poll: Which clojure.contrib libs should be bundled with Clojure?

2008-11-15 Thread Howard Lewis Ship
I'd like to see Clojure properly packaged (with source jars as well as binary jars), available via a maven repository, with the main Clojure site being a multi project so that you could download and build Clojure and standard libraries all in a single go. I'm checking with my management to see if

(. Classname-symbol (method-symbol args*))

2008-11-15 Thread lsmith
I've just started playing around with clojure, and can't quite make out how the (.special form works. For example, (. javax.swing.JOptionPane (showMessageDialog nil "Hello World")) seems to work just fine, but (. System.out (println "wtf")) does not. Only (.. System out (println "wtf")) does

reader macros

2008-11-15 Thread Jeff Rose
Hi, I'm finding comments talking about reader macros, but nothing about defining them. Does anyone know of an example for adding new read macros? I'd like to define a #! macro that passes over the rest of the line so we can use clojure scripts just as easily as a ruby script would be. If an

Agent errors reporting

2008-11-15 Thread ntupel
Currently agent errors are only reported when the agent is derefenced or further actions are dispatched to the agent. It would be great if one can get immediate notification of agent errors maybe through a callback. Thanks, nt --~--~-~--~~~---~--~~ You received th

Re: Newbie: cannot get slime to work

2008-11-15 Thread Giacecco
Bill, thank you for your suggestion. I was already using the latest versions but I found out that the problem was that the path to clojure was wrong: it should have been / usr/local/src/clojure/trunk/target/clojure-lang-1.0-SNAPSHOT.jar : I forgot the "trunk". The error message was misleading, t

Re: Newbie: cannot get slime to work

2008-11-15 Thread Bill Clementson
Hi Giacecco, On Sat, Nov 15, 2008 at 2:27 PM, Giacecco <[EMAIL PROTECTED]> wrote: > > I am using Aquamacs on MacOS 10.5.5, set up slime, swank and clojure- > mode as described in the instructions, but when I start slime I get > this error message: > > === > (add-classpath "file:usr/local/src/

Re: Testing for lists, vectors, ...

2008-11-15 Thread Stephen C. Gilardi
On Nov 15, 2008, at 5:15 PM, Konrad Hinsen wrote: > > I am trying to write a function (for use in a macro) that replaces a > given keyword in a form by a given symbol, i.e. > > (replace-symbol :foo :bar form) > > should return the form with all occurences of :foo replaced by :bar. > This turned o

Newbie: cannot get slime to work

2008-11-15 Thread Giacecco
I am using Aquamacs on MacOS 10.5.5, set up slime, swank and clojure- mode as described in the instructions, but when I start slime I get this error message: === (add-classpath "file:usr/local/src/clojure-swank/") (require (quote swank)) (swank/ignore-protocol-version "2008-11-02") (swank/

Poll: Which clojure.contrib libs should be bundled with Clojure?

2008-11-15 Thread Chouser
I've put up a poll form to allow everyone to vote on which clojure.contrib libs they think should be in clojure.core or otherwise bundled with Clojure: https://spreadsheets.google.com/viewform?key=p1hkQs__fVyaQGEP_bOFRVQ A summary of the results is available, but I can't figure out how to make i

Testing for lists, vectors, ...

2008-11-15 Thread Konrad Hinsen
I am trying to write a function (for use in a macro) that replaces a given keyword in a form by a given symbol, i.e. (replace-symbol :foo :bar form) should return the form with all occurences of :foo replaced by :bar. This turned out to be surprisingly difficult. I started out like this: (d

Re: FindBugs run on Clojure source code

2008-11-15 Thread Attila Szegedi
On 2008.11.15., at 15:25, Rich Hickey wrote: > Welcome Attila, > > I've run findbugs on Clojure before and cleaned up a few things. These > that you mentioned, however, stand as a good example of such an > analyzer not knowing enough, and I count as spurious, if well- > intended. > > As mentione

NoClassDefFoundError while using AOT compiler

2008-11-15 Thread Wilkes Joiner
I was trying out the new AOT compilation, but hit a roadblock with the following error message: java.lang.NoClassDefFoundError: compile_fail$criteria__9$f__11 If I do a dirty build, i.e. just run build 2x, it will find the class. I stripped everything down to the bare essentials to recreates it:

Re: Missing attachments when posting here

2008-11-15 Thread Rich Hickey
On Nov 15, 2:34 pm, Meikel Brandmeyer <[EMAIL PROTECTED]> wrote: > Hi, > > Am 15.11.2008 um 19:20 schrieb Stephen C. Gilardi: > > > I usually use Mac OS X's Mail from a "mac.com/MobileMe" > > account to send and receive mail with this group. > > I'm using Mail.app on Mac OS X and had never probl

A value that equals everything, or, ignoring things in multi-dispatch

2008-11-15 Thread samppi
Is there a way to get a value—call it 'anything—so that (isa? anything x) is always true for any x? I need this for multimethod dispatch—sometimes, I want a method to ignore some of the stuff its dispatch function returns: (defmulti a #(%1 %2)) (defmethod a [3 2] [x y] ...) ; in this met

Re: Missing attachments when posting here

2008-11-15 Thread Meikel Brandmeyer
Hi, Am 15.11.2008 um 19:20 schrieb Stephen C. Gilardi: I usually use Mac OS X's Mail from a "mac.com/MobileMe" account to send and receive mail with this group. I'm using Mail.app on Mac OS X and had never problems sending attachments to the group. However Google Groups seems to be rather chee

Re: Missing attachments when posting here

2008-11-15 Thread Randall R Schulz
On Saturday 15 November 2008 10:20, Stephen C. Gilardi wrote: > I usually use Mac OS X's Mail from a "mac.com/MobileMe" account to > send and receive mail with this group. > > ... > > Does anyone have any hints on doing it successfully or how I might go > about figuring out what's happening to my

Re: Missing attachments when posting here

2008-11-15 Thread Chouser
On Sat, Nov 15, 2008 at 1:20 PM, Stephen C. Gilardi <[EMAIL PROTECTED]> wrote: > > I usually use Mac OS X's Mail from a "mac.com/MobileMe" account to > send and receive mail with this group. I use gmail.com, and have never noticed a problem sending an attachment to the group. --Chouser --~--~--

Missing attachments when posting here

2008-11-15 Thread Stephen C. Gilardi
I usually use Mac OS X's Mail from a "mac.com/MobileMe" account to send and receive mail with this group. There have been times in the past when I've been able to attach files to messages and have them show up properly in - the copy I receive from the group, and - the archive

Re: Patch available: standalone build.xml

2008-11-15 Thread Randall R Schulz
On Saturday 15 November 2008 09:56, Stephen C. Gilardi wrote: > On Nov 15, 2008, at 12:45 PM, Stephen C. Gilardi wrote: > > I've enclosed a patch to build.xml > > Uploaded to the group because it came through with lines truncated by > mail. That's what attachments are for (though at least some ma

Re: Patch available: standalone build.xml

2008-11-15 Thread Stephen C. Gilardi
On Nov 15, 2008, at 12:45 PM, Stephen C. Gilardi wrote: > I've enclosed a patch to build.xml Uploaded to the group because it came through with lines truncated by mail. http://groups.google.com/group/clojure/web/build-xml-patch.zip --Steve --~--~-~--~~~---~--~-

Re: Newbie question: Can a collection contain itself?

2008-11-15 Thread Robert Pfeiffer
Hello samppi, You could try this, the list does not really contain itself, but it builds lists that are like itself recursively: ;builds recursion into lists, like Y the combinator (defn build-recursive-list [fun list] (fun (delay (build-recursive-list fun list)) list)) (def cyclic-list1

Patch available: standalone build.xml

2008-11-15 Thread Stephen C. Gilardi
I've enclosed a patch to build.xml that lets it stand alone without the "precompile.clj" helper file we're using currently. The patched build.xml writes the Clojure compile script to a build directory at build time based on a new ant property whose value is the list of libs to compile. I t

Re: Newbie: Optional parameters without multiple definitions

2008-11-15 Thread Craig Andera
If you're cool with passing a map instead of plain parameters, you could use destructuring to do this: (defn test1 [{x :x, y :y, :or {:y 3}}] [x y]) (test1 {:x 2}) => [2 3] Another thing you could do would be to use variable arity and handle the absence of the other parameters in the me

Newbie: Optional parameters without multiple definitions

2008-11-15 Thread samppi
Is there a more concise way of expressing an optional parameter with a default other than writing another entire definition? That is, instead of: (defn a-function ; two parameters, x and y, and y is 23 by default ([x] (a-function x 23) ([x y] ...)) ...is it possible to do something lik

Re: Newbie question: Sequences from a function

2008-11-15 Thread samppi
Thanks for your answers. iterate was just what I needed. On Nov 15, 9:30 am, "Craig Andera" <[EMAIL PROTECTED]> wrote: > One way to lazily produce f(n) over an infinite number of integers is > using map to apply your function to an infinite (lazy) series of > integers: > > (map (fn [x] (* x 3)) (

Re: Newbie question: Sequences from a function

2008-11-15 Thread Michel Salim
On Nov 15, 11:15 am, samppi <[EMAIL PROTECTED]> wrote: > Is there a way to make a lazy sequence whose sequential values are > derived from some function? I'm thinking about two ways: > >     (recursive-fn-seq f initial [n]) ; returns (initial (f initial) (f > (f initial)) ...) n or infinity times

Re: Newbie question: Sequences from a function

2008-11-15 Thread Craig Andera
One way to lazily produce f(n) over an infinite number of integers is using map to apply your function to an infinite (lazy) series of integers: (map (fn [x] (* x 3)) (iterate inc 0)) => (0 3 6 9 ...) Although you'd be wise to use take when evaluating this in the REPL. If you want to instead pr

Newbie question: Sequences from a function

2008-11-15 Thread samppi
Is there a way to make a lazy sequence whose sequential values are derived from some function? I'm thinking about two ways: (recursive-fn-seq f initial [n]) ; returns (initial (f initial) (f (f initial)) ...) n or infinity times (index-fn-seq f initial [n]); returns ((f i) (f (inc i)) (f

Re: length of a list

2008-11-15 Thread Rajarshi
On Nov 15, 7:58 am, "Craig Andera" <[EMAIL PROTECTED]> wrote: > Unless I'm missing something: > > (count '("CCC" "COC" "C(=O)C")) > => 3 > > Or better yet: > > (count ["CCC" "COC" "C(=O)C"]) > => 3 Thank you --~--~-~--~~~---~--~~ You received this message because

Re: Getting a flat sequence from a map (and vice versa)

2008-11-15 Thread samppi
Awesome. It amazes me what Clojure can do. Thanks for everyone's help. On Nov 15, 6:56 am, Rich Hickey <[EMAIL PROTECTED]> wrote: > On Nov 15, 12:09 am, "Brian Doyle" <[EMAIL PROTECTED]> wrote: > > > Another way to create a map is: > > > user=> (apply hash-map [:a 1 :b 2 :c 3]) > > {:a 1, :c 3, :

Re: Can't get rlwrap to work

2008-11-15 Thread Christopher Taylor
Hi, On 12.11.2008, at 22:38, Giacecco wrote: > > Hi all, > I am trying setting up clojure to use rlwrap as described at > http://en.wikibooks.org/wiki/Clojure_Programming#Enhancing_Clojure_REPL_with_rlwrap > on a MacOS 10.5.5. > > I have prepared the clj-completions.clj the instructions describe

Re: FindBugs run on Clojure source code

2008-11-15 Thread Rich Hickey
On Nov 15, 4:53 am, Attila Szegedi <[EMAIL PROTECTED]> wrote: > Hi folks, > > I run FindBugs on Clojure source code, and there are few things it > uncovered. I'd be happy to fix these and submit patches (after I > submitted a contributor agreement), except if someone already a > contributor want

Re: Readable names

2008-11-15 Thread Randall R Schulz
On Friday 14 November 2008 22:05, Mark H. wrote: > On Nov 12, 5:52 am, David <[EMAIL PROTECTED]> wrote: > > No, I think that, if at all, we need a single set of macros. As far > > as the IDEs are concerned, if we all try "inventing" our own (or > > plugins for the existing ones), they will all be

Re: FindBugs run on Clojure source code

2008-11-15 Thread Attila Szegedi
On 2008.11.15., at 14:23, Phil Jordan wrote: > > Hi Attila, > > I can't comment on the other issues, but: > > Attila Szegedi wrote: >> 2. Keyword and Ref define compareTo, but don't redefine equals (and >> hashCode) to be consistent with it. It ain't necessarily a problem if >> you know what you'

Re: Getting a flat sequence from a map (and vice versa)

2008-11-15 Thread Rich Hickey
On Nov 15, 12:09 am, "Brian Doyle" <[EMAIL PROTECTED]> wrote: > Another way to create a map is: > > user=> (apply hash-map [:a 1 :b 2 :c 3]) > {:a 1, :c 3, :b 2} > Yes, that's fine, and for the flatten: (interleave (keys m) (vals m)) Rich > On Fri, Nov 14, 2008 at 9:42 PM, samppi <[EMAIL PR

Re: [DISCUSS] Automatic defs for Repl?

2008-11-15 Thread John D. Hume
It's *1, *2, *3. On Fri, Nov 14, 2008 at 9:30 PM, Eric Rochester <[EMAIL PROTECTED]> wrote: > I'm not currently at a repl, so I can't check this, but IIRC, 1*, 2*, and 3* > bind to the last three return values. > Eric --~--~-~--~~~---~--~~ You received this messag

Re: FindBugs run on Clojure source code

2008-11-15 Thread Phil Jordan
Hi Attila, I can't comment on the other issues, but: Attila Szegedi wrote: > 2. Keyword and Ref define compareTo, but don't redefine equals (and > hashCode) to be consistent with it. It ain't necessarily a problem if > you know what you're doing, but since they're public it's usually a > g

Re: length of a list

2008-11-15 Thread Craig Andera
Unless I'm missing something: (count '("CCC" "COC" "C(=O)C")) => 3 Or better yet: (count ["CCC" "COC" "C(=O)C"]) => 3 On Fri, Nov 14, 2008 at 11:46 PM, Rajarshi <[EMAIL PROTECTED]> wrote: > > Hi, I've been learning Lisp using SBCL, but my complaint has been it > was difficult for me to link it

length of a list

2008-11-15 Thread Rajarshi
Hi, I've been learning Lisp using SBCL, but my complaint has been it was difficult for me to link it to stuff I use (such as cheminforatics libs). So I'm very happy to have found Clojure. However, I've been stumped trying to find out how to get the number of elements in a list. Currently I'm usin

FindBugs run on Clojure source code

2008-11-15 Thread Attila Szegedi
Hi folks, I run FindBugs on Clojure source code, and there are few things it uncovered. I'd be happy to fix these and submit patches (after I submitted a contributor agreement), except if someone already a contributor wants to tackle these instead (they're easy to fix for the most part).

Re: Getting a flat sequence from a map (and vice versa)

2008-11-15 Thread Kevin Downey
user=> (mapcat identity {:a 1 :b 2 :c 3}) (:c 3 :b 2 :a 1) On Sat, Nov 15, 2008 at 4:05 AM, Kevin Downey <[EMAIL PROTECTED]> wrote: > user=> (reduce concat {:a 1 :b 2 :c 3}) > (:c 3 :b 2 :a 1) > user=> > > > On Sat, Nov 15, 2008 at 4:02 AM, Matthias Benkard <[EMAIL PROTECTED]> wrote: >> >> On 1

Re: Getting a flat sequence from a map (and vice versa)

2008-11-15 Thread Matthias Benkard
On 15 Nov., 05:17, samppi <[EMAIL PROTECTED]> wrote: > Fold isn't build into Clojure Isn't fold just clojure/reduce? Matthias --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, s

Re: Getting a flat sequence from a map (and vice versa)

2008-11-15 Thread Kevin Downey
user=> (reduce concat {:a 1 :b 2 :c 3}) (:c 3 :b 2 :a 1) user=> On Sat, Nov 15, 2008 at 4:02 AM, Matthias Benkard <[EMAIL PROTECTED]> wrote: > > On 15 Nov., 05:17, samppi <[EMAIL PROTECTED]> wrote: >> Fold isn't build into Clojure > > Isn't fold just clojure/reduce? > > Matthias > > > -- The

Re: Lazy Seq and refs

2008-11-15 Thread Michael Wood
On Fri, Nov 14, 2008 at 10:51 PM, Bradbev <[EMAIL PROTECTED]> wrote: > > I thought up an interesting issue the other night. If you map a > function over a seq of refs, then change the refs & look at the map > return value (which will convert it from lazy to ...? Hmm, what's the > word - motivate

Re: Newbie question: Can a collection contain itself?

2008-11-15 Thread Matthias Benkard
On 15 Nov., 00:31, samppi <[EMAIL PROTECTED]> wrote: > Yeah, I surmised as much. The thing is, I'm writing a YAML library in > Clojure, and YAML allows circular recursion like that: > >   --- >   &x >   - 3 >   - 2 >   - 1 >   - *x > > ...So I'm wondering what I should do if a document like that w