Re: Naming Conventions for Functions that Modify State

2009-02-14 Thread Michael Wood
On Fri, Feb 13, 2009 at 3:07 AM, Jeffrey Straszheim wrote: > Well, there is the IO! macro to wrap side effects. This works with the > transactions mechanism. Yes, see also (find-doc "!"). > So foo! does show up, but is not followed rigorously. There is also do- (doall, dorun, doseq, dotimes,

Trojan horse in our Files section

2009-02-14 Thread Frantisek Sodomka
My antivirus doesn't like the Gift from the Stranger: http://groups.google.com/group/clojure/files?&sort=date Not really nice of you, Stranger... Frantisek --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure"

Re: A Clojure documentation browser

2009-02-14 Thread Craig Andera
> Github is fine. Once I see your name on clojure.org/contributing, I'll > commit this to clojure.contrib. For changes going forward, once you're happy > with some update on github, just let me know and I'll pull it into contrib. > For bug reporting, I recommend you add a section to the comments a

Re: Trojan horse in our Files section

2009-02-14 Thread Jeffrey Straszheim
Lovely. Thanks for the warning. On Sat, Feb 14, 2009 at 6:49 AM, Frantisek Sodomka wrote: > > My antivirus doesn't like the Gift from the Stranger: > http://groups.google.com/group/clojure/files?&sort=date > > Not really nice of you, Stranger... > > Frantisek > > > > --~--~-~--~~---

Re: A Clojure documentation browser

2009-02-14 Thread Stephen C. Gilardi
On Feb 14, 2009, at 7:13 AM, Craig Andera wrote: Glad to hear it. :) We talked about getting doc generation to be part of the build, which I think is a fine idea. Whose task is that? clojure-contrib/build.xml is where the change I talked about would go. If you're up for giving it a try, th

Re: Trojan horse in our Files section

2009-02-14 Thread Rich Hickey
On Feb 14, 8:56 am, Jeffrey Straszheim wrote: > Lovely. Thanks for the warning. > > On Sat, Feb 14, 2009 at 6:49 AM, Frantisek Sodomka wrote: > > > > > My antivirus doesn't like the Gift from the Stranger: > >http://groups.google.com/group/clojure/files?&sort=date > > > Not really nice of you,

Concurrency and file writing

2009-02-14 Thread James Reeves
Hi folks, I've been having some difficulty coming up with a scheme for writing to files in a thread-safe manner. The files are named with the hash of their content, so they are effectively immutable. The problem comes with writing them for the first time. I need to ensure that while a file is in

Re: Newbie at macros: Manipulating a vector of bindings

2009-02-14 Thread samppi
Thank you so much. I'm confused, however, about what functions you're allowed to call inside a macro outside of a quote. I read once that "runtime information" was unavailable during the macro phase. But it seems that one is still allowed to call array-map, apply, take-nth, and vec during the macr

Re: Newbie at macros: Manipulating a vector of bindings

2009-02-14 Thread David Nolen
You can pretty much call anything outside of the quote, in fact all runtime information is available (you have access to anything that was previously read). The main thing to understand is that all parameters passed to your macro are unevaluated. On Sat, Feb 14, 2009 at 10:45 AM, samppi wrote:

Re: Trojan horse in our Files section

2009-02-14 Thread bOR_
> Gone now. > > Rich but was it written in clojure? =). --~--~-~--~~~---~--~~ 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

Re: A pipe macro for left-to-right coll streams

2009-02-14 Thread Perry Trolard
Hi Timothy, On Feb 12, 8:08 pm, Timothy Pratley wrote: > What should happen when/if the seq arg doesn't contain the symbol? I > believe how you currently handle it is correct and in the spirit of > let-> (alternatively it could be reported as an error) however it may > raise yet another possibi

Re: Concurrency and file writing

