Re: Properly including clojure-contrib

2011-06-16 Thread octopusgrabbus
Thanks.
That did it.

On Jun 16, 5:46 pm, Benny Tsai  wrote:
> Hi cmn,
>
> A few things:
>
> 1. The warnings you see are because the clojure.contrib.string namespace
> defines several functions that have the same name as core functions (repeat,
> reverse, etc.).  The recommended way to pull in namespaces like that is to
> do (:require [clojure.contrib.string :as str]), and then the functions can
> be used via (str/repeat ...), (str/reverse ...), etc.
> 2. As of 1.2, "split" is incorporated into clojure.string, so no need to
> grab clojure.contrib.string just for that function.  clojure.string also
> defines functions with the same name as core functions, so it should be
> pulled in via (:require [clojure.string :as str]), and split can then be
> used via (str/split ...).
> 3. That EOF error is because process-file needs one more closing paren.

-- 
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: Properly including clojure-contrib

2011-06-16 Thread Mark Rathwell
The clojure.contrib.string namespace contains many function names which are
already defined clojure.core.  So, by :use-ing clojure.contrib.string, you
will be replacing the core functions with the string functions.  Rarely do
you really want to do this.  It is generally best to :require instead of
:use.

so something like:

(ns test-csv
 (:gen-class)
 (:import (java.io BufferedReader FileReader StringReader))
 (:use clojure-csv.core)
 (:require [clojure.contrib.string :as string]))

