Re: globing filenames via clojure

2009-12-12 Thread Travis
On Dec 12, 11:20 am, Scott wrote: > Trying to learn clojure via some simple examples. > > I would like to use a simple glob expression to open a file using read- > line > > How would I write the equivalent of: > > (for [line (read-lines "*.txt")] >     (print line)) > > Where *.txt would match o

Re: Mapping OOPS concepts to Clojure? Doable or Wrong thinking?

2009-12-12 Thread Raoul Duke
hi, > 2. In my mind, the single most important use of OO is polymorphism. > The ability to associate functions with multiple implementations > depending on their parameters is very useful since it means you can > generalize algorithms without having to know the implementation > details of the data

Re: Mapping OOPS concepts to Clojure? Doable or Wrong thinking?

2009-12-12 Thread Travis
On Dec 12, 9:21 am, Joost wrote: > * Inheritance is overrated. it tends to be abused as a way to share > implementation details more than anything else. All the points I made > about interfaces also apply to inheritance. See also traits, for a way > to really do reuse:http://scg.unibe.ch/researc

Re: Code arrangement for understandability

2009-12-12 Thread Sean Devlin
Adrian's comments are spot on, and they can be a bit intimidating to a newcomer. Let me offer a piece of encouragement. There's an interesting result from the way Clojurians code as described above. Every once in a while, someone will do something so radically brilliant with the built in construc

Re: Code arrangement for understandability

2009-12-12 Thread Richard Newman
> This is not meant to be patronising, but I think it does speak to the > problem of "disjoint" between experienced Clojure/Lisp'ers and noobs > learning the language. They tend to code as above, but when trying to > help people who are learning, they try to bridge the (imperative) gap > by breakin

Re: Code arrangement for understandability