2009-02-14 Thread Dan
On Sat, Feb 14, 2009 at 9:48 AM, James Reeves wrote: > > Hi folks, > > I've been having some difficulty coming up with a scheme for writing > to files in a thread-safe manner. The files are named with the hash of > their content, so they are effectively immutable. > What about making the file an

Re: More Swing Examples

2009-02-14 Thread Sean
Hi, I was trying to run this snake program, written by Mark Volkmann http://www.ociweb.com/mark/programming/ClojureSnake.html I'm getting the following error: Exception in thread "main" java.io.FileNotFoundException: Could not locate clojure/contrib/import_static__init.class or clojure/contrib/

Re: More Swing Examples

2009-02-14 Thread Telman Yusupov
You need to download clojure-contrib library: http://code.google.com/p/clojure-contrib/ On Feb 14, 11:07 am, Sean wrote: > Hi, > I was trying to run this snake program, written by Mark Volkmann > > http://www.ociweb.com/mark/programming/ClojureSnake.html > > I'm getting the following error: > >

Re: cljc?

2009-02-14 Thread Meikel Brandmeyer
Hi, Am 13.02.2009 um 23:02 schrieb Stephen C. Gilardi: the general case, a complete cljc "program" (in my opinion) would need to: [1] create the dest dir if it doesn't already exist [2] launch a clojure instance with that dest dir in classpath [3] compile I wrote a simple cljc as a bash s

Re: run clojure on 5,832 cores?

2009-02-14 Thread Christian Vest Hansen
On Sat, Feb 14, 2009 at 1:31 AM, Stuart Sierra wrote: > > On Feb 13, 6:13 pm, Christian Vest Hansen > wrote: >> I see no mention of a JVM being available for those CPUs, but perhaps >> the no-asm HotSpot can be build with gcc on it. > > Looks like they run Linux, so it would probably be possible

Circular Dependancy Question

