Patch: callable defstruct (PersistentStructMap$Def extends AFn)

2008-11-04 Thread Chouser
nstead of struct, but I think the above case is far more common. So why not make it the default if you call the struct-basis? The attached patch allows: user=> (point 42 11) {:x 42, :y 11} This is less wordy and has a nice declarative ring to it. --Chouser 1. http://clojure-log.n01se.net/

Re: Patch: callable defstruct (PersistentStructMap$Def extends AFn)

2008-11-05 Thread Chouser
On Wed, Nov 5, 2008 at 12:10 AM, Chouser <[EMAIL PROTECTED]> wrote: > The attached patch allows: > > user=> (point 42 11) > {:x 42, :y 11} The right tool for the job makes all the difference. Attached is a much simpler patch to accomplish the s

Re: sort with custom comparator

2008-11-06 Thread Chouser
: (ancestors (class #())) Cleaned up output: #{#=clojure.lang.AFn #=clojure.lang.IFn #=clojure.lang.IObj #=clojure.lang.Obj #=java.io.Serializable #=java.lang.Object #=java.lang.Runnable #=java.util.Comparator #=java.util.concurrent.

Re: prefer-method print-method problem

2008-11-06 Thread Chouser
c type than IPersistentMap -- you get the right behavior by default: user=> (sorted-map 1 2 3 4 5 6) #=(sorted-map 1 2,3 4,5 6) That still doesn't get read in right, and I'm not sure why. But it seems to be printing ok. --Chouser --~--~-~--~~~---~--~

Re: prefer-method print-method problem

2008-11-06 Thread Chouser
nerates the > "#=(sorted-map ..." printing? I've looked but can't find it in > boot.clj. Now *I'm* confused. It's your code that's printing "#=(sorted-map ..." for me, without any call to "prefer-method" required. --Chouser --~--~

Patch and audit: Use vectors for bindings in doseq, et al.

2008-11-07 Thread Chouser
binding form". This patch also includes fixes to all the places in boot, proxy, gen-class, and xml (that I found) that use these macros. I assume every lib in clojure-contrib and in fact nearly every piece of clojure code more that 10 line

Re: Print compiled Clojure svn revision?

2008-11-07 Thread Chouser
me Clojure function to read. ...but I don't really know enough about ant (or svn either, for that matter) to do this myself. --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. T

Re: Patch and audit: Use vectors for bindings in doseq, et al.

2008-11-07 Thread Chouser
t -- add a check to make sure only one binding pair is given. Alternatively it could act as if it were nested, as "for" (and now "doseq") do, in which case it would act like an "and", and both x and y would be bound to non-false values. --Chouser --~--~-~--~-

Re: Patch and audit: Use vectors for bindings in doseq, et al.

2008-11-08 Thread Chouser
lier patch). This patch is against 1089, the "Interim checkin - DO NOT USE!!" version of SVN. --Chouser On Sat, Nov 8, 2008 at 7:42 AM, Rich Hickey <[EMAIL PROTECTED]> wrote: > > > > On Nov 7, 5:09 pm, James Reeves <[EMAIL PROTECTED]> wrote: >> On Nov 7, 9:32

Re: a macro question, this time completely specified :-)

