Re: The function of clojure.contrib.accumulators

2009-04-29 Thread Konrad Hinsen
On 29.04.2009, at 21:44, samppi wrote: > Could someone give me a simple example of when > clojure.contrib.accumulators is useful? Its use seems to involve > collections (and numbers) that have the :clojure.contrib.accumulators/ > accumulator type, and it has some general multimethods for adding a

Re: regex replace all?

2009-04-29 Thread Mark Derricutt
Cool, I think I'll stick to my current one which lets me easily use multiple replacements in one call. -- Discouragement is a dissatisfaction with the past, a distaste for the present, and a distrust of the future - Maree De Jong, Life Church New Zealand. http://www.talios.com Sent from Auckland

Re: update/update-in

2009-04-29 Thread David Nolen
I see what you mean, does seem like a useful addition: (defn update [m k f & args] (assoc m k (apply f (k m) args))) (update {:foo 0} :foo inc) vs. (assoc {:foo 0} :foo (inc (:foo {:foo 0}))) On Wed, Apr 29, 2009 at 7:13 PM, mifrai wrote: > > Thanks for the quick reply and I understand that

Re: regex replace all?

2009-04-29 Thread Baishampayan Ghose
Mark Derricutt wrote: > Does clojure come with a built-in regex replace method? I see ones for > re-split, re-seq etc. but nothing for a simple replace, I've been using: > > (defn replace-all > [st reps] > (reduce #(.replaceAll %1 (first %2) (second %2)) st reps)) There is re-gsub in clojur

Re: Metadata for Any Object

2009-04-29 Thread Laurent PETIT
Hi, 2009/4/30 Stuart Sierra : > > On Apr 29, 5:58 pm, Stu Hood wrote: >> Instead of attaching the metadata directly to the object, what if the >> metadata was stored outside the object, in a global map of {object metadata, >> ...}? In order to handle garbage collection, something similar to Java

regex replace all?

2009-04-29 Thread Mark Derricutt
Does clojure come with a built-in regex replace method? I see ones for re-split, re-seq etc. but nothing for a simple replace, I've been using: (defn replace-all [st reps] (reduce #(.replaceAll %1 (first %2) (second %2)) st reps)) but wondered if I was just missing some builtin? -- Discour

Re: how do I create a runnable clojure program

2009-04-29 Thread e
incidentally, I seem to remember that the enclojure netbeans plugin does all this for you, and even outputs the exact command you need to run to execute. a default project starts with such a -main. That said, it's probably not a good way to really understand what's going on ... if that's a goal.

Re: Metadata for Any Object

2009-04-29 Thread Stuart Sierra
On Apr 29, 5:58 pm, Stu Hood wrote: > Instead of attaching the metadata directly to the object, what if the > metadata was stored outside the object, in a global map of {object metadata, > ...}? In order to handle garbage collection, something similar to Java's > WeakHashMap could be used, with t

Re: Git with Google Code

2009-04-29 Thread Kevin O'Neill
Baring server hickups it checks for updates once an hour. -k. On Thu, Apr 30, 2009 at 7:20 AM, Cosmin Stejerean wrote: > On Wed, Apr 29, 2009 at 3:57 PM, Kevin O'Neill wrote: >> >> no you have that the wrong way around. windows sucks :) >> >> if you dont want to (or can't) use git-svn i mainta

Re: update/update-in

2009-04-29 Thread mifrai
Thanks for the quick reply and I understand that's the functionality of it. But just like get-in is the recursive form of get - I'm just wondering why there's no singular form of update-in. I know it's not much more work to go (update-in map [:single-key] conj 3) - but from experience there tend

Re: update/update-in

2009-04-29 Thread David Nolen
Because update-in can use any function to do the update. On Wed, Apr 29, 2009 at 6:54 PM, mifrai wrote: > > Hi, > > I was wondering why there was no "update" to "update-in"? But there is > an "assoc" to "assoc-in" and a "get" to a "get-in". > > - Mike > > > --~--~-~--~~~

update/update-in

2009-04-29 Thread mifrai
Hi, I was wondering why there was no "update" to "update-in"? But there is an "assoc" to "assoc-in" and a "get" to a "get-in". - Mike --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this

Dropping strings.