2009-12-12 Thread Adrian Cuthbertson
> (reduce (fn [model f] (assoc model f (inc (get model f 1 >{} features)) > Do Clojurians usually arrange like that? Can it be rearrange for more > understandability? I would write it exactly like that. What happens as you become familiar with Clojure is that the patterns of the api b

Re: more dumb noob pain ("2dplot.clj")

2009-12-12 Thread ataggart
If it's a java project, then you can just select the jars, right- click, choose Build Path > Add to Build Path. You can also do it through Project > Properties >Java Build Path. On Dec 12, 6:32 pm, rebcabin wrote: > I got a lot closer thanks to the great hints above; the current state > is this

Re: more dumb noob pain ("2dplot.clj")

2009-12-12 Thread rebcabin
I got a lot closer thanks to the great hints above; the current state is this C:\usr\local\bin>java -cp clojure-1.0.0.jar;clojure-contrib.jar;j3d- core-1.3.1.j ar;j3dcore-ogl.dll;vecmath.jar;j3dutils.jar;j3dcore-d3d.dll clojure.lang.Repl Clojure 1.0.0- user=> (load-file "/Users/Reb/workspace/2dplo

Re: zipper for JSON data?

2009-12-12 Thread Paul_B_Hansen
Thanks Alex! I like the approach of using get-in/assoc-in/update-in much better than using a zipper. I'll go read the api documentation on those... Thanks again. On Dec 12, 4:36 pm, "Alex Osborne" wrote: > "Alex Osborne" writes: > > (-> (map-zip {:foo {:bar {:baz 2}}}) > >     zip/down > >  

Re: boolean-array in clojure

2009-12-12 Thread Alex Osborne
Michael Wood writes: > I don't think boolean-array exists in 1.0. Try this instead: > > user=> (into-array Boolean [true true false true]) > # > > although that gives you an array of Booleans instead of booleans. (into-array Boolean/TYPE [true false]) ;; => # -- You received this message beca

Re: Clojure & Contrib "master" & "new" on build.clojure.org

2009-12-12 Thread liebke
Thanks Tim! I've put together an experimental build of Incanter using the new builds: http://groups.google.com/group/incanter/browse_thread/thread/94b30744fee1095e I ran into a minor issue with Clojure's new branch that I was able to work around but couldn't diagnose (more details in the linked p

Re: Mapping OOPS concepts to Clojure? Doable or Wrong thinking?

2009-12-12 Thread mbrodersen
Cleaned it up a bit: (defmacro ? [object value] "Get an object value - same as object.value; in C# but immutable" `(get ~object (keyword (str '~value (defmacro ! [object method & args] "Call an object method - same as object.method(args); in C# but immutable" `

Re: Mapping OOPS concepts to Clojure? Doable or Wrong thinking?

2009-12-12 Thread mbrodersen
There is nothing "wrong" about objects in Clojure as long as the objects are immutable. Some people tend to think that "functional" is anti-"object oriented". That is IMHO the wrong way to think. They complement each other. Why limit the tools in your toolbox? F# (for example) shows how it can be

Re: zipper for JSON data?

2009-12-12 Thread Alex Osborne
"Alex Osborne" writes: > (-> (map-zip {:foo {:bar {:baz 2}}}) > zip/down > zip/down > (zip/insert-right [:greeting "Hello!"]) > zip/down > (zip/edit (val-editor inc)) > zip/root) > > ;; => [:root {:foo {:greeting "Hello!", :bar {:baz 3}}}] I should also probably point out

Re: zipper for JSON data?

2009-12-12 Thread Alex Osborne
Paul_B_Hansen writes: > I tried to simply get a zipper working for nested > maps but I didn't succeed. My attempt is below: > > (defn map-zip [root] > (zip/zipper map? > seq > (fn [node children] (with-meta (hash-map children) (meta > node))) > root))

Re: Leiningen in Python

2009-12-12 Thread Rob Wolfe
Mike K writes: > All, > > I tried to use this script on Windows and it blew up real good! I'm a > Clojure, Java, and Leiningen newbie, so perhaps a kind soul can help > me out. > > 1. lein self-install "worked". It downloaded leiningen-1.0.0- > standalone.jar. However, that contradicts the de

Clojure & Contrib "master" & "new" on build.clojure.org

2009-12-12 Thread dysinger
I created addition pairs of maven snapshot CI builds for clojure & contrib. Repository : http://build.clojure.org/snapshots "master": org.clojure:clojure:1.1.0-master-SNAPSHOT org.clojure:clojure-contrib:1.1.0-master-SNAPSHOT "new" org.clojure:clojure:1.1.0-new-SNAPSHOT org.clojure:clojure-cont

Re: Mapping OOPS concepts to Clojure? Doable or Wrong thinking?

2009-12-12 Thread Michael Wood
Hi 2009/12/12 ajay gopalakrishnan : > Hi, > > I come from a OOPS (Java) world and I am used to Singletons, Inheritance, > Statics, Interfaces etc. > I am reading the Programming Clojure book and I understand multi-methods and > when it is used. > But I am still not able to see how to achieve the e

Re: Mapping OOPS concepts to Clojure? Doable or Wrong thinking?

2009-12-12 Thread ajay gopalakrishnan
@Joost , Excellent Description. Of the sort that I was really hoping for! Indeed a heavy meal to digest, for an OOP person, but I see your point. Thanks! Ajay On Sat, Dec 12, 2009 at 12:21 PM, Joost wrote: > On 12 dec, 14:13, ajay gopalakrishnan wrote: > > Hi, > > > > I come from a OOPS (Java)

globing filenames via clojure

2009-12-12 Thread Scott
Trying to learn clojure via some simple examples. I would like to use a simple glob expression to open a file using read- line How would I write the equivalent of: (for [line (read-lines "*.txt")] (print line)) Where *.txt would match only the first file found in the present working directo

Re: Leiningen in Python

2009-12-12 Thread Mike K
I could not get the python script to work, so I switched to the powershell version. I now understand that the leiningen-1.0.0-SNAPSHOT.jar is a so-called "uberjar" and contains all the dependencies for leiningen. However, the python script assumes clojure is from a separate jar which is not insta

Re: more dumb noob pain ("2dplot.clj")

2009-12-12 Thread Michael Wood
2009/12/12 rebcabin : > Well, the 3d test applications from https://j3d-webstart.dev.java.net/test/ Java Webstart works differently to something run from the command line. When you click on the link it downloads a .jnlp file that, I believe, mentions all the dependencies. > work correctly and ev

Re: Clojure analysis

2009-12-12 Thread Joseph Smith
I think referring to clojure as a multiparadigm languge is incorrect. --- Joseph Smith j...@uwcreations.com (402)601-5443 On Dec 11, 2009, at 3:04 PM, kusi wrote: > http://kusimari.blogspot.com/2009/12/analysing-clojure-programming-language.html > > -- > You received this message because you

Re: Clojure analysis

2009-12-12 Thread Joost
On 12 dec, 17:29, Sean Devlin wrote: > First, is the STM.  This is THE killer feature of the language. > Ironically, it gives Clojure its identity, and ridiculously clean > design.  Write a concurrent app with it and you'll see. For me, it's not even the STM that's so compelling about clojure - i

Re: Clojure analysis

2009-12-12 Thread Stuart Halloway
The linked article is poorly researched and incorrect starting at the very first sentence. I hope that the author will have time to do a more in-depth exploration of Clojure and make some modifications. If you are looking for accurate introductory information on Clojure, I would recommend:

Re: boolean-array in clojure

2009-12-12 Thread Sean Devlin
The boolean-array function is new in 1.1 Sean On Dec 12, 12:37 pm, Michael Wood wrote: > 2009/12/12 Amol Dharmadhikari : > > > > > > > Hi All, > > > Apologies for a newbie question: > > > I am trying to invoke some java libraries from clojure and some of the > > methods take boolean arrays as th

Re: boolean-array in clojure

2009-12-12 Thread Michael Wood
2009/12/12 Amol Dharmadhikari : > Hi All, > > Apologies for a newbie question: > > I am trying to invoke some java libraries from clojure and some of the > methods take boolean arrays as their parameters. > > The documentation > (http://richhickey.github.com/clojure/clojure.core-api.html#clojure.co

Re: Fine-grained locals clearing

2009-12-12 Thread Rich Hickey
On Sat, Dec 12, 2009 at 10:57 AM, Daniel Werner wrote: > On Dec 10, 3:10 pm, Rich Hickey wrote: >> I'm happy to announce I have implemented this fine-grained locals >> clearing in the compiler, in the 'new' branch. > > Is there a chance for this feature to find its way into master before > Clojur

Re: simple journal-based persistenсe for Clojure

2009-12-12 Thread Sergey Didenko
I'm going to postpone the discussed above removing of "locking" - the write bottleneck. Because: 1. In-memory writes are very quick 2. there is no demand right now 3. it makes the backup workflow more complex The next thing I'm going to add is snapshotting. However it is not a priority for me ri

Re: Mapping OOPS concepts to Clojure? Doable or Wrong thinking?

2009-12-12 Thread Joost
On 12 dec, 14:13, ajay gopalakrishnan wrote: > Hi, > > I come from a OOPS (Java) world and I am used to Singletons, Inheritance, > Statics, Interfaces etc. > I am reading the Programming Clojure book and I understand multi-methods and > when it is used. > But I am still not able to see how to achi

Re: AbstractMethodError question

2009-12-12 Thread Keith Irwin
I figured out the problem and thought I'd note it here. When you "proxy" and object, the proxy code calls the constructor of the object BEFORE it registers its own methods as overrides for the object's methods. If the constructor calls methods, they'll be its own implementations rather those of t

Re: Clojure analysis

2009-12-12 Thread Sean Devlin
I'm guessing you're the author. A very interesting critique. Well written, and you've got guts posting it to this list. There are a few very important factors you need to consider to have a complete critique, though. First, is the STM. This is THE killer feature of the language. Ironically, it

Re: teaching duck-streams to support byte streams

2009-12-12 Thread B Smith-Mannschott
On Sat, Dec 12, 2009 at 16:38, Sean Devlin wrote: > Hmmm...  this could be interesting.  I"ll have to play with it. > > Do you have a CA on file with Rich?  It'll be required to include the > patch.  You'll find information here. > > http://clojure.org/contributing > > Sean Thanks for your intere

Re: Mapping OOPS concepts to Clojure? Doable or Wrong thinking?

2009-12-12 Thread David Nolen
On Sat, Dec 12, 2009 at 11:03 AM, Sean Devlin wrote: > Ummm some of these thing DON'T map to Clojure. > > I'd suggest you check out Rich's videos here: > > http://blip.tv/file/982823 > > Anyway, as to how you would solve some of these problems in Clojure... > > Static methods you get for free,

Re: Mapping OOPS concepts to Clojure? Doable or Wrong thinking?

2009-12-12 Thread Sean Devlin
Ummm some of these thing DON'T map to Clojure. I'd suggest you check out Rich's videos here: http://blip.tv/file/982823 Anyway, as to how you would solve some of these problems in Clojure... Static methods you get for free, because everything is a function in Clojure. Singletons aren't rea

Re: Fine-grained locals clearing

2009-12-12 Thread Daniel Werner
On Dec 10, 3:10 pm, Rich Hickey wrote: > I'm happy to announce I have implemented this fine-grained locals > clearing in the compiler, in the 'new' branch. Is there a chance for this feature to find its way into master before Clojure 1.1 is released? -- You received this message because you are

Re: teaching duck-streams to support byte streams

2009-12-12 Thread Sean Devlin
Hmmm... this could be interesting. I"ll have to play with it. Do you have a CA on file with Rich? It'll be required to include the patch. You'll find information here. http://clojure.org/contributing Sean On Dec 10, 4:44 pm, B Smith-Mannschott wrote: > I've posted an attempt to teach duck-

ClojureX now supporting Windows (Cygwin) too

2009-12-12 Thread Michael Kohl
Hi all, I can't remember if I ever mentioned ClojureX (see signature for link) on this list, but it's a sort of "installer" for Clojure (and clojure-contrib, clojure-mode, swank-clojure, slime, jline and the TextMate bundle). I originally created it to install everything on my Mac (and on Linux),

Re: On adding InputStream/OutputStream support in clojure.contrib.duck-streams

2009-12-12 Thread B Smith-Mannschott
Just a by-the-way: I'm (now) aware of http://clojure.org/contributing and http://clojure.org/patches . I'll put my CA in the mail on Monday and pick this up again in the new year. // Ben On Wed, Dec 9, 2009 at 23:33, B Smith-Mannschott wrote: > Duck-streams does good job supporting character ba

Re: Datatypes and protocols - update

2009-12-12 Thread Rich Hickey
On Dec 11, 8:48 am, Chris Kent wrote: > Rich Hickey gmail.com> writes: > > > > > An updated version of the code for datatypes[1] and protocols[2] is > > now available in the 'new' branch[3]. > > I've converted some code that used gen-class to use deftype and defprotocol > and > the results are

Mapping OOPS concepts to Clojure? Doable or Wrong thinking?

2009-12-12 Thread ajay gopalakrishnan
Hi, I come from a OOPS (Java) world and I am used to Singletons, Inheritance, Statics, Interfaces etc. I am reading the Programming Clojure book and I understand multi-methods and when it is used. But I am still not able to see how to achieve the effects of Singletons, Inheritance, Statics, Interf

Re: Idiomatic way to return the key of a map, which matches a vector containing a search value.

2009-12-12 Thread lambdatronic
This shaves 7 characters off Sean's solution and short circuits just as fast: (some #(and (some #{"rabble"} (val %)) (key %)) players) Happy hacking! On Dec 10, 3:29 pm, Sean Devlin wrote: > Oops!  Slight mistake > > (ffirst (filter (comp (partial some #{"rabble"}) val) players)) > > On Dec 10,

Re: more dumb noob pain ("2dplot.clj")

2009-12-12 Thread rebcabin
Well, the 3d test applications from https://j3d-webstart.dev.java.net/test/ work correctly and every other Java test I've tried works, but I am not sure how to find out what's on the CLASSPATH. Is CLASSPATH an environment variable? If so, I don't have any binding for it, but then the immediate ques

Re: more dumb noob pain ("2dplot.clj")

2009-12-12 Thread devender
You need this jar file j3d-core-1.3.1.jar in your classpath If you are using leiningen then add this to your project.clj [java3d/ j3d-core "1.3.1"] if not then you can download that jar from here http://repo2.maven.org/maven2/java3d/j3d-core/1.3.1/ -Devender On Dec 11, 9:15 am, rebcabin wrote:

boolean-array in clojure

2009-12-12 Thread Amol Dharmadhikari
Hi All, Apologies for a newbie question: I am trying to invoke some java libraries from clojure and some of the methods take boolean arrays as their parameters. The documentation ( http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/boolean-array) does say that there is a boo

zipper for JSON data?

2009-12-12 Thread Paul_B_Hansen
Hi fellow Clojurians - I am stumped with coming up with a definition of a clojure zipper for json data. Not only would this be useful for json data, but for any generic hash-map/vector data structure. I don't have a lot of experience with zippers, but it would be fantastic to provide this type o

Clojure analysis

2009-12-12 Thread kusi
http://kusimari.blogspot.com/2009/12/analysing-clojure-programming-language.html -- 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 Note that posts from new members are moderated - please be p

Re: update-in and get-in why no default?

2009-12-12 Thread Rich Hickey
On Thu, Dec 10, 2009 at 7:20 AM, Timothy Pratley wrote: > Hi, > > update-in is an especially useful function but I find the update > function inevitably requires a check for nil. If I could supply a not- > found value then my code would get better golf scores. > > When I reach for update-in, I usu

Re: Datatypes and protocols - update

2009-12-12 Thread Konrad Hinsen
On 12 Dec 2009, at 01:14, Jason Wolfe wrote: > A very simple example is: I have a protocol "A", and sub-protocols > "A1" and "A2". Every A is either an A1 or A2, but not both (and this > split is closed, as far as I'm concerned). Sometimes I want to deal > with instances of A1 and A2 together, a

Re: how 'bout a debug-repl?

2009-12-12 Thread Konrad Hinsen
On 11 Dec 2009, at 23:26, Dan Larkin wrote: > On Dec 11, 2009, at 3:04 PM, Sean Devlin wrote: > >> Wouldn't ::quit do the same thing? > > It wouldn't, because the repl is evaluating in the context of > wherever you put the (debug-repl) call, so its namespace won't be > "dr". > > What about ins

Re: Datatypes and protocols - update

2009-12-12 Thread ataggart
On Dec 11, 11:56 pm, ataggart wrote: > On Dec 11, 11:44 pm, ataggart wrote: > > > > > > > On Dec 11, 4:14 pm, Jason Wolfe wrote: > > > > I've been trying out the new branch, and on the whole I like it a lot. > > >  I know it'll take some time to learn how do things properly the "new" > > > way