2008-11-08 Thread Chouser
(when (= 1 (dosync (alter call-count inc))) > (apply function args) Or: (defn runonce "Create a function that will only run its argument once." [function] (let [needed (java.util.concurrent.atomic.AtomicBoolean. true)] (fn [& args] (when (.getA

Re: a macro question, this time completely specified :-)

2008-11-08 Thread Chouser
ta key." (let [has-run (gensym)] `(let [[function# ~has-run] (runonce (fn [] [EMAIL PROTECTED]))] (def ~(with-meta sym {:has-run has-run}) function# --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Googl

Re: clojure.jar/classpath for SVN version

2008-11-09 Thread Chouser
n constants new *print-dup* flag, prints duplicators back to simplified readably printing for repl readable fns, as long as they are not closures --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clo

Re: Readable names

2008-11-10 Thread Chouser
-) Ok, I've said my piece. I'll try harder not respond next time. --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups

Re: newbie: can clojure do ...

2008-11-11 Thread Chouser
I do actually use Clojure to prepare the pages. At this point I could probably use ClojureScript instead of Clojure for the client-side code, but I haven't done that yet. --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to th

Re: newbie: can clojure do ...

2008-11-11 Thread Chouser
ught to be replace by a real IRC bot, but nobody's quite gotten around to that yet. --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to cloj

Re: "Can't create defs outside of current namespace"

2008-11-11 Thread Chouser
efore evaluation begins. By the time you bind *ns* to your target-ns, it's too late -- the defn is already compiled to resolve to the old namespace. I can't think of any way to do this in a single macro expansion without using "eval" on the defn f

Re: Simple isa? question—ISeq and Sequential

2008-11-14 Thread Chouser
assume you're using a version older than that. --Chouser --~--~-~--~~~---~--~~ 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 To unsubscribe from

Re: Overloading a clojure.core name in my namespace

2008-11-14 Thread Chouser
lojure (all one keyword): (ns a (:refer-clojure :exclude (load))) --Chouser --~--~-~--~~~---~--~~ 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 To

Re: Overloading a clojure.core name in my namespace

2008-11-14 Thread Chouser
(in-ns 'a) # a=> (load) my-load a=> (doc mmap) - clojure.contrib.mmap/mmap ([f]) Memory-map the file named f. Returns a ByteBuffer. nil a=> (doc children) - clojure.contrib.zip-filter/children ([loc]) Returns a lazy sequence of all immediat

Re: Correct place to report bugs?

2008-11-14 Thread Chouser
On Fri, Nov 14, 2008 at 12:16 PM, Howard Lewis Ship <[EMAIL PROTECTED]> wrote: > > Is this mailing list the correct place to report bugs? The bug list > on the SF page looks pretty sparse. Yes, this is a fine place to report b

Re: multi-method dispatch for structs

2008-11-14 Thread Chouser
h off of, you'll have to attach that yourself, either as another key that all your Maps share or as metadata. --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this

Re: Lazy Seq and refs

2008-11-14 Thread Chouser
On Fri, Nov 14, 2008 at 3:51 PM, Bradbev <[EMAIL PROTECTED]> wrote: > > (which will convert it from lazy to ...? Hmm, what's the > word - motivated?) I think the word you want is "eager" http://www.zazzle.com/i_get_more_done_when_im_lazy_clojure_shirt

Re: Newbie question: Can a collection contain itself?

2008-11-14 Thread Chouser
ction -- it may look similar, but it's not the same. So the structure will only be as deep as you make it. --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this gro

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 attac

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

2008-11-15 Thread Chouser
ow to make it visible to anyone who doesn't log in using a Google account: I'll make the results available to everyone in some other format once sufficient time has been passed for everyone to vote. https://spreadsheets.google.com/gform?key=p1hkQs__fVyaQGEP_bOFRVQ&hl=en&a

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

2008-11-15 Thread Chouser
in Clojure put the dot elsewhere, either (. "foo" substring 1) or preferably (.substring "foo" 1) Putting those together, as Stephen Gilardi said, you get (.println System/out "get it done") --Chouser --~--~-~--~~~---~--~~ You received t

Re: recur in catch and finally?

2008-11-16 Thread Chouser
(if (nil? (.getCause x)) >x >(recur (.getCause x)) > > However I get: > > java.lang.UnsupportedOperationException: Cannot recur from catch/finally > (NO_SOURCE_FILE:1) > > Is this intended? You could of course work around this by putting your loop

Re: Eager map?

2008-11-17 Thread Chouser
definitions) for > denoting lazy/strict versions of functions. (e.g. (map f ...) is a > lazy seq, (map! f ...) is strict) (vec x) will force a lazy seq x and store it in a vector. (apply list x) will force and store in a list. --Chouser --~--~-~--~~~---~--~

Patch: Use vector binding for with-in-str

2008-11-18 Thread Chouser
tWip in IRC notice with-in-str is broken. Patch attached. --Chouser --~--~-~--~~~---~--~~ 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 To unsubs

Re: Adapting a functional pretty-printer to Clojure

2008-11-18 Thread Chouser
re used in code (defn, let, etc.) and can format the required args differently than the "rest" args. This would allow some code forms to look more natural. Anyway, it's definitely a work in progress. What I've got so far is attached. All thoughts and comments are welcome. --

Re: Adapting a functional pretty-printer to Clojure

2008-11-18 Thread Chouser
e on short lists. :-) I wanted to post what I had right away, but I will now take the time to understand your code, so I can come up with own opinion about how we ought to proceed. --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscr

Re: (new user) - Problem passing a double[][] to Java constructor.

2008-11-18 Thread Chouser
see that the type signature looks good: user=> my-tricky-array # To unpack it into Clojure seqs again: user=> (map seq my-tricky-array) ((1.0 2.0) (3.0 4.0)) --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Gr

Re: (new user) - Problem passing a double[][] to Java constructor.

2008-11-18 Thread Chouser
gt; user=> (into-array (map double-array [[1.0] [2.0]])) > # Ah, nice. Thanks. --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@goo

Re: [BUG?] No matching method found: getString

2008-11-19 Thread Chouser
need this you can wrap either step in a function to make calling it more pleasant. --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@google

Bug + Patch: LazilyPersistentVector mutated by sort

2008-11-19 Thread Chouser
ting the array inside the vector. --Chouser --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, se

Re: (Newbie) Multimethod dispatch by a function other than isa?

2008-11-19 Thread Chouser
8-11-14.html#17:40a-17:52 --Chouser --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to

Bug + Patch: compile fails for namespaces with dashes in their names.

2008-11-19 Thread Chouser
re, load the generated .class files. --Chouser --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, se

Re: What's in *your* user.clj?

2008-11-20 Thread Chouser
ang.PersistentHashMap (1) [ 5] static create : class clojure.lang.PersistentHashMap (2) [ 6] static create : interface clojure.lang.IPersistentMap (1) [ 7] (interface clojure.lang.IPersistentMap, int, interface clojure.lang.PersistentHashMap$INode) [ 8] applyTo : class java.lang.Object (1

Re: printing *command-line-args*

2008-11-20 Thread Chouser
ss-platform way to launch clojure from the command line that supports all the various "normal" usage patterns naturally. Until then use -- either manually, or put it in your clj shell script somewhere. --Chouser --~--~-~--~~~---~--~~ You received this messag

Re: What's in *your* user.clj?

2008-11-20 Thread Chouser
-length* since it does its own looping and only over concrete things like method lists -- no infinite seqs there. No, the *print-length* is set for the whole REPL context to save myself from pain when I accidentally evaluate the equivalent of (iterate in

Re: mutability

2008-11-20 Thread Chouser
on't need to alter state in as many places as you would in other languages, and when you do it's easier to do it in a thread-safe way. --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure

Re: mutability

2008-11-20 Thread Chouser
a is that you shouldn't have to actually set the state very often, usually just once at the top level of any particular code path or even handler, which will have benefits even in a single-threaded system. It can be hard to think through algorithms this way at first, but I've found

Re: mutability

2008-11-20 Thread Chouser
t agents are really what you want, but anyway... (send player update-in [:str] inc) (await player) --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email

Re: Clojure Box (was Working combination of .emacs, Aquamacs, swank-clojure, clojure-mode?)

2008-11-21 Thread Chouser
ay (or let my vim roots show too much) but jEdit is a 2 or 3MB download. I bet it wouldn't be very hard to get a Clojure REPL in there. --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure&qu

Re: Monads in Clojure

2008-11-21 Thread Chouser
ve to keep that in mind. (zero? n) is an idiom for (= 0 n) Alas even your beautiful, succinct implementation and careful code comments are apparently insufficient for me to understand monads. I'll keep trying. :-) --Chouser --~--~-~--~~~---~--~~ You r

Re: Suggest allowing java property to specify *compile-path*

2008-11-21 Thread Chouser
n to produce a .jar file directly, allowing a fifth use case: 5. java -jar my-foo.jar arg1 arg2 A cleverly written clj shell-script ought to be able to do all this today, though that doesn't work well as a cross-platform solution. So the question is -- are these use cases generall

Re: Monads in Clojure

2008-11-21 Thread Chouser
s something about a lisp other than Clojure can comment. --Chouser --~--~-~--~~~---~--~~ 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 To unsubscribe fr

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

2008-11-24 Thread Chouser
fVyaQGEP_bOFRVQ --Chouser On Sat, Nov 15, 2008 at 5:22 PM, Chouser <[EMAIL PROTECTED]> wrote: > 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: > > htt

Re: Adapting a functional pretty-printer to Clojure

2008-11-24 Thread Chouser
)] [(flatten (:doc2 x))]) This would of course require you to change everywhere that currently expects a struct with a :type to instead use (first x) for the type and the rest of the seq as args. Is your current version visible anywhere? Perhaps a more holistic look would reveal some other options.

Re: Trouble compiling clojure.contrib libs

2008-11-25 Thread Chouser
ur classpath. You get no error at this point, but apparently if the directory doesn't exist it's not really used, even though it's shown in the java.class.parth property string. --Chouser --~--~-~--~~~---~--~~ You received this message because you are s

Re: clojure contrib testing, fix for macro?, did macro? ever work?

2008-11-25 Thread Chouser
If you add me as a committer I will be well- > behaved. Maybe even install svn. :-) Oh, please don't bother. git-svn works beautifully. --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojur

Re: map: string keys to symbols

2008-11-26 Thread Chouser
)) That's essentially the same algorithm. I don't think there's a built-in function to do it for you. --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this

Re: trampoline for mutual recursion

2008-11-26 Thread Chouser
the mutual-recursion case you could get a nice error if you make a mistake like: (def foo [] (+ 10 (tail-call bar 1 2))) Although something less ugly might be nice. --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Googl

Re: trampoline for mutual recursion

2008-11-26 Thread Chouser
#(prn "Hello")) > > How can I execute the closure in myClosure now? user=> (myClosure) "Hello" or now, user=> (trampoline myClosure) "Hello" --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscr

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

2008-11-27 Thread Chouser
make writing unit tests very easy [using test-clojure and test-is] Chouser: [seq-utils] group-by Anonymous: if slurp is in clojure, spit [from duck-streams] should be there, too sj: sql and miglayout are important because they from the basis of so many applications Perry Trolard:

Re: Exception on the formatted print method calls

2008-11-27 Thread Chouser
ments, which generally means you need build the array the method is expecting. Fortunately, in the cases you list you can just use the Clojure function 'format' which does it for you: (.println System/out (format "%d" 1)) --Chouser --~--~-~--~~~---~--~

Re: Newbie: Why does .length work on strings but not .isEmpty ?

2008-11-28 Thread Chouser
On Thu, Nov 27, 2008 at 11:50 PM, Stephen C. Gilardi <[EMAIL PROTECTED]> wrote: > > You might also consider these Clojure functions: > user=> (count "") > 0 > user=> (empty? "") > true or (seq "") which returns nil on empty. --Chouse

Re: Newbie: Why does .length work on strings but not .isEmpty ?

2008-11-28 Thread Chouser
ling of character, and the doubling of the number of symbols? Personally, I would say no. And if you're doing fewer than a million, it's certainly not worth it. So write code for the programmer rather than the computer -- write it the way that will be the easiest for yourself and futu

Re: Next: #=(...) [was: Re: Documentation of :: Notation?]

2008-11-29 Thread Chouser
back in by 'read'. For example: user=> (java.util.Date.) # Hope that helps make sense of things, --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this gro

Re: SVN or release?

2008-11-29 Thread Chouser
0. So it's up to you to determine how you want to spend your time. Personally, I stay up to date with SVN. :-) --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to

Re: Converting collections of chars to a string?

2008-11-30 Thread Chouser
psed time: 36.130324 msecs" nil user=> (time (dotimes [_ 100] (reduce str long-sequence))) "Elapsed time: 1050.878775 msecs" nil --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure"

Re: Recursively / Iteratively Building Maps

2008-11-30 Thread Chouser
, :a 1} user=> (reduce (fn [m [k v]] (assoc m k v)) {} seq-of-pairs) ; if you really want to use assoc {:c 3, :b 2, :a 1} --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To pos