2009-02-14 Thread Dan Larkin
So I've got a circular dependency problem. There's a few ways to move functions and (require )s around but the problem remains -- these three files fundamentally depend on one another: parser.clj - lexer & parser (using joshua choi's excellent fnparse library) defaulttags.clj - multimethods

Re: More Swing Examples

2009-02-14 Thread Sean
This worked for me. I downloaded the svn and built it. Once I added the jar to my classpath, I was good to go. I did this by modifying the clj script I use. Thanks! On Feb 14, 12:37 pm, Telman Yusupov wrote: > You need to download clojure-contrib > library:http://code.google.com/p/clojure-c

Re: A Clojure documentation browser

2009-02-14 Thread Craig Andera
> clojure-contrib/build.xml is where the change I talked about would go. If > you're up for giving it a try, that'd be great. I plan to look at it this > weekend unless someone beats me to it. If I did give it a shot, it likely wouldn't be until late next week, so knock yourself out. :) --~--~--

Re: Circular Dependancy Question

2009-02-14 Thread Stephen C. Gilardi
On Feb 14, 2009, at 1:40 PM, Dan Larkin wrote: But as an aside, does this seem to anyone else like a wart on an otherwise great language? Thinking about file layout should not be one of my priorities... the language should not encourage me to put everything together in one file just to get

Re: Circular Dependancy Question

2009-02-14 Thread Dan Larkin
On Feb 14, 2009, at 2:14 PM, Stephen C. Gilardi wrote: > > On Feb 14, 2009, at 1:40 PM, Dan Larkin wrote: > >> But as an aside, does this seem to anyone else like a wart on an >> otherwise great language? Thinking about file layout should not be >> one of my priorities... the language should

Specifying files with spaces in the name to clojure.contrib.command-line

2009-02-14 Thread Kevin Albrecht
This utility is very useful, but it seems unable to handle passing in file names with spaces in them. Example program: ;- begin args.clj (ns args (:use clojure.contrib.command-line)) (with-command-line *command-line-args* "args -- test of args" [filenames] (doseq [filename filen

Re: Trojan horse in our Files section

2009-02-14 Thread Michael Wood
On Sat, Feb 14, 2009 at 5:58 PM, bOR_ wrote: > > >> Gone now. >> >> Rich > > but was it written in clojure? > > =). Nope. It was a rar file containing some text files (religious propaganda) and a Windows .scr (i.e. I assume PE executable, but I didn't check that.) I can't work out if it's a st

why fn key doesn't do what I want?

2009-02-14 Thread wubbie
Hi, a quick question: user=> (keys {:a 1 :b 2}) (:a :b) But user=> (key {:a 1}) java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.util.Map$Entry (NO_SOURCE_FILE:0) I see defn key in core.clj, though. What can be the correct usage of fn key, then? thanks in a

Re: Circular Dependancy Question

2009-02-14 Thread Stephen C. Gilardi
On Feb 14, 2009, at 3:09 PM, Dan Larkin wrote: But thinking about it more, would it be possible to emulate the way python handles circular dependencies? When a file is imported in python the interpreter "evaluates" top-level forms to create a list of exports. Of course the clojure reader

Re: Specifying files with spaces in the name to clojure.contrib.command-line

2009-02-14 Thread Michael Wood
On Sat, Feb 14, 2009 at 10:56 PM, Kevin Albrecht wrote: > > This utility is very useful, but it seems unable to handle passing in > file names with spaces in them. > > Example program: > > ;- begin args.clj > (ns args > (:use clojure.contrib.command-line)) > > (with-command-line *command

Re: Syslog

2009-02-14 Thread Stuart Sierra
On Feb 13, 11:09 am, jim wrote: > Has anyone done logging using syslog from clojure or java? I also find Apache Commons Logging to be a very nice API, either from Clojure or Java. It has back-ends for almost every logging framework. -Stuart Sierra --~--~-~--~~~---~-

Re: why fn key doesn't do what I want?

2009-02-14 Thread Brian Doyle
On Sat, Feb 14, 2009 at 2:24 PM, wubbie wrote: > > Hi, > > a quick question: > > user=> (keys {:a 1 :b 2}) > (:a :b) > > But > user=> (key {:a 1}) > java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot > be cast to java.util.Map$Entry (NO_SOURCE_FILE:0) > > I see defn key in core.

Re: why fn key doesn't do what I want?

2009-02-14 Thread wubbie
thanks! sun On Feb 14, 4:34 pm, Brian Doyle wrote: > On Sat, Feb 14, 2009 at 2:24 PM, wubbie wrote: > > > Hi, > > > a quick question: > > > user=> (keys {:a 1 :b 2}) > > (:a :b) > > > But > > user=> (key {:a 1}) > > java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot > > be ca

why (seq? [1 2 3]) yields false?

2009-02-14 Thread wubbie
Hi, Why vector is not a seq? user=> (seq? [1 2 3]) false user=> (seq? '(1 2 3)) true thanks, -sun --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googl

Re: why (seq? [1 2 3]) yields false?

2009-02-14 Thread Stephen C. Gilardi
On Feb 14, 2009, at 4:47 PM, wubbie wrote: Hi, Why vector is not a seq? user=> (seq? [1 2 3]) false user=> (seq? '(1 2 3)) true Most sequence functions automatically arrange to call "seq" on their arguments, so it's easy to start thinking that Clojure collections *are* seqs. In the gener

Re: why (seq? [1 2 3]) yields false?

2009-02-14 Thread Perry Trolard
wubbie, In case you're asking because you're trying to test for collection- like objects, there are (at least) two ways to do so: 1. coll? tests if its arg implements IPersistentCollection, i.e. is one of the native Clojure persistent collections: user=> (map coll? [{} [] '() #{}]) (true tr

Re: Concurrency and file writing

2009-02-14 Thread James Reeves
On Feb 14, 5:30 pm, Dan wrote: > What about making the file an agent and sending write actions to it? I don't see how that would solve the problem, unless you're suggesting that I have a single agent to handle all reads and writes? - James --~--~-~--~~~---~--~~ Y

Re: Concurrency and file writing

2009-02-14 Thread Laurent PETIT
Hello, You could maybe solve the read problem by also embedding, in the name of the file, its intended content size ? So it could be reasonably cheap to check if a file is present but not yet totally flushed to the disk by comparing its intended size (from its name) and its current real size ? F

Bugs in set and sorted-set (?)

2009-02-14 Thread Frantisek Sodomka
Hello! Function 'set' looses some of its data. It seems that there is a problem with comparison between lists and vectors: user=> (count [nil false true 0 42 0.0 3.14 2/3 0M 1M \c "" "abc" 'sym :kw () '(1 2) [] [1 2] {} {:a 1 :b 2} #{} #{1 2}]) 23 user=> (set [nil false true 0 42 0.0 3.14 2/3 0M

Re: Bugs in set and sorted-set (?)

2009-02-14 Thread Frantisek Sodomka
Similar is: user=> #{[] ()} #{[]} user=> #{[] [1 2]} #{[] [1 2]} user=> (hash-set [] ()) #{[]} Frantisek On Feb 15, 12:38 am, Frantisek Sodomka wrote: > Hello! > Function 'set' looses some of its data. It seems that there is a > problem with comparison between lists and vectors: > > user=> (cou

Re: Creating executable Jars?

2009-02-14 Thread kkw
Hi Emeka, Did you have success in this? Kev On Jan 29, 10:43 pm, Emeka wrote: > luciofulci I'm interested in your instruction, however, are > c:\user\apps\classes > and c:\user\classes the same thing? > > Emeka --~--~-~--~~~---~--~~ You received this message

Re: Bugs in set and sorted-set (?)

2009-02-14 Thread Stephen C. Gilardi
On Feb 14, 2009, at 6:38 PM, Frantisek Sodomka wrote: Function 'set' looses some of its data. It seems that there is a problem with comparison between lists and vectors: "set" is a hash set. It will never contain two items with equal hashes. user=> (hash [1 2]) 994 us

Re: run clojure on 5,832 cores?

2009-02-14 Thread Mark H.
On Feb 14, 10:00 am, Christian Vest Hansen wrote: > You run into problems with the garbage collector when the heap gets > big: the bigger the heap, the longer it takes to compact. Azul has > hardware support for their garbage collector which allows their > compaction phase to run concurrently wit

Re: Concurrency and file writing

2009-02-14 Thread Mark H.
On Feb 14, 6:48 am, James Reeves wrote: > I've been having some difficulty coming up with a scheme for writing > to files in a thread-safe manner. The files are named with the hash of > their content, so they are effectively immutable. > > The problem comes with writing them for the first time. I

Re: Specifying files with spaces in the name to clojure.contrib.command-line

2009-02-14 Thread Kevin Albrecht
Ah, this was the problem, thanks. Michael Wood wrote: > java -server -cp "${CLASSPATH}" clojure.main "${script}" "$@" > > The quotes are necessary around the $@, otherwise you will get the > symptoms you are seeing. --~--~-~--~~~---~--~~ You received this message b

map across code

2009-02-14 Thread kyle smith
I'm trying to map across code, but map evals each item in the list. I've been trying to re-implement map as a macro, but so far no success. Is there some way to accomplish this? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Googl

Re: map across code

2009-02-14 Thread Stephen C. Gilardi
On Feb 14, 2009, at 9:07 PM, kyle smith wrote: I'm trying to map across code, but map evals each item in the list. I've been trying to re-implement map as a macro, but so far no success. Is there some way to accomplish this? Could you post a short example of the input and output you'd like t

Re: map across code

2009-02-14 Thread kyle smith
Well, I'm just doing some exploratory programming, so I don't really have anything yet. I'd like to do something like (map a-macro some-code) What I can't do is (map #(a-macro %) some-code) because % evals each code fragment. --~--~-~--~~~---~--~~ You received this

Re: map across code

2009-02-14 Thread Stuart Sierra
On Feb 14, 9:07 pm, kyle smith wrote: > I'm trying to map across code, but map evals each item in the list. > I've been trying to re-implement map as a macro, but so far no > success.  Is there some way to accomplish this? clojure.contrib.template/do-template may do what you want. -Stuart Sierr

Re: Concurrency and file writing

2009-02-14 Thread Kevin Downey
http://www.exampledepot.com/egs/java.io/CreateTempFile.html On Sat, Feb 14, 2009 at 4:38 PM, Mark H. wrote: > > On Feb 14, 6:48 am, James Reeves wrote: >> I've been having some difficulty coming up with a scheme for writing >> to files in a thread-safe manner. The files are named with the hash

Re: Git : I'm lazy

2009-02-14 Thread Kyle Schaffrick
On Wed, 11 Feb 2009 23:07:31 -0500 "Stephen C. Gilardi" wrote: > > On Feb 11, 2009, at 10:57 PM, Jeffrey Straszheim wrote: > > > I know I should look this up on the web, but I'm really busy these > > days. I do intend to learn git someday, but I'm doing fine with > > Subversion for my own

Re: Git : I'm lazy

2009-02-14 Thread Stephen C. Gilardi
On Feb 14, 2009, at 10:44 PM, Kyle Schaffrick wrote: Hmm, forgive a possibly stupid question: Do you not also need to do a "git update" to update your working copy to the new head revision? I don't know git that well, but it seems like many DVCSs like mercurial distinguish between "pull" an

Re: Bugs in set and sorted-set (?)

2009-02-14 Thread Chouser
On Sat, Feb 14, 2009 at 7:19 PM, Stephen C. Gilardi wrote: > > "set" is a hash set. It will never contain two items with equal hashes. I don't think that's quite right. I don't think it matters in this case, but hash values aren't guaranteed unique. A hash-map can have two keys with the same h

Re: Specifying files with spaces in the name to clojure.contrib.command-line

2009-02-14 Thread Chouser
On Sat, Feb 14, 2009 at 3:56 PM, Kevin Albrecht wrote: > > P.S. Also, unrelated to this problem, the following line in the > example code in command_line.clj is missing the vector surrounding the > bindings of the doseq: > > :else (doseq filename filenames Fixed, thanks. --Chouser --~--

Re: how to emulate lisp's labels functionality?

2009-02-14 Thread GS
On Feb 14, 12:21 pm, Chouser wrote: > > (defn count-instances [obj lsts] > >   (let [instances-in (fn [lst] > >                        (if (cons? lst) > >                          (+ (if (= (first lst) obj) 1 0) > >                             (instances-in (rest lst))) > >                      

Re: Bugs in set and sorted-set (?)

2009-02-14 Thread Stephen C. Gilardi
On Feb 14, 2009, at 11:10 PM, Chouser wrote: I don't think that's quite right. I don't think it matters in this case, but hash values aren't guaranteed unique. A hash-map can have two keys with the same hash value as long as = returns false. Vectors and lists with the same values evaluate as

Re: Git : I'm lazy

2009-02-14 Thread Kyle Schaffrick
On Sat, 14 Feb 2009 22:58:33 -0500 "Stephen C. Gilardi" wrote: > > On Feb 14, 2009, at 10:44 PM, Kyle Schaffrick wrote: > > > Hmm, forgive a possibly stupid question: Do you not also need to do > > a "git update" to update your working copy to the new head revision? > > > > I don't know git th

Re: how to emulate lisp's labels functionality?

2009-02-14 Thread Chouser
On Sat, Feb 14, 2009 at 11:32 PM, GS wrote: > > On Feb 14, 12:21 pm, Chouser wrote: >> >> (defn count-instances [obj lsts] >> (let [instances-in (fn thisfn [lst] >>(if (seq lst) >> (+ (if (= (first lst) obj) 1 0) >> (