Aw: Re: help--reading keyboard input from Clojure is surprisingly difficult
Hi, indeed. On the other hand the atom has the advantage of making the loop easily interuptible from the outside. YMMV. :) Sincerely Meikel -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Aw: Re: Where to place Arguments
Hi, another one which caught me recently is nthnext. I expected (nthnext 5 some-seq), but Clojure complained about 5 being not a sequence. :] Sincerely Meikel -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: No any? function
Thanks for the responses. I agree that some takes care of things quite nicely. The asymmetrical naming convention in this case was what caught my eye. Just wanted to make sure if it was a deliberate design decision or an oversight. Sounds like it was done by design. On Jun 14, 9:29 am, Ambrose Bonnaire-Sergeant abonnaireserge...@gmail.com wrote: Hi David, any? would be redundant and less general than some, if I am not mistaken. Compare the docstrings for the hypothetical any?. (some p coll) Returns the *first logical true value* of (pred x) for any x in coll, else *nil*. (any? p coll) Returns *true* if (pred x) is logical true for any x in coll, else *false*. Since *nil* and *false* are both falsy, some can be used as a predicate that is truthy when it finds truthy result, otherwise falsy. This is exactly the behavior expected from an any? function. some is a poster boy for Clojure's well thought out truthyness system, this is a great example of the types of general functions it allows. Perhaps a pointer to some should be added in the docstring of not-any?. Although a quick look at the source makes it crystal clear. I wasn't aware of not-any?s existence, maybe noting it in somes docstring could be beneficial also. Thanks, Ambrose On Tue, Jun 14, 2011 at 3:08 PM, de1976 davidescobar1...@gmail.com wrote: Hello everyone. In looking through the API documentation, I've noticed that there is a not-any? function available, but there is no corresponding inverse any? function that I can find. There are, however, every? and not-every? functions available. The closest I could find was some, but wouldn't it make sense to have an any? function for more obvious consistency? Thanks. -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Emacs setup - quick navigation to files and definitions
In my experience ECB and Speedbar (both come with CEDET) is the only option. I think that speedbar may be available without cedet, but it seems less functional. ECB can keep the speedbar window fixed regardless of closing/opening other emacs windows. It's not a nice as IDEs I'd say, but certainly does work, showing a tree of directories, clojure files and clojure functions/defs. CEDET does look quite the overwhelming install, but it wasn't that bad. I found several of the default ecb/speedbar behaviours unpleasant and fixed them with the right customisation. Right now, having to double, instead of single click, on ecb windows is the most annoying. Some settings I have in my emacs config, some of which I won't remember why I set them: (speedbar-add-supported-extension .clj) (setq ecb-use-speedbar-instead-native-tree-buffer 'dir) (setq speedbar-show-unknown-files t) (setq speedbar-tag-regroup-maximum-length 100) (setq ecb-primary-secondary-mouse-buttons 'mouse-1--C-mouse-1) (setq ecb-speedbar-buffer-sync nil) (setq speedbar-tag-hierarchy-method '(speedbar-sort-tag-hierarchy)) (setq ecb-auto-expand-directory-tree nil) My emacs setup files might help https://bitbucket.org/enerqi/emacs-setup/src such as src/elisp/rc/emacs-rc-cedet.el. However, I've saved a copy of cedet with my elisp files. With recent versions of emacs (23+ or 24+) cedet comes with emacs and I had to delete the cedet shipped with emacs to avoid changing my emacs config. On Jun 13, 2:50 am, yair yair@gmail.com wrote: Hi, With swank and slime all set-up along with CDT, further improved by slime autocomplete, my emacs setup is getting pretty close to being a full featured, highly clojure focused IDE. One thing I am struggling with while working on a larger than usual project (i.e. 7 source files some of which have 200-300 lines) is quickly navigating between source files and the definitions within them. I took a look at CEDET but it seemed a bit overwhelming, and I wasn't sure the effort would be worth it as I couldn't tell if clojure would then be supported within it. So, which plugins do you use in emacs for navigating between clojure source files and definitions? Thanks -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
ClassNotFoundException with dynamically compiled classes
Hi all, in my clojure project, I'm working with an external java graph library. Graphs represented by that library conform to a user-specified data model, that is, the graph itself and all its vertices and edges are objects of some java class, which is dynamically generated and compiled when loading such a graph. Now the problem is that I don't have access to these classes but only to the instances. Here's a REPL session: --8---cut here---start-8--- de.uni-koblenz.funtg.test.funtl (def mygraph (load-graph /home/horn/uni/repos/funql/test/greqltestgraph.tg)) #'de.uni-koblenz.funtg.test.funtl/mygraph de.uni-koblenz.funtg.test.funtl mygraph #RouteMapImpl de.uni_koblenz.jgralabtest.schemas.greqltestschema.impl.std.RouteMapImpl@3e2d015f de.uni-koblenz.funtg.test.funtl (class mygraph) de.uni_koblenz.jgralabtest.schemas.greqltestschema.impl.std.RouteMapImpl de.uni-koblenz.funtg.test.funtl de.uni_koblenz.jgralabtest.schemas.greqltestschema.impl.std.RouteMapImpl java.lang.ClassNotFoundException: de.uni_koblenz.jgralabtest.schemas.greqltestschema.impl.std.RouteMapImpl [Thrown class java.lang.RuntimeException] ; Evaluation aborted. de.uni-koblenz.funtg.test.funtl (Class/forName de.uni_koblenz.jgralabtest.schemas.greqltestschema.impl.std.RouteMapImpl) de.uni_koblenz.jgralabtest.schemas.greqltestschema.impl.std.RouteMapImpl [Thrown class java.lang.ClassNotFoundException] ; Evaluation aborted. --8---cut here---end---8--- Why can't I access that class by its qualified name although it's there? Bye, Tassilo -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ClassNotFoundException with dynamically compiled classes
On Wed, Jun 15, 2011 at 6:27 AM, Tassilo Horn tass...@member.fsf.org wrote: Hi all, in my clojure project, I'm working with an external java graph library. Graphs represented by that library conform to a user-specified data model, that is, the graph itself and all its vertices and edges are objects of some java class, which is dynamically generated and compiled when loading such a graph. Now the problem is that I don't have access to these classes but only to the instances. Here's a REPL session: --8---cut here---start-8--- de.uni-koblenz.funtg.test.funtl (def mygraph (load-graph /home/horn/uni/repos/funql/test/greqltestgraph.tg)) #'de.uni-koblenz.funtg.test.funtl/mygraph de.uni-koblenz.funtg.test.funtl mygraph #RouteMapImpl de.uni_koblenz.jgralabtest.schemas.greqltestschema.impl.std.RouteMapImpl@3e2d015f de.uni-koblenz.funtg.test.funtl (class mygraph) de.uni_koblenz.jgralabtest.schemas.greqltestschema.impl.std.RouteMapImpl de.uni-koblenz.funtg.test.funtl de.uni_koblenz.jgralabtest.schemas.greqltestschema.impl.std.RouteMapImpl java.lang.ClassNotFoundException: de.uni_koblenz.jgralabtest.schemas.greqltestschema.impl.std.RouteMapImpl [Thrown class java.lang.RuntimeException] ; Evaluation aborted. de.uni-koblenz.funtg.test.funtl (Class/forName de.uni_koblenz.jgralabtest.schemas.greqltestschema.impl.std.RouteMapImpl) de.uni_koblenz.jgralabtest.schemas.greqltestschema.impl.std.RouteMapImpl [Thrown class java.lang.ClassNotFoundException] ; Evaluation aborted. --8---cut here---end---8--- Why can't I access that class by its qualified name although it's there? Perhaps it's not visible to the normal classloader, but it is to some other classloader used by this graph library. Can you not just use (class some-instance) to get ahold of the class object, given you can get ahold of instances as you said, and then use reflection on the class object? -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: SQL queries on csv-files
Clojure-CSV might be useful: https://github.com/davidsantiago/clojure-csv Regards, Shantanu On Jun 14, 6:06 pm, Mark markaddle...@gmail.com wrote: Although it may be overkill for you, take a look at Teiid: http://teiid.org On Jun 14, 5:30 am, finbeu info_pe...@t-online.de wrote: Hello, I have a couple of csv files that are actually dumped data from SQL tables. These tables have proper relationships with key, foreign keys so they can be easily joined using SQL. I would like to load them into memory and then appy SQL queries on that data. So in fact, I'm looking for a clojure in-memory SQL database that allows me to slurp the csv files, treat them as tables and run sql queries on them. I already looked into clojure.set and this would work. But is there another library to look into? Maybe a clojure SQL set of macros that allow to issue real SQL queries? I don't want to install sqlite and jdbc-drivers and stuff like this. Just load csv file into memory and run SQL queries within clojure. Thx. Finn -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ClassNotFoundException with dynamically compiled classes
Ken Wesson kwess...@gmail.com writes: Hi Ken, Why can't I access that class by its qualified name although it's there? Perhaps it's not visible to the normal classloader, but it is to some other classloader used by this graph library. Yes, indeed that library uses its own classloader. Can you not just use (class some-instance) to get ahold of the class object, given you can get ahold of instances as you said, and then use reflection on the class object? Yes, that's what I'm currently doing. Bye, Tassilo -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
(. rnd nextInt) vs (.nextInt rnd)
Hi all. I'm struggling to see the point of this (from Pragmatic's Programming Clojure): Java = rnd.nextInt() Clojure = (. rnd nextInt) sugared = (.nextInt rnd) What's the point of the sugared version? It's not any less to type. It's also incomprehensible to me how it came about. In the middle one it's simple, class and method, but the in sugared one it's just plain simply bizarre looking. What was the intent? Thanks. -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: (. rnd nextInt) vs (.nextInt rnd)
The difference is that the sugared version works just like a normal Clojure function. It also eases a lot of things with macros like (doto). 2011/6/15 James Keats james.w.ke...@gmail.com: Hi all. I'm struggling to see the point of this (from Pragmatic's Programming Clojure): Java = rnd.nextInt() Clojure = (. rnd nextInt) sugared = (.nextInt rnd) What's the point of the sugared version? It's not any less to type. It's also incomprehensible to me how it came about. In the middle one it's simple, class and method, but the in sugared one it's just plain simply bizarre looking. What was the intent? Thanks. -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
loop/recur and tail postion
Hi, I'm going through some Scheme code to learn Clojure. I defined a function rember as (defn rember [atom l] (loop [a atom lat l] (cond (empty? lat) `() (= (first lat) a) (rest lat) :else (cons (first lat) (recur a (rest lat)) To which the REPL responds: Can only recur from tail position [Thrown class java.lang.UnsupportedOperationException] Is the call to recur not in tail position here? Thank you, Kevin -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: loop/recur and tail postion
Is the call to recur not in tail position here? No, because of (cons (first lat) (recur a (rest lat))). You cons (first lat) after you call (recur ...). That is why (recur ...) is not in tail position. -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Aw: loop/recur and tail postion
Hi, no, it's not. The cons is in the tail position. Here a working version. (defn rember [a l] (loop [ret [] lat (seq l)] (cond (not lat) ret (= (first lat) a) (recur ret (next lat)) :else (recur (conj ret (first lat)) (next lat) Note, how recur is now in the tail position and how an accumulator is used to collect the results. Hope that helps. Sincerely Meikel BTW: you can also use direct recursion in your original function instead of recur by simply calling the function (rember) itself again. -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: (. rnd nextInt) vs (.nextInt rnd)
On Wed, Jun 15, 2011 at 9:52 AM, James Keats james.w.ke...@gmail.com wrote: Hi all. I'm struggling to see the point of this (from Pragmatic's Programming Clojure): Java = rnd.nextInt() Clojure = (. rnd nextInt) sugared = (.nextInt rnd) What's the point of the sugared version? It's not any less to type. Actually there's one fewer character -- a space. It's also incomprehensible to me how it came about. In the middle one it's simple, class and method, but the in sugared one it's just plain simply bizarre looking. What was the intent? It's closer to typical function-call form: (.doSomething someNoun) resembles (do-something some-noun) more than does (. someNoun doSomething). -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: loop/recur and tail postion
On Wed, Jun 15, 2011 at 10:08 AM, Kevin Sookocheff kevin.sookoch...@gmail.com wrote: Hi, I'm going through some Scheme code to learn Clojure. I defined a function rember as (defn rember [atom l] (loop [a atom lat l] (cond (empty? lat) `() (= (first lat) a) (rest lat) :else (cons (first lat) (recur a (rest lat)) To which the REPL responds: Can only recur from tail position [Thrown class java.lang.UnsupportedOperationException] Is the call to recur not in tail position here? Nope. The return from recur has to be, directly, the return from the enclosing loop form for it to be a tail position. Here you're consing something onto it in between. Generally that means you need to add a result accumulator to the loop, something like: (defn rember [atom l] (loop [a atom lat l res []] (cond (empty? lat) res (= (first lat) a) (rest lat) :else (recur a (rest lat) (conj res (first lat)) though I can think of further improvements, like hoisting a out of the loop (it doesn't change) and using seq/next like so: (defn rember [atom l] (loop [lat (seq l) res []] (if lat (let [f (first lat)] (if (= f atom) (rest lat) (recur (next lat) (conj res f res))) -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: loop/recur and tail postion
Thanks everyone. Makes perfect sense. -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Using clojure-csv
Thanks. It wasn't on the CLASSPATH. On Jun 14, 3:41 pm, David Santiago david.santi...@gmail.com wrote: I think the basic problem is Clojure is not able to find the clojure-csv jar file. I'm afraid I'm not quite clear enough on your specific setup to know exactly what has gone wrong. I'm not sure where you have this jar, or what exactly the shell scripting stuff is in that command you're using to launch it... Can you double-check to make sure that clojure-csv is on the classpath? - David On Tue, Jun 14, 2011 at 2:26 PM, octopusgrabbus octopusgrab...@gmail.com wrote: I am trying to use clojure-csv, but am having a lot of cockpit error. Here is my current configuration: Running Clojure 1.2.1. Modified a shell script installed by Synaptic to include clojure- contrib.jar: exec java -cp /usr/share/java/clojure.jar:/usr/share/java/clojure- contrib.jar$extra_classpath clojure.main $@ clojure.jar and clojure-contrib.jar are links lrwxrwxrwx 1 root root 25 2011-06-09 18:38 /usr/share/java/ clojure-contrib.jar - clojure-contrib-1.2.0.jar lrwxrwxrwx 1 root root 17 2011-06-09 18:23 /usr/share/java/ clojure.jar - clojure-1.2.1.jar c This fails: (ns test-csv (:import (java.io BufferedReader))) (use clojure-csv.core) with java.lang.ClassNotFoundException: clojure-csv.core (NO_SOURCE_FILE:6) What am I doing wrong? Thanks. cmn -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: (. rnd nextInt) vs (.nextInt rnd)
What's the point of the sugared version? It's not any less to type. Actually there's one fewer character -- a space. Okay, I'll give you that. It's also incomprehensible to me how it came about. In the middle one it's simple, class and method, but the in sugared one it's just plain simply bizarre looking. What was the intent? It's closer to typical function-call form: (.doSomething someNoun) resembles (do-something some-noun) more than does (. someNoun doSomething). Right. That makes sense. I see the consistency here now. :-) Thanks. Soldiering on now; I'll probably be back. :-D -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Having trouble figuring out dependencies
I have clojure-1.2.1.jar. It is in my classpath. I am trying to build a very simple hello world project with cake, and have two dependencies: org.clojure:clojure:jar:1.1.0-master-SNAPSHOT org.clojure:clojure-contrib:jar:1.0-SNAPSHOT Is this a cake dependency? I can't figure out why cake needs these other jar files. Also, where can I find the jar files or sources to build them? Thanks. cmn -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Using clojure-csv
The indentation made it confusing, but the (use ...) was outside of the (ns ...). I had the same initial reaction, especially since i prefer (:use) over (use) except when typing code into the REPL. -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Having trouble figuring out dependencies
I've found the missing Clojure releases on github, will unpack and put in my CLASSPATH. On Jun 15, 10:57 am, octopusgrabbus octopusgrab...@gmail.com wrote: I have clojure-1.2.1.jar. It is in my classpath. I am trying to build a very simple hello world project with cake, and have two dependencies: org.clojure:clojure:jar:1.1.0-master-SNAPSHOT org.clojure:clojure-contrib:jar:1.0-SNAPSHOT Is this a cake dependency? I can't figure out why cake needs these other jar files. Also, where can I find the jar files or sources to build them? Thanks. cmn -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Having trouble figuring out dependencies
Hi cmn, Cake manages your dependencies via maven, you shouldn't need to worry about classpaths or local jars. Do you have a project.clj file in your project root? Can you post it here? Thanks, Ambrose On Wed, Jun 15, 2011 at 10:57 PM, octopusgrabbus octopusgrab...@gmail.comwrote: I have clojure-1.2.1.jar. It is in my classpath. I am trying to build a very simple hello world project with cake, and have two dependencies: org.clojure:clojure:jar:1.1.0-master-SNAPSHOT org.clojure:clojure-contrib:jar:1.0-SNAPSHOT Is this a cake dependency? I can't figure out why cake needs these other jar files. Also, where can I find the jar files or sources to build them? Thanks. cmn -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Where to place Arguments
On Tue, Jun 14, 2011 at 4:28 PM, Nick Zbinden nick...@gmail.com wrote: I'm writing this here because of two reasons: 1. The universial threading operator keeps showing up. Im not saying its a always a bad thing but I think we should trie to avoid it in most cases and the standard on the parameter order would help. I really don't understand why you say this. I'm not saying you're wrong, just that you're stating something as fact that I don't think is clear on its face. 2. The Question of where to put this stuff pops up again and again (IRC, Stackoverflow). We, as a Communety, should have a standard answer to this. For one previous discussion of this same topic: https://groups.google.com/d/msg/clojure/iyyNyWs53dc/13dWIhwTKzoJ -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Having trouble figuring out dependencies
Here is the project.clj (defproject helloworld 0.1 :dependencies [[org.clojure/clojure 1.1.0-master-SNAPSHOT] [org.clojure/clojure-contrib 1.0-SNAPSHOT]] :main helloworld) but I've had an aha moment. Nothing prevents me from changing the dependencies, but to what, the latest, and why not locally? I'm just not sure of the local directory syntax in this instance. On Jun 15, 11:06 am, Ambrose Bonnaire-Sergeant abonnaireserge...@gmail.com wrote: Hi cmn, Cake manages your dependencies via maven, you shouldn't need to worry about classpaths or local jars. Do you have a project.clj file in your project root? Can you post it here? Thanks, Ambrose On Wed, Jun 15, 2011 at 10:57 PM, octopusgrabbus octopusgrab...@gmail.comwrote: I have clojure-1.2.1.jar. It is in my classpath. I am trying to build a very simple hello world project with cake, and have two dependencies: org.clojure:clojure:jar:1.1.0-master-SNAPSHOT org.clojure:clojure-contrib:jar:1.0-SNAPSHOT Is this a cake dependency? I can't figure out why cake needs these other jar files. Also, where can I find the jar files or sources to build them? Thanks. cmn -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
(function [args] more args)
Hi again. This is another syntax that I'm struggling with: (function [args] more args) Or for example: (subvec [1 2 3 4 5] 1 3) Please note I'm not referring specifically to the subvec function, but simply using it as an example, as I've seen this syntax with many other functions, but it escapes my mind now to provide more examples. I don't like it, and here's what I don't like about it. It leaves me with a bad taste that where the arguments are generally meant to be passed to the function in a vector of arguments, some are sometimes passed outside the vector. It feels inconsistent and ad hoc. What am I missing out on? are the arguments contained within a vector only when defining functions? such as: (defn name [args] body) Thanks. -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Having trouble figuring out dependencies
On Wed, Jun 15, 2011 at 11:26 PM, octopusgrabbus octopusgrab...@gmail.comwrote: Here is the project.clj (defproject helloworld 0.1 :dependencies [[org.clojure/clojure 1.1.0-master-SNAPSHOT] [org.clojure/clojure-contrib 1.0-SNAPSHOT]] :main helloworld) This should work (untested): (defproject helloworld 0.1 :dependencies [[org.clojure/clojure 1.2.1] [org.clojure/clojure-contrib 1.2]] :main helloworld) Then run cake deps to resolve the deps. but I've had an aha moment. Nothing prevents me from changing the dependencies, but to what, the latest, and why not locally? I'm just not sure of the local directory syntax in this instance. Cake resolves your dependencies the maven repositories and then caches it internally. This is usually simpler than manually downloading and managing your dependencies, possibly even for a hello world. On Jun 15, 11:06 am, Ambrose Bonnaire-Sergeant abonnaireserge...@gmail.com wrote: Hi cmn, Cake manages your dependencies via maven, you shouldn't need to worry about classpaths or local jars. Do you have a project.clj file in your project root? Can you post it here? Thanks, Ambrose On Wed, Jun 15, 2011 at 10:57 PM, octopusgrabbus octopusgrab...@gmail.comwrote: I have clojure-1.2.1.jar. It is in my classpath. I am trying to build a very simple hello world project with cake, and have two dependencies: org.clojure:clojure:jar:1.1.0-master-SNAPSHOT org.clojure:clojure-contrib:jar:1.0-SNAPSHOT Is this a cake dependency? I can't figure out why cake needs these other jar files. Also, where can I find the jar files or sources to build them? Thanks. cmn -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: (function [args] more args)
So let me see if I can help out with this. In classic lisp, when you define a function it would take this syntax: (defn name (arg1 arg2) body) The only problem with this approach is that sometimes it is hard to figure out what is part of the body and what is the argument lists. Clojure solves this by just mandating that argument lists are vectors...this is almost purely syntactic sugar. The idea is that using [] makes it stand out from the other forms that use (). Now in the example you gave for subvec...we would write this in classic lisp like this: (subvec (vector 1 2 3 4 5) 1 3) So we're creating a vector then running subvec on it. However, this is a bit more verbose that what people from say Ruby and Python are used to. It's just simpler to allow people to write [1 2 3 4 5] instead of (vector 1 2 3 4 5) So in the case of using [] as a function argument, it's considered a vector constructor. In the case of being used in a defn, it's considered syntactic sugar. Yes it's a tad confusing, but it makes sense once you work it out. I hope this helps. Timothy -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Having trouble figuring out dependencies
I happened to have clojure-contrib 1.2.0 changed that dependency, and it built. Many thanks. On Jun 15, 11:43 am, Ambrose Bonnaire-Sergeant abonnaireserge...@gmail.com wrote: On Wed, Jun 15, 2011 at 11:26 PM, octopusgrabbus octopusgrab...@gmail.comwrote: Here is the project.clj (defproject helloworld 0.1 :dependencies [[org.clojure/clojure 1.1.0-master-SNAPSHOT] [org.clojure/clojure-contrib 1.0-SNAPSHOT]] :main helloworld) This should work (untested): (defproject helloworld 0.1 :dependencies [[org.clojure/clojure 1.2.1] [org.clojure/clojure-contrib 1.2]] :main helloworld) Then run cake deps to resolve the deps. but I've had an aha moment. Nothing prevents me from changing the dependencies, but to what, the latest, and why not locally? I'm just not sure of the local directory syntax in this instance. Cake resolves your dependencies the maven repositories and then caches it internally. This is usually simpler than manually downloading and managing your dependencies, possibly even for a hello world. On Jun 15, 11:06 am, Ambrose Bonnaire-Sergeant abonnaireserge...@gmail.com wrote: Hi cmn, Cake manages your dependencies via maven, you shouldn't need to worry about classpaths or local jars. Do you have a project.clj file in your project root? Can you post it here? Thanks, Ambrose On Wed, Jun 15, 2011 at 10:57 PM, octopusgrabbus octopusgrab...@gmail.comwrote: I have clojure-1.2.1.jar. It is in my classpath. I am trying to build a very simple hello world project with cake, and have two dependencies: org.clojure:clojure:jar:1.1.0-master-SNAPSHOT org.clojure:clojure-contrib:jar:1.0-SNAPSHOT Is this a cake dependency? I can't figure out why cake needs these other jar files. Also, where can I find the jar files or sources to build them? Thanks. cmn -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Aw: (function [args] more args)
Hi, in your example the vector *is* the argument. You could just as well write (let [x [1 2 3 4 5]] (subvec x 1 3)). On function definition the arguments are given in a vector, yes. I'm not sure I understand your concern completely. Sincerely Meikel -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Having trouble figuring out dependencies
Just to be clear, you do not need to download and build all of your dependencies, and you do not need to worry about whether they are on your classpath. I don't know cake, but I assume it is similar to leiningen in that is manages all of your dependencies for you, via maven, and again, if like leiningen, it will manage getting everything in your project's classpath for you. So, you just specify your dependencies in your project.clj, and run deps and via maven it will search some public repositories on the internet to find those dependencies, and install them automatically in your local maven repository. On Wed, Jun 15, 2011 at 11:51 AM, octopusgrabbus octopusgrab...@gmail.comwrote: I happened to have clojure-contrib 1.2.0 changed that dependency, and it built. Many thanks. On Jun 15, 11:43 am, Ambrose Bonnaire-Sergeant abonnaireserge...@gmail.com wrote: On Wed, Jun 15, 2011 at 11:26 PM, octopusgrabbus octopusgrab...@gmail.comwrote: Here is the project.clj (defproject helloworld 0.1 :dependencies [[org.clojure/clojure 1.1.0-master-SNAPSHOT] [org.clojure/clojure-contrib 1.0-SNAPSHOT]] :main helloworld) This should work (untested): (defproject helloworld 0.1 :dependencies [[org.clojure/clojure 1.2.1] [org.clojure/clojure-contrib 1.2]] :main helloworld) Then run cake deps to resolve the deps. but I've had an aha moment. Nothing prevents me from changing the dependencies, but to what, the latest, and why not locally? I'm just not sure of the local directory syntax in this instance. Cake resolves your dependencies the maven repositories and then caches it internally. This is usually simpler than manually downloading and managing your dependencies, possibly even for a hello world. On Jun 15, 11:06 am, Ambrose Bonnaire-Sergeant abonnaireserge...@gmail.com wrote: Hi cmn, Cake manages your dependencies via maven, you shouldn't need to worry about classpaths or local jars. Do you have a project.clj file in your project root? Can you post it here? Thanks, Ambrose On Wed, Jun 15, 2011 at 10:57 PM, octopusgrabbus octopusgrab...@gmail.comwrote: I have clojure-1.2.1.jar. It is in my classpath. I am trying to build a very simple hello world project with cake, and have two dependencies: org.clojure:clojure:jar:1.1.0-master-SNAPSHOT org.clojure:clojure-contrib:jar:1.0-SNAPSHOT Is this a cake dependency? I can't figure out why cake needs these other jar files. Also, where can I find the jar files or sources to build them? Thanks. cmn -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: (function [args] more args)
The enclosed vector (or list, map, set, etc) is considered as arg1 because it is one entity. Take a look at the source for subvec: = (clojure.repl/source subvec) (defn subvec Returns a persistent vector of the items in vector from start (inclusive) to end (exclusive). If end is not supplied, defaults to (count vector). This operation is O(1) and very fast, as the resulting vector shares structure with the original and no trimming is done. {:added 1.0} ([v start] (subvec v start (count v))) ([v start end] (. clojure.lang.RT (subvec v start end nil Notice that it takes 2 or 3 arguments. Your example, (subvec [1 2 3 4 5] 1 3), correspond with the 3 args method. You can verify this by: = (count '([1 2 3 4 5] 1 3)) 3 So the correct definition for something like subvec is (function [vector_arg1 arg2 arg3] body). For more info on how to play with the function arguments, look into 'clojure destructuring'. On Jun 15, 11:31 am, James Keats james.w.ke...@gmail.com wrote: Hi again. This is another syntax that I'm struggling with: (function [args] more args) Or for example: (subvec [1 2 3 4 5] 1 3) Please note I'm not referring specifically to the subvec function, but simply using it as an example, as I've seen this syntax with many other functions, but it escapes my mind now to provide more examples. I don't like it, and here's what I don't like about it. It leaves me with a bad taste that where the arguments are generally meant to be passed to the function in a vector of arguments, some are sometimes passed outside the vector. It feels inconsistent and ad hoc. What am I missing out on? are the arguments contained within a vector only when defining functions? such as: (defn name [args] body) Thanks. -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: (function [args] more args)
Hi, I admit that subvec is not a good example as it does indeed take a vector as a first argument, perhaps i'll find better example or perhaps I might've just been confused. I learnt lisp and scheme many years ago, abandoned them for languages with better libraries, and I'm perhaps thrown off by the [] of clojure instead of the () throughout of lisp. Thanks. On Jun 15, 4:54 pm, Meikel Brandmeyer m...@kotka.de wrote: Hi, in your example the vector *is* the argument. You could just as well write (let [x [1 2 3 4 5]] (subvec x 1 3)). On function definition the arguments are given in a vector, yes. I'm not sure I understand your concern completely. Sincerely Meikel -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure group in DFW area
Everyone, sorry for late notice but are meeting tonight is cancelled due to some scheduling conflicts. We have another meeting set for Tuesday June 28th 630PM - 900PM @ Rubedo, inc. 14580 Beltwood Pkwy E Suite 103 Farmers Branch, TX 75244 See you then ! On Jun 3, 9:46 am, ch...@rubedoinc.com ch...@rubedoinc.com wrote: Meeting is growing strong! We will be looking at some group projects to take on that we can use to stretch our clojure skills. Make the next meeting to be a part of it! Wednesday June 15th 630PM - 900PM @ Rubedo, inc. 14580 Beltwood Pkwy E Suite 103 Farmers Branch, TX 75244 (wifi available) On May 20, 11:08 am, ch...@rubedoinc.com ch...@rubedoinc.com wrote: Thanks everyone for attending. Our next meeting is scheduled for Our next meeting is scheduled for May 31th 630PM - 900PM @ Rubedo, inc. 14580 Beltwood Pkwy E Suite 103 Farmers Branch, TX 75244 (wifi available) there will be pizza and sodas, so bring yourclojurequestions and your appetite. Reply in this thread if you will be attending so that I can get a head count for pizza. On May 16, 12:41 pm, ch...@rubedoinc.com ch...@rubedoinc.com wrote: Meeting tonight, see you there ! Our next meeting is scheduled for May 16th 630PM - 900PM @ Rubedo, inc. 14580 Beltwood Pkwy E Suite 103 Farmers Branch, TX 75244 (wifi available) On May 4, 11:20 am, ch...@rubedoinc.com ch...@rubedoinc.com wrote: Thanks everyone for attending the first meeting. It was great to talk clojurewith some like minded people who are excited by the possibilities ! Our next meeting is scheduled for May 16th 630PM - 900PM @ Rubedo, inc. 14580 Beltwood Pkwy E Suite 103 Farmers Branch, TX 75244 (wifi available) Right now, we will try for two meetings each month. In the beginning, these will be mostly hack nights. As the group matures, we will look at doing presentations / talks onClojure. As most of the group is relatively new toClojure, we decided to start with thehttp://projecteuler.net/problemsasaway to get familiar with the language and have some common solutions to discuss. At our next meeting, we will bring our solutions for problems 1-10 and discuss how we went about solving them. All are welcome ! On Apr 25, 9:08 pm, Christopher Redinger ch...@clojure.com wrote: ch...@rubedoinc.com wrote: Rubedo, inc. 14580 Beltwood Pkwy E Suite 103 Farmers Branch, TX 75244 When: 630PM Monday May 2nd What:ClojureInterest Group Topic: 1st meeting, what our goals are, and how to take over the world withClojure Hi Chris! Thanks for offering to host the group. I've added a link to this thread on theClojureUser Groups page:http://dev.clojure.org/display/community/Clojure+User+Groups. Hopefully to help people who might be looking. We can update the link to something with a little more information if you get a page set up somewhere. Also, if you choose to go through Meetup, they have provided us with a code that gives a discount toClojuregroups. See the above page for more information. Thanks again, and let me know if there's anythingClojure/core can help you out with! Thanks, Chris -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Why is class name not found?
I am getting this error and cannot find out what I've done wrong. Any pointers would be very appreciated. Exception in thread main java.lang.NoClassDefFoundError: test_csv I have built the project in test_csv successfully using cake. project.clj -- (defproject test_csv 0.1 :dependencies [[org.clojure/clojure 1.2.1] [org.clojure/clojure-contrib 1.2.0] [clojure-csv/clojure-csv 1.2.4]] :main test_csv) test_csv.clj - (ns test_csv (:import (java.io BufferedReader FileReader) (:use clojure-csv.core)) (defn -main [ args] (println Hello world!)) -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Why is class name not found?
I am invoking the program using java -jar test_csv-0.1-standalone.jar On Jun 15, 1:19 pm, octopusgrabbus octopusgrab...@gmail.com wrote: I am getting this error and cannot find out what I've done wrong. Any pointers would be very appreciated. Exception in thread main java.lang.NoClassDefFoundError: test_csv I have built the project in test_csv successfully using cake. project.clj -- (defproject test_csv 0.1 :dependencies [[org.clojure/clojure 1.2.1] [org.clojure/clojure-contrib 1.2.0] [clojure-csv/clojure-csv 1.2.4]] :main test_csv) test_csv.clj - (ns test_csv (:import (java.io BufferedReader FileReader) (:use clojure-csv.core)) (defn -main [ args] (println Hello world!)) -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Why is class name not found?
It is standard to name your filenames with underscores, but your clojure names with dashes (so 'ns test_csv' should be 'ns test-csv'). Also update that in your project.clj :main key. That may or may not be the cause of the problem here. On Wed, Jun 15, 2011 at 1:19 PM, octopusgrabbus octopusgrab...@gmail.comwrote: I am getting this error and cannot find out what I've done wrong. Any pointers would be very appreciated. Exception in thread main java.lang.NoClassDefFoundError: test_csv I have built the project in test_csv successfully using cake. project.clj -- (defproject test_csv 0.1 :dependencies [[org.clojure/clojure 1.2.1] [org.clojure/clojure-contrib 1.2.0] [clojure-csv/clojure-csv 1.2.4]] :main test_csv) test_csv.clj - (ns test_csv (:import (java.io BufferedReader FileReader) (:use clojure-csv.core)) (defn -main [ args] (println Hello world!)) -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Swank-Inject Issue
Hi, I am trying to get swank-inject to work on Ubuntu Linux and I am getting a failure related to tools.jar (ClassNotFoundException: com.sun.jdi.Bootstrap jdi.clj: 1). This error does not go away even if I add tools.jar directly to CLASSPATH. Has anyone seen this error before? Any ideas on how to solve this would be great. Thanks! Asim -- Here are the commands I am executing: export JAVA_HOME=/home/ajalis/dev/tools/Linux/jdk/jdk1.6.0_16_x64 export JDK_HOME=/home/ajalis/dev/tools/Linux/jdk/jdk1.6.0_16_x64 export CLASSPATH=/home/ajalis/dev/tools/Linux/jdk/jdk1.6.0_16_x64/lib/tools.jar which java rm -rf $HOME/tmp/swank-fun mkdir -p $HOME/tmp/swank-fun cd $HOME/tmp/swank-fun git clone https://github.com/wirde/swank-inject.git cd swank-inject lein uberjar ajalis-wsl:/home/ajalis m swank/install-v4 export JAVA_HOME=/home/ajalis/dev/tools/Linux/jdk/jdk1.6.0_16_x64 export JDK_HOME=/home/ajalis/dev/tools/Linux/jdk/jdk1.6.0_16_x64 export CLASSPATH=/home/ajalis/dev/tools/Linux/jdk/jdk1.6.0_16_x64/lib/tools.jar which java rm -rf $HOME/tmp/swank-fun mkdir -p $HOME/tmp/swank-fun cd $HOME/tmp/swank-fun git clone https://github.com/wirde/swank-inject.git cd swank-inject lein uberjar -- Here is the output I get: /home/ajalis/dev/tools/Linux/jdk/jdk1.6.0_16_x64/bin/java Initialized empty Git repository in /home/ajalis/tmp/swank-fun/swank-inject/.git/ remote: Counting objects: 225, done. remote: Compressing objects: 100% (199/199), done. remote: Total 225 (delta 110), reused 0 (delta 0) Receiving objects: 100% (225/225), 30.22 KiB, done. Resolving deltas: 100% (110/110), done. Cleaning up. Copying 5 files to /home/ajalis/tmp/swank-fun/swank-inject/lib Exception in thread main java.lang.ClassNotFoundException: com.sun.jdi.Bootstrap (jdi.clj:1) at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:2911) at clojure.lang.Compiler.compile1(Compiler.java:5933) at clojure.lang.Compiler.compile1(Compiler.java:5923) at clojure.lang.Compiler.compile(Compiler.java:5992) at clojure.lang.RT.compile(RT.java:368) at clojure.lang.RT.load(RT.java:407) at clojure.lang.RT.load(RT.java:381) at clojure.core$load$fn__4511.invoke(core.clj:4905) at clojure.core$load.doInvoke(core.clj:4904) at clojure.lang.RestFn.invoke(RestFn.java:409) at clojure.core$load_one.invoke(core.clj:4729) at clojure.core$load_lib.doInvoke(core.clj:4766) at clojure.lang.RestFn.applyTo(RestFn.java:143) at clojure.core$apply.invoke(core.clj:542) at clojure.core$load_libs.doInvoke(core.clj:4800) at clojure.lang.RestFn.applyTo(RestFn.java:138) at clojure.core$apply.invoke(core.clj:544) at clojure.core$use.doInvoke(core.clj:4880) at clojure.lang.RestFn.invoke(RestFn.java:409) at swank_inject.aot$loading__4410__auto__.invoke(aot.clj:2) at clojure.lang.AFn.applyToHelper(AFn.java:159) at clojure.lang.AFn.applyTo(AFn.java:151) at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:2906) at clojure.lang.Compiler.compile1(Compiler.java:5933) at clojure.lang.Compiler.compile1(Compiler.java:5923) at clojure.lang.Compiler.compile(Compiler.java:5992) at clojure.lang.RT.compile(RT.java:368) at clojure.lang.RT.load(RT.java:407) at clojure.lang.RT.load(RT.java:381) at clojure.core$load$fn__4511.invoke(core.clj:4905) at clojure.core$load.doInvoke(core.clj:4904) at clojure.lang.RestFn.invoke(RestFn.java:409) at clojure.core$load_one.invoke(core.clj:4729) at clojure.core$compile$fn__4516.invoke(core.clj:4916) at clojure.core$compile.invoke(core.clj:4915) at user$eval7.invoke(NO_SOURCE_FILE:1) at clojure.lang.Compiler.eval(Compiler.java:5424) at clojure.lang.Compiler.eval(Compiler.java:5415) at clojure.lang.Compiler.eval(Compiler.java:5391) at clojure.core$eval.invoke(core.clj:2382) at clojure.main$eval_opt.invoke(main.clj:235) at clojure.main$initialize.invoke(main.clj:254) at clojure.main$null_opt.invoke(main.clj:279) at clojure.main$main.doInvoke(main.clj:354) at clojure.lang.RestFn.invoke(RestFn.java:422) at clojure.lang.Var.invoke(Var.java:369) at clojure.lang.AFn.applyToHelper(AFn.java:165) at clojure.lang.Var.applyTo(Var.java:482) at clojure.main.main(main.java:37) Caused by: java.lang.ClassNotFoundException: com.sun.jdi.Bootstrap at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at clojure.lang.DynamicClassLoader.findClass(DynamicClassLoader.java:58) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at
Re: Why is class name not found?
I'm getting a new error:] [compile] Compiling namespace test-csv error evaluating: ((compile-stale source-path compile-path)) java.lang.RuntimeException: java.lang.ClassNotFoundException: :use.clojure-csv (test_csv.clj:1) Here's the modified project.clj defproject test-csv 0.1 :dependencies [[org.clojure/clojure 1.2.1] [org.clojure/clojure-contrib 1.2.0] [clojure-csv/clojure-csv 1.2.4]] :main test-csv) Here's the modified test_csv.clj -- (ns test-csv (:import (java.io BufferedReader FileReader) (:use clojure-csv))) (defn -main [ args] (println Hello world!)) I took the[clojure-csv/clojure-csv 1.2.4] for project.clj right from clojure-csv's README.md. On Jun 15, 1:37 pm, Mark Rathwell mark.rathw...@gmail.com wrote: It is standard to name your filenames with underscores, but your clojure names with dashes (so 'ns test_csv' should be 'ns test-csv'). Also update that in your project.clj :main key. That may or may not be the cause of the problem here. On Wed, Jun 15, 2011 at 1:19 PM, octopusgrabbus octopusgrab...@gmail.comwrote: I am getting this error and cannot find out what I've done wrong. Any pointers would be very appreciated. Exception in thread main java.lang.NoClassDefFoundError: test_csv I have built the project in test_csv successfully using cake. project.clj -- (defproject test_csv 0.1 :dependencies [[org.clojure/clojure 1.2.1] [org.clojure/clojure-contrib 1.2.0] [clojure-csv/clojure-csv 1.2.4]] :main test_csv) test_csv.clj - (ns test_csv (:import (java.io BufferedReader FileReader) (:use clojure-csv.core)) (defn -main [ args] (println Hello world!)) -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Why is class name not found?
Did you run the command to re-pull the dependencies, then rebuild your jar? (I'm assuming it is something like 'cake deps') On Wed, Jun 15, 2011 at 1:58 PM, octopusgrabbus octopusgrab...@gmail.comwrote: I'm getting a new error:] [compile] Compiling namespace test-csv error evaluating: ((compile-stale source-path compile-path)) java.lang.RuntimeException: java.lang.ClassNotFoundException: :use.clojure-csv (test_csv.clj:1) Here's the modified project.clj defproject test-csv 0.1 :dependencies [[org.clojure/clojure 1.2.1] [org.clojure/clojure-contrib 1.2.0] [clojure-csv/clojure-csv 1.2.4]] :main test-csv) Here's the modified test_csv.clj -- (ns test-csv (:import (java.io BufferedReader FileReader) (:use clojure-csv))) (defn -main [ args] (println Hello world!)) I took the[clojure-csv/clojure-csv 1.2.4] for project.clj right from clojure-csv's README.md. On Jun 15, 1:37 pm, Mark Rathwell mark.rathw...@gmail.com wrote: It is standard to name your filenames with underscores, but your clojure names with dashes (so 'ns test_csv' should be 'ns test-csv'). Also update that in your project.clj :main key. That may or may not be the cause of the problem here. On Wed, Jun 15, 2011 at 1:19 PM, octopusgrabbus octopusgrab...@gmail.comwrote: I am getting this error and cannot find out what I've done wrong. Any pointers would be very appreciated. Exception in thread main java.lang.NoClassDefFoundError: test_csv I have built the project in test_csv successfully using cake. project.clj -- (defproject test_csv 0.1 :dependencies [[org.clojure/clojure 1.2.1] [org.clojure/clojure-contrib 1.2.0] [clojure-csv/clojure-csv 1.2.4]] :main test_csv) test_csv.clj - (ns test_csv (:import (java.io BufferedReader FileReader) (:use clojure-csv.core)) (defn -main [ args] (println Hello world!)) -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Why is class name not found?
If I take the :use clojure-csv out of test_csv.clj, it compiles and all is well. I am guessing this is because I've mentioned clojure-csv in the project.clj file. On Jun 15, 1:58 pm, octopusgrabbus octopusgrab...@gmail.com wrote: I'm getting a new error:] [compile] Compiling namespace test-csv error evaluating: ((compile-stale source-path compile-path)) java.lang.RuntimeException: java.lang.ClassNotFoundException: :use.clojure-csv (test_csv.clj:1) Here's the modified project.clj defproject test-csv 0.1 :dependencies [[org.clojure/clojure 1.2.1] [org.clojure/clojure-contrib 1.2.0] [clojure-csv/clojure-csv 1.2.4]] :main test-csv) Here's the modified test_csv.clj -- (ns test-csv (:import (java.io BufferedReader FileReader) (:use clojure-csv))) (defn -main [ args] (println Hello world!)) I took the [clojure-csv/clojure-csv 1.2.4] for project.clj right from clojure-csv's README.md. On Jun 15, 1:37 pm, Mark Rathwell mark.rathw...@gmail.com wrote: It is standard to name your filenames with underscores, but your clojure names with dashes (so 'ns test_csv' should be 'ns test-csv'). Also update that in your project.clj :main key. That may or may not be the cause of the problem here. On Wed, Jun 15, 2011 at 1:19 PM, octopusgrabbus octopusgrab...@gmail.comwrote: I am getting this error and cannot find out what I've done wrong. Any pointers would be very appreciated. Exception in thread main java.lang.NoClassDefFoundError: test_csv I have built the project in test_csv successfully using cake. project.clj -- (defproject test_csv 0.1 :dependencies [[org.clojure/clojure 1.2.1] [org.clojure/clojure-contrib 1.2.0] [clojure-csv/clojure-csv 1.2.4]] :main test_csv) test_csv.clj - (ns test_csv (:import (java.io BufferedReader FileReader) (:use clojure-csv.core)) (defn -main [ args] (println Hello world!)) -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Why is class name not found?
Yes, I did all that. On Jun 15, 2:01 pm, Mark Rathwell mark.rathw...@gmail.com wrote: Did you run the command to re-pull the dependencies, then rebuild your jar? (I'm assuming it is something like 'cake deps') On Wed, Jun 15, 2011 at 1:58 PM, octopusgrabbus octopusgrab...@gmail.comwrote: I'm getting a new error:] [compile] Compiling namespace test-csv error evaluating: ((compile-stale source-path compile-path)) java.lang.RuntimeException: java.lang.ClassNotFoundException: :use.clojure-csv (test_csv.clj:1) Here's the modified project.clj defproject test-csv 0.1 :dependencies [[org.clojure/clojure 1.2.1] [org.clojure/clojure-contrib 1.2.0] [clojure-csv/clojure-csv 1.2.4]] :main test-csv) Here's the modified test_csv.clj -- (ns test-csv (:import (java.io BufferedReader FileReader) (:use clojure-csv))) (defn -main [ args] (println Hello world!)) I took the [clojure-csv/clojure-csv 1.2.4] for project.clj right from clojure-csv's README.md. On Jun 15, 1:37 pm, Mark Rathwell mark.rathw...@gmail.com wrote: It is standard to name your filenames with underscores, but your clojure names with dashes (so 'ns test_csv' should be 'ns test-csv'). Also update that in your project.clj :main key. That may or may not be the cause of the problem here. On Wed, Jun 15, 2011 at 1:19 PM, octopusgrabbus octopusgrab...@gmail.comwrote: I am getting this error and cannot find out what I've done wrong. Any pointers would be very appreciated. Exception in thread main java.lang.NoClassDefFoundError: test_csv I have built the project in test_csv successfully using cake. project.clj -- (defproject test_csv 0.1 :dependencies [[org.clojure/clojure 1.2.1] [org.clojure/clojure-contrib 1.2.0] [clojure-csv/clojure-csv 1.2.4]] :main test_csv) test_csv.clj - (ns test_csv (:import (java.io BufferedReader FileReader) (:use clojure-csv.core)) (defn -main [ args] (println Hello world!)) -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Why is class name not found?
On Wed, Jun 15, 2011 at 1:58 PM, octopusgrabbus octopusgrab...@gmail.com wrote: java.lang.ClassNotFoundException: :use.clojure-csv (test_csv.clj:1) (ns test-csv (:import (java.io BufferedReader FileReader) (:use clojure-csv))) Oops. You're trying to import your use clause. (ns test-csv (:import (java.io BufferedReader FileReader)) (:use clojure-csv)) And do try to find yourself an editor you like that will reindent by paren matching ... :) -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Why is class name not found?
See Ken's post, there is a paren out of place in test_csv.clj. On Wed, Jun 15, 2011 at 2:02 PM, octopusgrabbus octopusgrab...@gmail.comwrote: Yes, I did all that. On Jun 15, 2:01 pm, Mark Rathwell mark.rathw...@gmail.com wrote: Did you run the command to re-pull the dependencies, then rebuild your jar? (I'm assuming it is something like 'cake deps') On Wed, Jun 15, 2011 at 1:58 PM, octopusgrabbus octopusgrab...@gmail.comwrote: I'm getting a new error:] [compile] Compiling namespace test-csv error evaluating: ((compile-stale source-path compile-path)) java.lang.RuntimeException: java.lang.ClassNotFoundException: :use.clojure-csv (test_csv.clj:1) Here's the modified project.clj defproject test-csv 0.1 :dependencies [[org.clojure/clojure 1.2.1] [org.clojure/clojure-contrib 1.2.0] [clojure-csv/clojure-csv 1.2.4]] :main test-csv) Here's the modified test_csv.clj -- (ns test-csv (:import (java.io BufferedReader FileReader) (:use clojure-csv))) (defn -main [ args] (println Hello world!)) I took the[clojure-csv/clojure-csv 1.2.4] for project.clj right from clojure-csv's README.md. On Jun 15, 1:37 pm, Mark Rathwell mark.rathw...@gmail.com wrote: It is standard to name your filenames with underscores, but your clojure names with dashes (so 'ns test_csv' should be 'ns test-csv'). Also update that in your project.clj :main key. That may or may not be the cause of the problem here. On Wed, Jun 15, 2011 at 1:19 PM, octopusgrabbus octopusgrab...@gmail.comwrote: I am getting this error and cannot find out what I've done wrong. Any pointers would be very appreciated. Exception in thread main java.lang.NoClassDefFoundError: test_csv I have built the project in test_csv successfully using cake. project.clj -- (defproject test_csv 0.1 :dependencies [[org.clojure/clojure 1.2.1] [org.clojure/clojure-contrib 1.2.0] [clojure-csv/clojure-csv 1.2.4]] :main test_csv) test_csv.clj - (ns test_csv (:import (java.io BufferedReader FileReader) (:use clojure-csv.core)) (defn -main [ args] (println Hello world!)) -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Question about data structures and encapsulation
Newbie so go gentle please :). I am an experienced OO Java developer (decade +) considering jumping fence to a functional language, and clojure is pretty high up on the list for a number of reasons. I am so used to defining everything as objects which are sealed units of state and behaviour that I am struggling to see how to solve the same problem with clojure. I desperately wish somebody would write a domain driven design with clojure :). In brief, in OO state is exposed via a well defined API. That state may be simple properties (values) or it may be calculations (functions). And critically, the decision as to whether it is a value or a function is an implementation concern. The Java Bean spec defines accessors for properties of a class, behind which lies the logic of how to retrieve that state. So, the very common Person class will expose get/setName(), get/setAge() etc. and as a consumer I have no idea how the results are calcualted. In Clojure, if I understand correctly, the preferred way would be to use a map (or defstruct) with keys such as :name and :age. These are then retrieved as (person :name) and (person: age) etc. My question is if I suddenly decided that one of those values is best implemented as a calculation, how can I seamlessly implement that. By seamless I mean implement it without updating any consumers of a person? For example, if I changed the age property to be the result of a function, I could either replace the value of age with a function that calculates age or write a function(person)-age. Both of those are disruptive to the consumers of person. I understand that clojure is about explicitly distinguishing between state and functions, but I see this as a high price to pay. Have I missed something? The OO in me is saying well, never introspect a map directly, rather provide get-X(person) functions but that is very very noisy. That's enough for now - this is, I expect, the first of many cries for help :) Thanks in advance to all who reply! -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Question about data structures and encapsulation
On Wed, Jun 15, 2011 at 2:41 PM, Colin Yates colin.ya...@gmail.com wrote: In Clojure, if I understand correctly, the preferred way would be to use a map (or defstruct) with keys such as :name and :age. These are then retrieved as (person :name) and (person: age) etc. My question is if I suddenly decided that one of those values is best implemented as a calculation, how can I seamlessly implement that. By seamless I mean implement it without updating any consumers of a person? For example, if I changed the age property to be the result of a function, I could either replace the value of age with a function that calculates age or write a function(person)-age. Both of those are disruptive to the consumers of person. I understand that clojure is about explicitly distinguishing between state and functions, but I see this as a high price to pay. Have I missed something? The OO in me is saying well, never introspect a map directly, rather provide get-X(person) functions but that is very very noisy. But that's more or less what you'd have to do. If age might be calculated in some more complex manner, now or in the future, you want something like (defn age [person] (:age person)) or whatever. -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Why is class name not found?
Thanks for the response. I eventually found that as well. (ns test-csv (:gen-class) (:import (java.io BufferedReader FileReader)) (:use clojure-csv.core)) (defn process-file [file-name] (with-open [br (BufferedReader. (FileReader. file-name))] (parse-csv (line-seq br (defn -main [ args] (process-file resultset.csv)) On Jun 15, 2:08 pm, Mark Rathwell mark.rathw...@gmail.com wrote: See Ken's post, there is a paren out of place in test_csv.clj. On Wed, Jun 15, 2011 at 2:02 PM, octopusgrabbus octopusgrab...@gmail.comwrote: Yes, I did all that. On Jun 15, 2:01 pm, Mark Rathwell mark.rathw...@gmail.com wrote: Did you run the command to re-pull the dependencies, then rebuild your jar? (I'm assuming it is something like 'cake deps') On Wed, Jun 15, 2011 at 1:58 PM, octopusgrabbus octopusgrab...@gmail.comwrote: I'm getting a new error:] [compile] Compiling namespace test-csv error evaluating: ((compile-stale source-path compile-path)) java.lang.RuntimeException: java.lang.ClassNotFoundException: :use.clojure-csv (test_csv.clj:1) Here's the modified project.clj defproject test-csv 0.1 :dependencies [[org.clojure/clojure 1.2.1] [org.clojure/clojure-contrib 1.2.0] [clojure-csv/clojure-csv 1.2.4]] :main test-csv) Here's the modified test_csv.clj -- (ns test-csv (:import (java.io BufferedReader FileReader) (:use clojure-csv))) (defn -main [ args] (println Hello world!)) I took the [clojure-csv/clojure-csv 1.2.4] for project.clj right from clojure-csv's README.md. On Jun 15, 1:37 pm, Mark Rathwell mark.rathw...@gmail.com wrote: It is standard to name your filenames with underscores, but your clojure names with dashes (so 'ns test_csv' should be 'ns test-csv'). Also update that in your project.clj :main key. That may or may not be the cause of the problem here. On Wed, Jun 15, 2011 at 1:19 PM, octopusgrabbus octopusgrab...@gmail.comwrote: I am getting this error and cannot find out what I've done wrong. Any pointers would be very appreciated. Exception in thread main java.lang.NoClassDefFoundError: test_csv I have built the project in test_csv successfully using cake. project.clj -- (defproject test_csv 0.1 :dependencies [[org.clojure/clojure 1.2.1] [org.clojure/clojure-contrib 1.2.0] [clojure-csv/clojure-csv 1.2.4]] :main test_csv) test_csv.clj - (ns test_csv (:import (java.io BufferedReader FileReader) (:use clojure-csv.core)) (defn -main [ args] (println Hello world!)) -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
clojure-csv Column or field extraction
Is it possible to use clojure-csv to extract data positionally in a .csv file, or should I use BufferedReader to read each line lazily and apply splitting the line up into fields by delimiter? Thanks. cmn -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Why is class name not found?
Thanks for all the responses. This was a success. On Jun 15, 3:02 pm, octopusgrabbus octopusgrab...@gmail.com wrote: Thanks for the response. I eventually found that as well. (ns test-csv (:gen-class) (:import (java.io BufferedReader FileReader)) (:use clojure-csv.core)) (defn process-file [file-name] (with-open [br (BufferedReader. (FileReader. file-name))] (parse-csv (line-seq br (defn -main [ args] (process-file resultset.csv)) On Jun 15, 2:08 pm, Mark Rathwell mark.rathw...@gmail.com wrote: See Ken's post, there is a paren out of place in test_csv.clj. On Wed, Jun 15, 2011 at 2:02 PM, octopusgrabbus octopusgrab...@gmail.comwrote: Yes, I did all that. On Jun 15, 2:01 pm, Mark Rathwell mark.rathw...@gmail.com wrote: Did you run the command to re-pull the dependencies, then rebuild your jar? (I'm assuming it is something like 'cake deps') On Wed, Jun 15, 2011 at 1:58 PM, octopusgrabbus octopusgrab...@gmail.comwrote: I'm getting a new error:] [compile] Compiling namespace test-csv error evaluating: ((compile-stale source-path compile-path)) java.lang.RuntimeException: java.lang.ClassNotFoundException: :use.clojure-csv (test_csv.clj:1) Here's the modified project.clj defproject test-csv 0.1 :dependencies [[org.clojure/clojure 1.2.1] [org.clojure/clojure-contrib 1.2.0] [clojure-csv/clojure-csv 1.2.4]] :main test-csv) Here's the modified test_csv.clj -- (ns test-csv (:import (java.io BufferedReader FileReader) (:use clojure-csv))) (defn -main [ args] (println Hello world!)) I took the [clojure-csv/clojure-csv 1.2.4] for project.clj right from clojure-csv's README.md. On Jun 15, 1:37 pm, Mark Rathwell mark.rathw...@gmail.com wrote: It is standard to name your filenames with underscores, but your clojure names with dashes (so 'ns test_csv' should be 'ns test-csv'). Also update that in your project.clj :main key. That may or may not be the cause of the problem here. On Wed, Jun 15, 2011 at 1:19 PM, octopusgrabbus octopusgrab...@gmail.comwrote: I am getting this error and cannot find out what I've done wrong. Any pointers would be very appreciated. Exception in thread main java.lang.NoClassDefFoundError: test_csv I have built the project in test_csv successfully using cake. project.clj -- (defproject test_csv 0.1 :dependencies [[org.clojure/clojure 1.2.1] [org.clojure/clojure-contrib 1.2.0] [clojure-csv/clojure-csv 1.2.4]] :main test_csv) test_csv.clj - (ns test_csv (:import (java.io BufferedReader FileReader) (:use clojure-csv.core)) (defn -main [ args] (println Hello world!)) -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Question about data structures and encapsulation
Hi, and just today this was posted to reddit: http://skillsmatter.com/podcast/scala/talk-by-patrick-fredriksson Sincerely Meikel -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Allow Data Structure to Be Called as Function
Hi, I'm sorry if this has been asked before, but I would like to know how to create data structures in Clojure that can be used in the same way as the built-in data structures. For example, I can access the elements of a vector by (my-vec 1). How can I implement this interface when creating a data structure in Clojure? Thanks, RJ -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Allow Data Structure to Be Called as Function
On Wed, Jun 15, 2011 at 3:53 PM, RJ Nowling rnowl...@gmail.com wrote: Hi, I'm sorry if this has been asked before, but I would like to know how to create data structures in Clojure that can be used in the same way as the built-in data structures. For example, I can access the elements of a vector by (my-vec 1). How can I implement this interface when creating a data structure in Clojure? (defrecord Foo [...] ... IFn (invoke [this] (do-this-on-zero-argument-call)) (invoke [this x] (do-when-called-with-x)) (invoke [this x y] (+ x y))) = ((Foo.) 33 9) 42 = -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Emacs setup - quick navigation to files and definitions
emacs-nav is a lightweight project explorer for emacs that I have found useful - https://code.google.com/p/emacs-nav/ It has the ability to grep the directory structure for a symbol (Press 'g' when the cursor is in the emacs-nav window). I find that handy to search for function names across projects. Disclaimer - Clojure for me right now is only getting to be a serious hobby so I am not certain this will scale :) On a side note - many thanks to Glen Stampoultzis for the ctrl-x ctrl- i tip ... Works like a charm. Beats the heck out of ctrl-s :) Hope this helps. Raju On Jun 15, 5:40 am, Kelvin Ward kelvin.d.w...@googlemail.com wrote: In my experience ECB and Speedbar (both come with CEDET) is the only option. I think that speedbar may be available without cedet, but it seems less functional. ECB can keep the speedbar window fixed regardless of closing/opening other emacs windows. It's not a nice as IDEs I'd say, but certainly does work, showing a tree of directories, clojure files and clojure functions/defs. CEDET does look quite the overwhelming install, but it wasn't that bad. I found several of the default ecb/speedbar behaviours unpleasant and fixed them with the right customisation. Right now, having to double, instead of single click, on ecb windows is the most annoying. Some settings I have in my emacs config, some of which I won't remember why I set them: (speedbar-add-supported-extension .clj) (setq ecb-use-speedbar-instead-native-tree-buffer 'dir) (setq speedbar-show-unknown-files t) (setq speedbar-tag-regroup-maximum-length 100) (setq ecb-primary-secondary-mouse-buttons 'mouse-1--C-mouse-1) (setq ecb-speedbar-buffer-sync nil) (setq speedbar-tag-hierarchy-method '(speedbar-sort-tag-hierarchy)) (setq ecb-auto-expand-directory-tree nil) My emacs setup files might helphttps://bitbucket.org/enerqi/emacs-setup/src such as src/elisp/rc/emacs-rc-cedet.el. However, I've saved a copy of cedet with my elisp files. With recent versions of emacs (23+ or 24+) cedet comes with emacs and I had to delete the cedet shipped with emacs to avoid changing my emacs config. On Jun 13, 2:50 am, yair yair@gmail.com wrote: Hi, With swank and slime all set-up along with CDT, further improved by slime autocomplete, my emacs setup is getting pretty close to being a full featured, highly clojure focused IDE. One thing I am struggling with while working on a larger than usual project (i.e. 7 source files some of which have 200-300 lines) is quickly navigating between source files and the definitions within them. I took a look at CEDET but it seemed a bit overwhelming, and I wasn't sure the effort would be worth it as I couldn't tell if clojure would then be supported within it. So, which plugins do you use in emacs for navigating between clojure source files and definitions? Thanks -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Question about data structures and encapsulation
Hi, I must admit my thoughts are still not fixed concerning this, guided by several considerations: * consider the ring spec: it specifies what keys are expected to be present in the request map, the response map. Good enough. * Wait ! what if some keys could be calculated from others (derived) = they may not be essential, put them in a function. * Wait ! what if the computation of the value of the derived key heavyweight ? * answer 1 : let the consumer cache it. * answer 2 : cache the value in the map, but make it clear that it costs something to compute it, e.g. by placing it explicitly (as in in the spec of your map) in a `delay` construct * choice between 1 and 2 will obviously be in the library's designer hand * I tend to be very liberal with the use of maps inside the library I'm writing : after all, no other code than my library will depend on it, so I assume the choice of breaking inner parts of my lib by exposing map keys everywhere in it. It's a kind of cost/benefit tradeoff: no cost upfront, many benefits, and if later I have to change more things in my lib than if I had encapsulated things, then I both grumble and then think that the price of the change has been paid several times by not having paid the cost of having encapsulated all parts of my lib concepts. * I tend to be more selective with the parts of the lib which are exposed to consumers. * All in all, it may not be such a big deal, because of the following characteristic of clojure: it emphazises representing in maps only the essential pieces of your domain model. Those which will be subject to change for good reasons (change in spec), not wrong reasons (hopefully). And, also, when it's possible, I try to only expose as maps to consumers as little as possible. The more objects they retrieve from libraries are opaque objects (only intended to be passed back to library functions), the better. This is related to the previous point: the only objects which remain transparent are then the maps which represent the essential part of the concept (only data which are not computable from other data). HTH, -- Laurent 2011/6/15 Colin Yates colin.ya...@gmail.com: Newbie so go gentle please :). I am an experienced OO Java developer (decade +) considering jumping fence to a functional language, and clojure is pretty high up on the list for a number of reasons. I am so used to defining everything as objects which are sealed units of state and behaviour that I am struggling to see how to solve the same problem with clojure. I desperately wish somebody would write a domain driven design with clojure :). In brief, in OO state is exposed via a well defined API. That state may be simple properties (values) or it may be calculations (functions). And critically, the decision as to whether it is a value or a function is an implementation concern. The Java Bean spec defines accessors for properties of a class, behind which lies the logic of how to retrieve that state. So, the very common Person class will expose get/setName(), get/setAge() etc. and as a consumer I have no idea how the results are calcualted. In Clojure, if I understand correctly, the preferred way would be to use a map (or defstruct) with keys such as :name and :age. These are then retrieved as (person :name) and (person: age) etc. My question is if I suddenly decided that one of those values is best implemented as a calculation, how can I seamlessly implement that. By seamless I mean implement it without updating any consumers of a person? For example, if I changed the age property to be the result of a function, I could either replace the value of age with a function that calculates age or write a function(person)-age. Both of those are disruptive to the consumers of person. I understand that clojure is about explicitly distinguishing between state and functions, but I see this as a high price to pay. Have I missed something? The OO in me is saying well, never introspect a map directly, rather provide get-X(person) functions but that is very very noisy. That's enough for now - this is, I expect, the first of many cries for help :) Thanks in advance to all who reply! -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options,
Re: clojure-csv Column or field extraction
I'm afraid I don't understand the question. What do you mean positionally? When it parses the CSV file, it gives you back a stream of rows, each row being a vector of the contents of each cell of the CSV. If you are interested in cells at a given row/column, you should be able to count into those vectors fairly naturally... - David On Wed, Jun 15, 2011 at 2:08 PM, octopusgrabbus octopusgrab...@gmail.com wrote: Is it possible to use clojure-csv to extract data positionally in a .csv file, or should I use BufferedReader to read each line lazily and apply splitting the line up into fields by delimiter? Thanks. cmn -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Question about data structures and encapsulation
Hi Colin! Welcome to Clojure! On Wed, Jun 15, 2011 at 11:41 AM, Colin Yates colin.ya...@gmail.com wrote: the very common Person class will expose get/setName(), get/setAge() etc. and as a consumer I have no idea how the results are calcualted. The FP approach certainly takes some getting used to after a lot of Java! I like the fact that a lot of (post-Java) languages go out of their way to avoid all the boilerplate get/set methods in various ways because this is very high ceremony. I was lucky enough to be exposed to functional programming in the 80's and then move into OOP in the 90's (with C++ in '92 and Java in '97). Whilst I am still unlearning some OOP habits, I'm more comfortable with the non-OO approach and dusting off my older programming approaches. I'm finding, as I introduce more people to Clojure, that folks without a lot of OOP experience tend to pick up FP much quicker and aren't as concerned about get/set encapsulation. My experience with OOP has been that essential properties of objects rarely change into computed functions (and derived properties are computed functions in the first place). That said, of course there are situations where an essential property needs a function: when you have side-effects on the get/set operation, such as recording changes, but I'd argue that is likely to be known upfront. Also given the preference for immutable data, you're much less likely to use/need setters. My suggestion would be to code with raw maps instead of functions-wrapping-maps and see how things go. By using raw maps you'll find that a lot of power can be brought to bear with standard Clojure functions. As for the age property on Person, that seems to be a common example given to justify the use of getters but age is a derived property, based on date of birth, and every real world system I've worked with that represents people, and needs age, uses a function for it upfront. So I think that's a bit of a strawman :) Hope that helps? -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Railo Technologies, Inc. -- http://www.getrailo.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Where to place Arguments
On Wed, Jun 15, 2011 at 8:25 AM, Aaron Cohen aa...@assonance.org wrote: For one previous discussion of this same topic: https://groups.google.com/d/msg/clojure/iyyNyWs53dc/13dWIhwTKzoJ Very helpful. Rich's explanation helps clarify something that hasn't (yet) sunk in for me: the difference between collection and sequence... More discussion / education on that from the Clojure old hands would be very beneficial to a lot of us newer folks, I suspect! -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Railo Technologies, Inc. -- http://www.getrailo.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Question about data structures and encapsulation
Thanks for all the help, all of you. The Clojure community has a reputation for being helpful :) The example of age as a property which might change from a value to a function was indeed a strawman, but it was just an example. So the consensus seems to be that yes, that requirement is hard to solve, but as Sean states, it isn't a particularly common occurrence. KISS with maps seems to be the way to go. Thanks again! -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Allow Data Structure to Be Called as Function
You could also use reify: (defn make-foo [s] (reify clojure.lang.IFn (invoke [this] (str Hello, s ((make-foo RJ)) Hello, RJ I have to admit, though, that I'm unclear on the relative merits of defrecord vs. reify. Anyone want to comment? Cheers, -Michael Nygard On Jun 15, 2011, at 12:57 PM, Ken Wesson wrote: On Wed, Jun 15, 2011 at 3:53 PM, RJ Nowling rnowl...@gmail.com wrote: Hi, I'm sorry if this has been asked before, but I would like to know how to create data structures in Clojure that can be used in the same way as the built-in data structures. For example, I can access the elements of a vector by (my-vec 1). How can I implement this interface when creating a data structure in Clojure? (defrecord Foo [...] ... IFn (invoke [this] (do-this-on-zero-argument-call)) (invoke [this x] (do-when-called-with-x)) (invoke [this x y] (+ x y))) = ((Foo.) 33 9) 42 = -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en Michael T. Nygard mtnyg...@gmail.com http://www.michaelnygard.com/ Release It! Design and Deploy Production-Ready Software http://bit.ly/ReleaseIt Beautiful Architecture http://bit.ly/BeautifulArchitecture 97 Things Every Software Architect Should Know http://bit.ly/97Things -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Allow Data Structure to Be Called as Function
Thank you, Ken and Michael. Not knowing how to do that bothered me since it felt like I couldn't create data structures that were on the same level of the built-in data structures. :) On Jun 15, 6:59 pm, Michael Nygard mtnyg...@gmail.com wrote: You could also use reify: (defn make-foo [s] (reify clojure.lang.IFn (invoke [this] (str Hello, s ((make-foo RJ)) Hello, RJ I have to admit, though, that I'm unclear on the relative merits of defrecord vs. reify. Anyone want to comment? Cheers, -Michael Nygard On Jun 15, 2011, at 12:57 PM, Ken Wesson wrote: On Wed, Jun 15, 2011 at 3:53 PM, RJ Nowling rnowl...@gmail.com wrote: Hi, I'm sorry if this has been asked before, but I would like to know how to create data structures in Clojure that can be used in the same way as the built-in data structures. For example, I can access the elements of a vector by (my-vec 1). How can I implement this interface when creating a data structure in Clojure? (defrecord Foo [...] ... IFn (invoke [this] (do-this-on-zero-argument-call)) (invoke [this x] (do-when-called-with-x)) (invoke [this x y] (+ x y))) = ((Foo.) 33 9) 42 = -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en Michael T. Nygard mtnyg...@gmail.comhttp://www.michaelnygard.com/ Release It! Design and Deploy Production-Ready Softwarehttp://bit.ly/ReleaseIt Beautiful Architecturehttp://bit.ly/BeautifulArchitecture 97 Things Every Software Architect Should Knowhttp://bit.ly/97Things -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
using regex reader macro with generated code
IS it possible to use the regex reader macro # with generated code? What I mean is do something like: #${(join | (range 1 1))} I'm using ${...} to mean string interpolation, though I know Clojure doesn't have that syntax. Is there a way to get this effect or must I use (re-pattern (join | (range 1 1))) Thanks for the help! Alex -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojure-csv Column or field extraction
I've got to go back and look at your documentation. I'm not sure how to pull the columns out of each row. On Jun 15, 5:04 pm, David Santiago david.santi...@gmail.com wrote: I'm afraid I don't understand the question. What do you mean positionally? When it parses the CSV file, it gives you back a stream of rows, each row being a vector of the contents of each cell of the CSV. If you are interested in cells at a given row/column, you should be able to count into those vectors fairly naturally... - David On Wed, Jun 15, 2011 at 2:08 PM, octopusgrabbusoctopusgrab...@gmail.com wrote: Is it possible to use clojure-csv to extract data positionally in a .csv file, or should I use BufferedReader to read each line lazily and apply splitting the line up into fields by delimiter? Thanks. cmn -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojure-csv Column or field extraction
Here's a repl session that will hopefully demonstrate how to do a few things, including pull out an entire column. Just remember the library turns CSVs into regular clojure data structures, so getting the data you want out of the return value of the parse is just about indexing into vectors. user= (use 'clojure-csv.core) nil user= (def csv (parse-csv 1,2,3\n4,5,6\n7,8,9)) #'user/csv user= (nth (nth csv 1) 2) ;; Get 2nd row, last column. 6 user= (- csv (nth 1) (nth 2)) ;; Another way to do it. 6 user= (defn get-column [parsed-csv col] (map #(nth % col) parsed-csv)) ;; Function to return a given column. #'user/get-column user= (get-column csv 1) ;; Get second column as a sequence. (2 5 8) - David On Wed, Jun 15, 2011 at 9:58 PM, octopusgrabbus octopusgrab...@gmail.com wrote: I've got to go back and look at your documentation. I'm not sure how to pull the columns out of each row. On Jun 15, 5:04 pm, David Santiago david.santi...@gmail.com wrote: I'm afraid I don't understand the question. What do you mean positionally? When it parses the CSV file, it gives you back a stream of rows, each row being a vector of the contents of each cell of the CSV. If you are interested in cells at a given row/column, you should be able to count into those vectors fairly naturally... - David On Wed, Jun 15, 2011 at 2:08 PM, octopusgrabbusoctopusgrab...@gmail.com wrote: Is it possible to use clojure-csv to extract data positionally in a .csv file, or should I use BufferedReader to read each line lazily and apply splitting the line up into fields by delimiter? Thanks. cmn -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en