2009-04-29 Thread Nicolas Buduroi
Hi, I was wondering if there's a drop function somewhere in contrib that work for strings. I didn't found any so I wrote my own: (defn drop-str ([s] (drop-str 1 s)) ([n s] (apply str (drop n (seq s) This is not really fast, a better version would be something like that: (defn drop-str [

Monads tutorial Part 2

2009-04-29 Thread jim
I've just posted the second part of my monads tutorial at: http://intensivesystems.net/tutorials/monads_201.html I need to proof it further, so if you see problems with content, grammar or spelling. Comment here or send me an email. Jim --~--~-~--~~~---~--~~ You

Metadata for Any Object

2009-04-29 Thread Stu Hood
Hey gang, Metadata support for pure Java objects is not currently supported, because it requires a modification to the object. Additionally, only some Clojure objects support metadata, due to the necessity of implementing the IMeta interface. This can be confusing for new users, and eliminates som

Re: Git with Google Code

2009-04-29 Thread Cosmin Stejerean
On Wed, Apr 29, 2009 at 3:57 PM, Kevin O'Neill wrote: > > no you have that the wrong way around. windows sucks :) > > if you dont want to (or can't) use git-svn i maintain a mirror on git > hub (http://github.com/kevinoneill/clojure/tree/master). > Thanks for maintaining that, it's what I always

Re: Git with Google Code

2009-04-29 Thread Kevin O'Neill
no you have that the wrong way around. windows sucks :) if you dont want to (or can't) use git-svn i maintain a mirror on git hub (http://github.com/kevinoneill/clojure/tree/master). -k. On Wed, Apr 29, 2009 at 6:36 AM, Rayne wrote: > > Git still sucks on windows :\ > > On Apr 28, 11:04 am, St

Re: UTF-8

2009-04-29 Thread Laurent PETIT
2009/4/29 Stephen C. Gilardi : > > On Apr 29, 2009, at 12:54 PM, Rich Hickey wrote: > >> Ok - patch welcome ASAP (not singling out you Laurent :) > > > I've entered an issue and provided a patch: > >        http://code.google.com/p/clojure/issues/detail?id=112 > That was quick ! :-) --~--~--

Re: UTF-8

2009-04-29 Thread Perry Trolard
For those on OS X -- who probably don't want the default MacRoman -- or anyone else who wants to override the system default, I wanted to point out that setting the "file.encoding" system property when invoking java (e.g. `java -Dfile.encoding=UTF-8 ... clojure.main`) will set the encoding for in,

The function of clojure.contrib.accumulators

2009-04-29 Thread samppi
Could someone give me a simple example of when clojure.contrib.accumulators is useful? Its use seems to involve collections (and numbers) that have the :clojure.contrib.accumulators/ accumulator type, and it has some general multimethods for adding and combining, but what does it add that conj and

Re: UTF-8

2009-04-29 Thread Rich Hickey
On Apr 29, 1:24 pm, "Stephen C. Gilardi" wrote: > On Apr 29, 2009, at 12:54 PM, Rich Hickey wrote: > > > Ok - patch welcome ASAP (not singling out you Laurent :) > > I've entered an issue and provided a patch: > >http://code.google.com/p/clojure/issues/detail?id=112 > Patch applied - r

Re: how do I create a runnable clojure program

2009-04-29 Thread Santanu
Thanks everyone for your suggestions. I somehow managed to compile my first clojure program, generating a class file that I could run using java. I started with the overview provided by Stuart Sierra, and read the article pointed by Raphaël. Didn't work at first, but after some trial and error, it

Re: more vimclojure

2009-04-29 Thread Meikel Brandmeyer
Hi, Am 29.04.2009 um 19:07 schrieb Meikel Brandmeyer: - here (I feel a little uncomfortable with that, but as long as the "I can't get SLIME to work" thread show up, it's ok, I think) A fourth place is now the VimClojure Google Group: http://groups.google.com/group/vimclojure Sincerely Mei

Re: more vimclojure

2009-04-29 Thread Mitch
I'd like to add how great I think VimClojure is. It's truly an amazing environment and I don't think I'd be able to enjoy clojure as much without it. I'm too committed to vim to learn emacs for a new language. Thanks a lot Meikel! On Apr 29, 10:13 am, Meikel Brandmeyer wrote: > Hi Adrian, > >

Re: Getting slime-edit-definition to work with Clojure

2009-04-29 Thread Phil Hagelberg
Baishampayan Ghose writes: > Can you kindly share your working dotfiles and enlighten me? I use M-x clojure-install plus (clojure-slime-config), since I wrote it. This this is _all_ you need for projects that don't have dependencies on third-party jars. For some other projects, I've been using

Re: Clojure talk in NYC May 12

2009-04-29 Thread DiG
I will be there too. On Apr 29, 11:16 am, Stuart Sierra wrote: > Hi, Clojurians, > I'll be talking about my work with Clojure at LispNYC on Tuesday, May > 12.  Time (evening) & location to be announced.  Slides and > (hopefully) video available after. > > Possible topics: >  * Clojure with Java

Re: how do I create a runnable clojure program

2009-04-29 Thread Rayne
Not really, he just needs decent instructions. :p I don't know a line of Java. I figured it out. :) On Apr 29, 9:15 am, Stuart Sierra wrote: > Hi Santanu, > Unfortunately, this is not a well-documented area, but it is > possible.  Here's the high-level view, but don't expect these > instructions

Re: UTF-8

2009-04-29 Thread Stephen C. Gilardi
On Apr 29, 2009, at 12:54 PM, Rich Hickey wrote: Ok - patch welcome ASAP (not singling out you Laurent :) I've entered an issue and provided a patch: http://code.google.com/p/clojure/issues/detail?id=112 Thanks, --Steve smime.p7s Description: S/MIME cryptographic signature

Re: more vimclojure

2009-04-29 Thread Meikel Brandmeyer
Hi Adrian, Am 29.04.2009 um 07:00 schrieb Adrian Cuthbertson: In the absence of an issue tracker at this time, could I mention the following relating to indenting; (defn xxx "Some stuff... (defmacro xxx "Some stuff... (defroutes xxx "Some stuf... This can be configured us

Re: more vimclojure

2009-04-29 Thread jim
Meikel, I'm liking what I've seen so far of vimclojure. One request is to have the preview window stay up all the time and keep adding to it with the \ef, \et, \eb, etc. commands. Having it come and go is distracting to me. My $0.02 Thanks, Jim On Apr 29, 12:07 pm, Meikel Brandmeyer wrote: >

Re: more vimclojure

2009-04-29 Thread Meikel Brandmeyer
Hi, Am 29.04.2009 um 04:42 schrieb Johan Berntsson: I've been emailing directly to Meikel, but perhaps a issue tracker of some kind would be good? It is of course up to Meikel, and VimClojure is already good enough for me to use for all my Clojure hacking (including some paid work). As for bu

Re: Example Server in Clojure

2009-04-29 Thread Chris McClellen
Thanks for the replies so far. Phil, I'll look into mire - I like that it is broken into steps to show the progression. Laurent - Thanks for the info I'll put that change in tonight when I'm out from behind this firewall. On Apr 29, 12:25 pm, Phil Hagelberg wrote: > Chris McClellen writes: >

Re: UTF-8

2009-04-29 Thread Rich Hickey
On Apr 29, 9:25 am, Laurent PETIT wrote: > Yes, not fixing it before 1.0 would be the kind of thing that people > willing to make FUD on clojure would exploit really easily with great > success: > > "clojure does not even handle encoding problems well" > Ok - patch welcome ASAP (not singling o

Re: Getting slime-edit-definition to work with Clojure

2009-04-29 Thread Christopher Wilson
Here's a .emacs snippet that works for me: ;; SLIME setup (clojure) (add-to-list 'load-path "~/.emacs.d/slime/") ; your SLIME directory (add-to-list 'load-path "~/.emacs.d/") ; clojure-mode.el is here (add-to-list 'load-path "~/.emacs.d/swank-clojure") ; swank-clojure directory (setq swank-cloju

Re: Feature Request: Easily Embeddable Console

2009-04-29 Thread kyle smith
See repl.clj in the files section. I've embedded it in a few of my apps, and it's quite nice. --~--~-~--~~~---~--~~ 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: Example Server in Clojure

2009-04-29 Thread Phil Hagelberg
Chris McClellen writes: > I ended up writing a chat server in clojure, thats weighs in at about > 189 lines of code (not counting comments and blank lines). I am > fairly new to clojure so I was hoping people could take a look at it > and give constructive comments about what I did right and wh

Re: learning clojure, converting a sequence with repetitions to a multi-map

2009-04-29 Thread Christophe Grand
IMHO, the slowdown comes from allocation: with (apply merge-with concat (map (fn [x] {(key-fn x) [x]}) s)) you build a map containing a vector, plus a seq (merge-with calls seq on each argument) for each item before performing a reduction which calls assoc and concat. In seq-to-multimap you o

Re: Clojure talk in NYC May 12

2009-04-29 Thread Stuart Sierra
On Apr 29, 11:21 am, Rich Hickey wrote: > I'll be there - looking forward to it! Ooh, pressure. Guess I gotta make it good. -SS --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group,

Re: learning clojure, converting a sequence with repetitions to a multi-map

2009-04-29 Thread Boris Mizhen
Thanks Jason. merge-with seems to be made to support a function like this, I wonder where is the slowdown coming from? Is apply slow? I named your version seq-to-multimap2. The timing results are below: user> (def a (reverse (take 10 (iterate (fn [x] (rand-int 100)) 1 #'user

Re: Clojure talk in NYC May 12

2009-04-29 Thread Laurent PETIT
2009/4/29 Stuart Sierra : > > Hi, Clojurians, > I'll be talking about my work with Clojure at LispNYC on Tuesday, May > 12.  Time (evening) & location to be announced.  Slides and > (hopefully) video available after. Excellent, keep us informed when the video are available! Have a nice talk, --

Re: Clojure talk in NYC May 12

2009-04-29 Thread Rich Hickey
On Apr 29, 11:16 am, Stuart Sierra wrote: > Hi, Clojurians, > I'll be talking about my work with Clojure at LispNYC on Tuesday, May > 12. Time (evening) & location to be announced. Slides and > (hopefully) video available after. > > Possible topics: > * Clojure with Java libraries like Hadoo

Clojure talk in NYC May 12

2009-04-29 Thread Stuart Sierra
Hi, Clojurians, I'll be talking about my work with Clojure at LispNYC on Tuesday, May 12. Time (evening) & location to be announced. Slides and (hopefully) video available after. Possible topics: * Clojure with Java libraries like Hadoop & Solr * Deploying a web server with Clojure & Restlet

Re: java enum problem

2009-04-29 Thread brus
On 29 tra, 17:00, Stuart Sierra wrote: > On Apr 29, 10:14 am, brus wrote: > > > (def AShow (proxy [Enum] ["AlwaysShow" 1])) > > I don't think you can proxy an enumeration.  You can use gen-class, > but even that doesn't work perfectly.  You may need to break down and > write some Java. > > -Stu

Re: learning clojure, converting a sequence with repetitions to a multi-map

2009-04-29 Thread Boris Mizhen
Thanks Christophe, > Using a default return value, you can rewrite the (if-let...) as (conj > (amap key ()) item). A good point, getting clojure and clojure :) (defn seq-to-multimap "takes a sequence s of possibly repeating elements and converts it to a map, where keys are obtained by app

Re: Example Server in Clojure

2009-04-29 Thread Laurent PETIT
Hi, Not a thourough analysis of your code, but still one remark at least : For each of your files that are part of a namespace but the main file, you should consider placing an (in-ns 'name.of.the.loading.ns) call at the top of the file. This will help IDEs, and also you when you just want to r

Re: java enum problem

2009-04-29 Thread Stuart Sierra
On Apr 29, 10:14 am, brus wrote: > (def AShow (proxy [Enum] ["AlwaysShow" 1])) I don't think you can proxy an enumeration. You can use gen-class, but even that doesn't work perfectly. You may need to break down and write some Java. -Stuart Sierra --~--~-~--~~~---~-

Re: Example Server in Clojure

2009-04-29 Thread tmountain
I'm new to Clojure as well and am also writing a server. Side effects are hard to avoid when doing things like I/O, so I wouldn't feel too bad about it. From the looks of your code, you've done a nice job separating things like network communication from the business logic of your chat server. I h

Re: how do I create a runnable clojure program

2009-04-29 Thread rb
On Apr 29, 1:04 pm, Santanu wrote: > Hi Everybody, > > I wanted to compile a .clj clojure file into a .jar/.class file so > that I could run it using java. (I don't know what is the actual way > to run clojure file. So far, I have only been trying it from within > emacs/slime). > > But I don't

Re: how do I create a runnable clojure program

2009-04-29 Thread tmountain
There was a very recent thread on the list related to the same question: http://groups.google.com/group/clojure/browse_thread/thread/750e5795141cff35# HTH, Travis On Apr 29, 7:04 am, Santanu wrote: > Hi Everybody, > > I wanted to compile a .clj clojure file into a .jar/.class file so > that I

Re: how do I create a runnable clojure program

2009-04-29 Thread Stuart Sierra
Hi Santanu, Unfortunately, this is not a well-documented area, but it is possible. Here's the high-level view, but don't expect these instructions to be sufficient: 1. Put (:gen-class) in the (ns...) declaration in your .clj file. 2. Add a -main function like: (defn -main [& args] ...) 3. Com

java enum problem

2009-04-29 Thread brus
Hello to community. I'm trying to convert this "jMonkey Engine" java's code to Clojure: . public class TestSimpleGame extends SimpleGame { public static void main(String[] args) { TestSimpleGame app = new TestSimpleGame();

Re: Git with Google Code

2009-04-29 Thread Vincent Foley
http://article.gmane.org/gmane.comp.version-control.git/117039 On Apr 29, 1:01 am, Dan wrote: > On Tue, Apr 28, 2009 at 4:36 PM, Rayne wrote: > > > Git still sucks on windows :\ > > On which grounds? > > Or as wikipedia would put it [citation needed] --~--~-~--~~~---

Re: UTF-8

2009-04-29 Thread Laurent PETIT
Yes, not fixing it before 1.0 would be the kind of thing that people willing to make FUD on clojure would exploit really easily with great success: "clojure does not even handle encoding problems well" :'( 2009/4/29 Toralf : > > On Apr 29, 1:30 pm, David Powell wrote: >> So, I'd like to see th

Re: UTF-8

2009-04-29 Thread Toralf
On Apr 29, 1:30 pm, David Powell wrote: > So, I'd like to see the constants in RT.java changed to not specify UTF-8, > but for the encoding used by > the compiler to continue to specify UTF-8. +1 --~--~-~--~~~---~--~~ You received this message because you are su

Re: Git with Google Code

2009-04-29 Thread Christophe Grand
git-svn has been reenabled in msysgit since one or two releases and works well. Luke Amdor a écrit : > I believe git-svn doesn't work under msysgit. When I did have use git > under windows, I used cygwin's git. It did everything that the *nix > git could do. > > Luke > > On Apr 29, 4:03 am, Mark

Re: UTF-8

2009-04-29 Thread Stephen C. Gilardi
On Apr 29, 2009, at 7:30 AM, David Powell wrote: So, I'd like to see the constants in RT.java changed to not specify UTF-8, but for the encoding used by the compiler to continue to specify UTF-8. Anyone have any opinions? I think your explanation, reasoning, and conclusions are all exactly

Re: Git with Google Code

2009-04-29 Thread Luke Amdor
I believe git-svn doesn't work under msysgit. When I did have use git under windows, I used cygwin's git. It did everything that the *nix git could do. Luke On Apr 29, 4:03 am, Marko Kocić wrote: > (defn on-windows [x] >   (use "http://code.google.com/p/msysgit";) >   'success) > > On 29 апр, 1

UTF-8

2009-04-29 Thread David Powell
There seems to be two separate issues regarding character sets in Clojure: 1) What encoding should clojure use to read/write to *in*, *out*, and *err*? 2) What encoding should clojure's use to load .clj files. For 1) Clojure currently uses UTF-8 - this is hardcoded in the constants for those

how do I create a runnable clojure program

2009-04-29 Thread Santanu
Hi Everybody, I wanted to compile a .clj clojure file into a .jar/.class file so that I could run it using java. (I don't know what is the actual way to run clojure file. So far, I have only been trying it from within emacs/slime). But I don't know how to create the .class/.jar file. I also don'

Re: cannot use swig native shared libraries

2009-04-29 Thread Antonio, Fabio Di Narzo
2009/4/29 Tony Hursh : > > > On Apr 27, 2009, at 8:45 PM, jim wrote: > >> >> Hey Antonio, >> >> I'm getting a similar error. I wanted to call setuid from Clojure, so >> I followed this link's example: >> http://www2.sys-con.com/itsg/virtualcd/Java/archives/0510/Silverman/index.html >> >> to build

Example Server in Clojure

2009-04-29 Thread Chris McClellen
I wanted to write an example server in clojure to show some folks at the office what a full from the ground up application might look like in clojure. I wanted a non-trivial example, but not one so complex that a new clojure user wouldn't understand it. I had ported some decent algorithms we us

Re: cannot use swig native shared libraries

2009-04-29 Thread Tony Hursh
On Apr 27, 2009, at 8:45 PM, jim wrote: > > Hey Antonio, > > I'm getting a similar error. I wanted to call setuid from Clojure, so > I followed this link's example: > http://www2.sys-con.com/itsg/virtualcd/Java/archives/0510/Silverman/index.html > > to build a java class and a shared library. I

Re: Git with Google Code

2009-04-29 Thread Marko Kocić
(defn on-windows [x] (use "http://code.google.com/p/msysgit";) 'success) On 29 апр, 10:55, dysinger wrote: > Let me abstract that out a little for you :P > > (defn on-windows [x] >   (format "%s sucks on windows!" x)) > > On Apr 28, 1:36 pm, Rayne wrote: > > > Git still sucks on windows :\

Re: Git with Google Code

2009-04-29 Thread dysinger
Let me abstract that out a little for you :P (defn on-windows [x] (format "%s sucks on windows!" x)) On Apr 28, 1:36 pm, Rayne wrote: > Git still sucks on windows :\ > > On Apr 28, 11:04 am, Stuart Sierra > wrote: > > > FYI, for those interested in using Git for Clojure sources, here's > > G

Re: Git with Google Code

2009-04-29 Thread dysinger
Or you can just point github.com at the svn repo. Stuart Sierra wrote: > FYI, for those interested in using Git for Clojure sources, here's > Google's advice on how to use Git with Google Code: > > http://google-opensource.blogspot.com/2008/05/develop-with-git-on-google-code-project.html > > -SS

Feature Request: Easily Embeddable Console

2009-04-29 Thread ianp
IMHO it would be good if there were an easy (i.e. 1-line) way of embedding Clojure in an existing Swing app. most of the docs out there cover embedding it in a console application, or using Swank to connect over a socket. Ideally, either: JPanel panel = ...; panel.add(new ClojureConsole(

Re: -> and type hints

2009-04-29 Thread Christophe Grand
Christophe Grand a écrit : > Bad example: > (-> "hello world" (.split " ") #^String second (.split "o") seq) ; > actually works > but not: > (-> "hello world" (.split " ") #^String (second) (.split "o") seq) ; > works only with the patched -> > Or I should put up and write (-> "hello w

Re: -> and type hints

2009-04-29 Thread Christophe Grand
Bad example: (-> "hello world" (.split " ") #^String second (.split "o") seq) ; actually works but not: (-> "hello world" (.split " ") #^String (second) (.split "o") seq) ; works only with the patched -> Christophe Grand a écrit : > Hello, > > Currently when you have a reflection warning in

-> and type hints

2009-04-29 Thread Christophe Grand
Hello, Currently when you have a reflection warning in a -> form, you have to split it: clojure.core=> (-> "hello world" (.split " ") second (.split "o") seq) Reflection warning, line: 1269 - call to split can't be resolved. ("w" "rld") I propose to modify the -> macro to make it preserve typ

Re: Post 1.0 features

2009-04-29 Thread Konrad Hinsen
On 29.04.2009, at 01:53, Rich Hickey wrote: > I've moved some of my notes on future features here: > > http://clojure.org/todo - everything isa? some-root I posted a patch for that a while ago: http://groups.google.com/group/clojure/browse_thread/thread/ bc5193304c1ab2e3/77e5d53d8ccd6b10?lnk=