(defn process-file [file-name]
   (with-open [br (BufferedReader. (FileReader. file-name))]
   (println (string/split (line-seq br)",")))

(defn -main [& args]
 (process-file "resultset.csv"))



On Thu, Jun 16, 2011 at 5:37 PM, octopusgrabbus wrote:

> I don't know what I'm doing wrong. After adding (:use
> clojure.contrib.string) to
>
> (ns test-csv
>   (:gen-class)
>  (:import (java.io BufferedReader FileReader StringReader))
>  (:use clojure-csv.core)
>   (:use clojure.contrib.string))
>
>
> (defn process-file [file-name]
>(with-open [br (BufferedReader. (FileReader. file-name))]
>(println (split (line-seq br)",")))
>
> (defn -main [& args]
>  (process-file "resultset.csv"))
>
> I'm getting these errors on compile:
>
>  [compile] Compiling namespace test-csv
> WARNING: repeat already refers to: #'clojure.core/repeat in namespace:
> test-csv, being replaced by: #'clojure.contrib.string/repeat
> WARNING: butlast already refers to: #'clojure.core/butlast in
> namespace: test-csv, being replaced by: #'clojure.contrib.string/
> butlast
> WARNING: reverse already refers to: #'clojure.core/reverse in
> namespace: test-csv, being replaced by: #'clojure.contrib.string/
> reverse
> WARNING: get already refers to: #'clojure.core/get in namespace: test-
> csv, being replaced by: #'clojure.contrib.string/get
> WARNING: partition already refers to: #'clojure.core/partition in
> namespace: test-csv, being replaced by: #'clojure.contrib.string/
> partition
> WARNING: drop already refers to: #'clojure.core/drop in namespace:
> test-csv, being replaced by: #'clojure.contrib.string/drop
> WARNING: take already refers to: #'clojure.core/take in namespace:
> test-csv, being replaced by: #'clojure.contrib.string/take
> error evaluating:
> ((compile-stale source-path compile-path))
> java.lang.RuntimeException: java.lang.Exception: EOF while reading
> (test_csv.clj:15)
> .
> .
> .
>
> What am I doing wrong?
> tnx
> cmn
> On Jun 16, 5:16 pm, Damon Snyder  wrote:
> > Hi cmn,
> > I think if you add clojure.contrib.string to your use or simply add
> > (:use clojure.contrib.string). I think that should fix it.
> >
> > Damon
> >
> > On Jun 16, 12:16 pm, octopusgrabbus  wrote:
> >
> >
> >
> >
> >
> >
> >
> > > What is the proper way to :use clojure contrib so split resolves as a
> > > symbol?
> >
> > > ns test-csv
> > >   (:gen-class)
> > >   (:import (java.io BufferedReader FileReader StringReader))
> > >   (:use clojure-csv.core)
> > >   (:use [clojure.contrib.def]))
> >
> > > (defn process-file [file-name]
> > > (with-open [br (BufferedReader. (FileReader. file-name))]
> > > (println (split "," (line-seq br)
> >
> > > (defn -main [& args]
> > >   (process-file "resultset.csv"))
> >
> > > 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: Properly including clojure-contrib

2011-06-16 Thread Benny Tsai
Hi cmn,

A few things:

1. The warnings you see are because the clojure.contrib.string namespace 
defines several functions that have the same name as core functions (repeat, 
reverse, etc.).  The recommended way to pull in namespaces like that is to 
do (:require [clojure.contrib.string :as str]), and then the functions can 
be used via (str/repeat ...), (str/reverse ...), etc.
2. As of 1.2, "split" is incorporated into clojure.string, so no need to 
grab clojure.contrib.string just for that function.  clojure.string also 
defines functions with the same name as core functions, so it should be 
pulled in via (:require [clojure.string :as str]), and split can then be 
used via (str/split ...).
3. That EOF error is because process-file needs one more closing paren.

-- 
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: Properly including clojure-contrib

2011-06-16 Thread octopusgrabbus
I don't know what I'm doing wrong. After adding (:use
clojure.contrib.string) to

(ns test-csv
  (:gen-class)
  (:import (java.io BufferedReader FileReader StringReader))
  (:use clojure-csv.core)
  (:use clojure.contrib.string))


(defn process-file [file-name]
(with-open [br (BufferedReader. (FileReader. file-name))]
(println (split (line-seq br)",")))

(defn -main [& args]
  (process-file "resultset.csv"))

I'm getting these errors on compile:

  [compile] Compiling namespace test-csv
WARNING: repeat already refers to: #'clojure.core/repeat in namespace:
test-csv, being replaced by: #'clojure.contrib.string/repeat
WARNING: butlast already refers to: #'clojure.core/butlast in
namespace: test-csv, being replaced by: #'clojure.contrib.string/
butlast
WARNING: reverse already refers to: #'clojure.core/reverse in
namespace: test-csv, being replaced by: #'clojure.contrib.string/
reverse
WARNING: get already refers to: #'clojure.core/get in namespace: test-
csv, being replaced by: #'clojure.contrib.string/get
WARNING: partition already refers to: #'clojure.core/partition in
namespace: test-csv, being replaced by: #'clojure.contrib.string/
partition
WARNING: drop already refers to: #'clojure.core/drop in namespace:
test-csv, being replaced by: #'clojure.contrib.string/drop
WARNING: take already refers to: #'clojure.core/take in namespace:
test-csv, being replaced by: #'clojure.contrib.string/take
error evaluating:
((compile-stale source-path compile-path))
java.lang.RuntimeException: java.lang.Exception: EOF while reading
(test_csv.clj:15)
.
.
.

What am I doing wrong?
tnx
cmn
On Jun 16, 5:16 pm, Damon Snyder  wrote:
> Hi cmn,
> I think if you add clojure.contrib.string to your use or simply add
> (:use clojure.contrib.string). I think that should fix it.
>
> Damon
>
> On Jun 16, 12:16 pm, octopusgrabbus  wrote:
>
>
>
>
>
>
>
> > What is the proper way to :use clojure contrib so split resolves as a
> > symbol?
>
> > ns test-csv
> >   (:gen-class)
> >   (:import (java.io BufferedReader FileReader StringReader))
> >   (:use clojure-csv.core)
> >   (:use [clojure.contrib.def]))
>
> > (defn process-file [file-name]
> >     (with-open [br (BufferedReader. (FileReader. file-name))]
> >                             (println (split "," (line-seq br)
>
> > (defn -main [& args]
> >   (process-file "resultset.csv"))
>
> > 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: Properly including clojure-contrib

2011-06-16 Thread Damon Snyder
Hi cmn,
I think if you add clojure.contrib.string to your use or simply add
(:use clojure.contrib.string). I think that should fix it.

Damon

On Jun 16, 12:16 pm, octopusgrabbus  wrote:
> What is the proper way to :use clojure contrib so split resolves as a
> symbol?
>
> ns test-csv
>   (:gen-class)
>   (:import (java.io BufferedReader FileReader StringReader))
>   (:use clojure-csv.core)
>   (:use [clojure.contrib.def]))
>
> (defn process-file [file-name]
>     (with-open [br (BufferedReader. (FileReader. file-name))]
>                             (println (split "," (line-seq br)
>
> (defn -main [& args]
>   (process-file "resultset.csv"))
>
> 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