> 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,
> -M
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=
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 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, e
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 (jo
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 wrote:
> You could also use reify:
>
> (defn make-foo [s]
> (reify clojure
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, 20
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
On Wed, Jun 15, 2011 at 8:25 AM, Aaron Cohen 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" a
Hi Colin! Welcome to Clojure!
On Wed, Jun 15, 2011 at 11:41 AM, Colin Yates 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
Ja
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
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)
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 proj
On Wed, Jun 15, 2011 at 3:53 PM, RJ Nowling 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
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 da
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
Thanks for all the responses. This was a success.
On Jun 15, 3:02 pm, octopusgrabbus 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-nam
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" grou
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
On Wed, Jun 15, 2011 at 2:41 PM, Colin Yates 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 o
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
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 wrote:
> Yes, I did all that.
>
> On Jun 15, 2:01 pm, Mark Rathwell wrote:
> > Did you run the command to re-pull the dependencies, then rebuild your
> jar?
> > (I'm assuming it is som
On Wed, Jun 15, 2011 at 1:58 PM, octopusgrabbus
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 Bu
Yes, I did all that.
On Jun 15, 2:01 pm, Mark Rathwell 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
> wrote:
>
>
>
>
>
>
>
> > I'm getting a new error:]
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 wrote:
> I'm getting a new error:]
>
> [compile] Compiling namespace test-csv
> error evaluating:
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 wrote:
> I'm getting a new error:]
>
> [compile] Compiling namespace test-csv
> error evaluating:
> ((compile-stale source
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
-
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
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 wrote:
> I
I am invoking the program using
java -jar test_csv-0.1-standalone.jar
On Jun 15, 1:19 pm, octopusgrabbus 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 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"
:de
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"
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 th
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
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 lei
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 a
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
wrote:
> On Wed, Jun 15, 2011 at 11:26 PM, octopusgrabbus
> wrote:
>
> > Here is the project.clj
> > (defproject helloworld "0.1"
> > :dependencies [[org.
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 so
On Wed, Jun 15, 2011 at 11:26 PM, octopusgrabbus
wrote:
> 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"]]
>
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 escap
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 f
On Tue, Jun 14, 2011 at 4:28 PM, Nick Zbinden 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 wou
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
wrote:
> I have clojure-1.2.1.jar. It is in
I've found the missing Clojure releases on github, will unpack and put
in my CLASSPATH.
On Jun 15, 10:57 am, octopusgrabbus 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:cl
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
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 the
>
> > 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
Thanks. It wasn't on the CLASSPATH.
On Jun 14, 3:41 pm, David Santiago 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 th
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 unsubscri
On Wed, Jun 15, 2011 at 10:08 AM, Kevin Sookocheff
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)
On Wed, Jun 15, 2011 at 9:52 AM, James Keats 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 t
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, h
> 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 "Cloju
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))
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 :
> Hi all. I'm struggling to see the point of this (from Pragmatic's
> Programming Clojure):
>
> Java => rnd.nextInt()
> Clojure =>
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 midd
Ken Wesson 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 j
Clojure-CSV might be useful:
https://github.com/davidsantiago/clojure-csv
Regards,
Shantanu
On Jun 14, 6:06 pm, Mark wrote:
> Although it may be overkill for you, take a look at Teiid: http://teiid.org
>
> On Jun 14, 5:30 am, finbeu wrote:
>
>
>
>
>
>
>
> > Hello,
>
> > I have a couple of csv
On Wed, Jun 15, 2011 at 6:27 AM, Tassilo Horn 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 j
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 loadi
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 d
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
61 matches
Mail list logo