Re: Recursively / Iteratively Building Maps

2008-11-30 Thread Chouser
ns-publics already calls 'the-ns' on its arg, and 'for' is handy for destructuring. (defn ns-var-metas [ns-name] (into {} (for [[n v] (ns-publics ns-name)] [n ^v]))) Both 'into' and 'apply conj' allow you to specify nil instead of a pair if you wanted

Re: quit

2008-11-30 Thread Chouser
x27;m generally in favor of ditching parens whenever possible. I do wonder, though, if people would be confused by: user=> [1 2 3] java.lang.IllegalArgumentException: Wrong number of args passed to: LazilyPersistentVector (NO_SOURCE_FILE:0) --Chouser --~--~-~--~~~

Re: coll vs. seq

2008-11-30 Thread Chouser
uppose 'coll' would be a misleading name. In that case perhaps 's' or 'sequence' or something would do, but never 'seq'. Although it doesn't directly generate an error to use the word 'seq' as an arg or local, it shadows the

Re: coll vs. seq

2008-11-30 Thread Chouser
elegates to (RT/seq) uses the name 'coll'. For the others, they do all appear to call 'seq' on the arg you name, so any collection could be passed in. Whether it makes sense to highlight this fact by renaming the arg to something-coll or not probably depends on the specific functi

Re: loop recur vs recursion

2008-11-30 Thread Chouser
-for-int prompt junk-allowed default Or, since a default only makes sense if it might be returned: (defn prompt-for-int ([prompt] (or (prompt-for-int prompt nil) (recur prompt))) ([prompt default] (or (parse-int (prompt-read prompt)) default))) --Chouser --~--~-~--~~-

Re: Help with xml-seq

2008-11-30 Thread Chouser
"Test"]] This has not been deeply tested: (defn f [{:keys [tag attrs content] :as other}] (if tag (vec (concat [tag] (when attrs [attrs]) (when-let [s (map f content)] (vec s other)) --Chouser --~--~-~--~~~---

Re: Help with xml-seq

2008-11-30 Thread Chouser
e the document) vs. translating iterations into stack depth, you'll be okay. That's no promise, of course, but building a nested structure like this using only tail recursion sounds messier than I'd like to deal with at the moment. :-) --Chouser --~--~-~--~~~--

Re: Java libraries

2008-12-01 Thread Chouser
the documentation for the > String class at http://java.sun.com/javase/6/docs/api/java/lang/String.html. > It would also be helpful to know which File I/O libraries are most > relevant, and a couple short examples of how to use them. An

<    3   4   5   6   7   8