Access denied with clojure.java.io/copy

2012-07-08 Thread Pierre-Henry Perret

Using *clojure.java.io/copy *I get the following output:

___
Exception in thread "main" java.io.FileNotFoundException: 
.lein-git-deps\project\cljs-src (Access denied) (NO_SOURCE_FILE:0


The sources files are in *lein-git-deps\project\cljs-sr *and destination in 
a *src*/*app *in the same root projet directory.

No idea what originate that message, because all files are present and the 
app is not running while doing the copy.

Any suggestion welcomed.
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: mutual reference in FP style

2012-07-08 Thread Timo Mihaljov
On 07/06/2012 09:54 PM, Mark Engelberg wrote:
> You basically have two choices.
> 
> Choice 1, give names to each of your nodes, and link names to names.
> (def cycle {:a {:value 2, :link :b}, :b {:value 3, :link :a}}
> 
> Choice 2, use one of Clojure's reference types
> (def a (ref {:value 2}))
> (def b (ref {:value 3}))
> (dosync (alter a assoc :link b) (alter b assoc :link a))

I think promises are a great fit for this use case, as the result is
immutable.

;; Don't try to print all of the infinite data structure.
(set! *print-level* 20)

(let [a (promise)
  b (promise)]
  (deliver a {:b b})
  (deliver b {:a a})
  (pprint @a))

; {:b
;  #}>}>}>}>}>}
;= nil

-- 
Timo


-- 
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: mutual reference in FP style

2012-07-08 Thread Timo Mihaljov
On 07/08/2012 01:37 PM, Timo Mihaljov wrote:
> I think promises are a great fit for this use case, as the result is
> immutable.

I should have read the original question more closely. Promises are
great for mutual references in static graphs, but updating parts of the
graph will be easier with the other solutions provided in this thread.

-- 
Timo


-- 
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 clojure-csv with large files

2012-07-08 Thread Timothy Washington
Hi there,

I'm trying out the
Clojure-csvlib. But I
run out of heap space when trying to parse a large CSV file. So
this call should return a lazy sequence.

(csv/parse-csv (io/reader "*125Mfile.csv*"))



Instead, I get a "*java.lang.OutOfMemoryError: Java heap space*". Is there
a way to get that lazy sequence before reading in the entire file? I can't
see one, when looking at the
code
.


Thanks in advance
Tim

-- 
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: critique my code!

2012-07-08 Thread William Morgan
Excerpts from Alex Robbins's message of 2012-07-06 05:27:28 -0700:
> Reading through your code, many of your functions have large cond or
> condp clauses. Sometimes those can be replaced with multimethods.

Thanks, that's good to know. I think in this case the large condp
switches are part and parcel of fact that it's lexing and parsing
strings. If they get too large I may refactor into multimethods.

I was really hoping for some Clojure experts to weigh in on these
style questions below. Anyone?

(E.g. surely people don't use the repl with single-line uninformative
error messages... what am I doing wrong?)

> > - What's a good way to signal errors (e.g. parse errors)? I found the
> > slingshot library, which seemed to provide nice exceptions, but I'm a
> > little leery of pulling in a non-stdlib library just for this. Is
> > there a more standard way to signal exceptional circumstances?
> >
> > - Once a template is compiled, rather than relying on structs or hashes
> > to provide data, I used dynamic bindings. So you can provide a
> > function that fills in the data. Is this a good idea or a bad one?
> > (See example 1.)
> >
> > - A lot of the iteration code seemed to naturally take the form:
> > (defn whatever [args]
> >   (let [new-args
> >  (some complicated stuff)]
> > (recur new-args)))
> >
> > So all the complicated code is indented 9 spaces from the function
> > declaration right off the bat. Is there a better way to structure
> > things so that I get a little more breathing room?
> >
> > - I'm happy developing from the repl, but debugging was often painful.
> > I would get a one-line error message about e.g. an arity mismatch,
> > with no stacktrace and no way to tell where the error occurred. I see
> > references to third-party tracing libraries. Is this what people use?
> > Is there really no stacktrace available when you an error happens?
> >
> > Thanks for any advice!
> >
> > --
> > William
> >
> > --
> > 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
> 

-- 
William 

-- 
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 with large files

2012-07-08 Thread Denis Labaye
Hi,

I would try something like (untested):

(map parse-csv
 (line-seq (clojure.java.io/reader "/tmp/foo.csv")))

But it will break for CSV cells with newlines like:
a  ; b
foo;"bar
baz"
x  ; z

interesting ...

Denis


On Sun, Jul 8, 2012 at 6:34 PM, Timothy Washington wrote:

> Hi there,
>
> I'm trying out the 
> Clojure-csvlib. But I run out 
> of heap space when trying to parse a large CSV file. So
> this call should return a lazy sequence.
>
> (csv/parse-csv (io/reader "*125Mfile.csv*"))
>
>
>
> Instead, I get a "*java.lang.OutOfMemoryError: Java heap space*". Is
> there a way to get that lazy sequence before reading in the entire file? I
> can't see one, when looking at the 
> code
> .
>
>
> Thanks in advance
> Tim
>
>  --
> 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: Using clojure-csv with large files

2012-07-08 Thread David Santiago
Yeah, CSV files can have embedded newlines, so you can't just split it
up on linebreaks and expect it to work, you need to send them through
a parser.

parse-csv *is* lazy, so my question is, are you doing this at the
repl, exactly as you wrote? If so, it will lazily parse the file, and
then print that sequence to the repl output, which will consume the
whole sequence, causing it to all be in memory at once, and the
exception you got. It's the same problem as if you do (repeat 10) at
the repl.

If you are instead consuming it lazily (by say assigning it to a
variable and processing it in some way that only consumes as much as
you need of it, or using a function that processes a lazy seq a piece
at a time), then there is a bug in the library, and I'd appreciate it
if you file an issue for me on the repo so we can get it sorted out
ASAP.

   David

On Sun, Jul 8, 2012 at 10:39 AM, Denis Labaye  wrote:
> Hi,
>
> I would try something like (untested):
>
> (map parse-csv
>  (line-seq (clojure.java.io/reader "/tmp/foo.csv")))
>
> But it will break for CSV cells with newlines like:
> a  ; b
> foo;"bar
> baz"
> x  ; z
>
> interesting ...
>
> Denis
>
>
> On Sun, Jul 8, 2012 at 6:34 PM, Timothy Washington 
> wrote:
>>
>> Hi there,
>>
>> I'm trying out the Clojure-csv lib. But I run out of heap space when
>> trying to parse a large CSV file. So this call should return a lazy
>> sequence.
>>
>> (csv/parse-csv (io/reader "125Mfile.csv"))
>>
>>
>>
>> Instead, I get a "java.lang.OutOfMemoryError: Java heap space". Is there a
>> way to get that lazy sequence before reading in the entire file? I can't see
>> one, when looking at the code.
>>
>>
>> Thanks in advance
>> Tim
>>
>> --
>> 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


Can I examine the state of a Clojure lazy sequence?

2012-07-08 Thread Larry Travis
(1) Is there any way I can extract from a Clojure lazy sequence at some 
given point in its use those of its members that have so far been 
realized? For example, can I extract the cache of realized members, turn 
it into a vector, and then process that vector independently of further 
use of the lazy sequence?


(2) If I can't extract the cache, is there some way that I can at least 
discover how many realized sequence members have so far been put into 
the cache?


It is obvious that, if all I want is an initial segment of a lazy 
sequence, I can force the initial segment's realization and get hold of 
it for further processing (independent of its source) with the take 
function -- but I want to know how many and what members of the lazy 
sequence have so far been realized independently of my forcing their 
realization -- for example, in order to evaluate and compare success so 
far of alternative solution paths being simultaneously pursued by an AI 
algorithm.


Thanks in advance for any relevant advice.
  --Larry

--
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 with large files

2012-07-08 Thread Sean Corfield
On Sun, Jul 8, 2012 at 9:34 AM, Timothy Washington  wrote:
> I'm trying out the Clojure-csv lib. But I run out of heap space when trying
> to parse a large CSV file. So this call should return a lazy sequence.
>
> (csv/parse-csv (io/reader "125Mfile.csv"))

If you are consuming the CSV lazily, you should be able to parse very
large files. At World Singles, we use clojure-csv to parse PowerMTA
logfiles in excess of 400Mb every day (about 1m rows).
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.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: POST not working with compojure 1.1.0 and ring-jetty-adapter 1.1.0

2012-07-08 Thread ArturoH
Worked like a charm, thank you James

On Saturday, July 7, 2012 5:42:43 PM UTC-5, James Reeves wrote:
>
> On 7 July 2012 23:24, ArturoH  wrote: 
> > I'm not sure that I am having a version problem but this very simple 
> example 
> > does not work for me. I get the POST form but when I subit the POST back 
> I 
> > do not see the variable content just a simple "The message was ::". I 
> run it 
> > with "lein run". Any help will be greatly appreciated. 
>
> You haven't added middleware to handle the parameters. You can do this 
> manually: 
>
>   (use 'ring.middleware.params) 
>   (def app (wrap-params example)) 
>
> But there's a helper function in Compojure that adds a bunch of common 
> middleware for you: 
>
>   (require '[compojure.handler :as handler]) 
>   (def app (handler/site example)) 
>
> - James 
>

-- 
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 with large files

2012-07-08 Thread Dustin Getz
what are you doing with the return value of csv/parse-csv?

-- 
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

[ANN] timing is a timing library for clojure

2012-07-08 Thread Sun Ning
Hi, I just worked on timing clojure function calls. As you know, the 
built-in (time) macro is pretty good. But there's even better solutions 
in Java, called perf4j. perf4j logs call time with a configurable 
logger. And you can use log4j appenders to aggregate the data into some 
sorts of reports.


Then I created this library called "timing" that wraps perf4j, and to be 
clojure friendly. With timing, you can define a function that to be timed:


(defn-timed look-up-something-from-the-moon []
 ...)

or wrap a predefined function to be a timed one:

(let [timed-flight (timed-fn fly-me-to-the-moon)]
  (timed-flight...))

or just wrap a sets of forms:

(timed "the-timer-tag"
  (look-up ...)
  (look-up-again ...)
  ...)

You can find more information on the github page: 
https://github.com/sunng87/timing

and perf4j developer guide: http://perf4j.codehaus.org/devguide.html

Let me know if you have any ideas or questions.

--
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 with large files

2012-07-08 Thread Timothy Washington
Hmm, these are all good points. My source file just returns the sequence
(as in *src.clj*). I have a midje test file (*test.clj*) that just asserts
that it exists.

*src.clj *


(ns my-ns ... )

(defn load-config []

  (let [config (load-file "etc/config.clj")
dname (-> config :data :test)]
(csv/parse-csv (io/reader dname))
  )
)



*test.clj*


(fact "load config training file; ensure first tickis as expected"
  (config/load-config) => truthy
)



Sean and David, you are very correct in that it was midje that was doing
the consuming. If, on the repl, I lazily pull from the seq, then I get the
desired effect.

user> (def thing (config/load-config))

user> (*first* thing)
["Time" "Ask" "Bid" "AskVolume" "BidVolume"]

user> (*second* thing)
["01.05.2012 20:00:00.676" "1.32390" "1.32379" "300.00" "225.00"]



So the question seems to be which test functions let me deal with lazy
sequences in this way. For now, I'm using this:

(fact "load config training file; ensure first tickis as expected"
  (-> (config/load-config) nil? not) => true
)




Cheers all

Tim Washington
Interruptsoftware.ca
416.843.9060



On Sun, Jul 8, 2012 at 7:50 PM, Dustin Getz  wrote:

> what are you doing with the return value of csv/parse-csv?
>
>  --
> 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: Can I examine the state of a Clojure lazy sequence?

2012-07-08 Thread Tassilo Horn
Larry Travis  writes:

Hi Larry,

> (1) Is there any way I can extract from a Clojure lazy sequence at
> some given point in its use those of its members that have so far been
> realized? For example, can I extract the cache of realized members,
> turn it into a vector, and then process that vector independently of
> further use of the lazy sequence?

I think, you are looking for `realized?`.  Here's a function for
creating a vector of realized elements of a lazy seq.

--8<---cut here---start->8---
user> (defn realized-vec [s]
(loop [s s, r []]
   (if (and (seq s) (realized? (rest s)))
  (recur (rest s) (conj r (first s)))
  (conj r (first s)
#'user/realized-vec
user> (def nums (iterate inc 0))
#'user/nums
user> (realized-vec nums)
[0]
user> (take 10 nums)
(0 1 2 3 4 5 6 7 8 9)
user> (realized-vec nums)
[0 1 2 3 4 5 6 7 8 9]
user> (take 15 nums)
(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14)
user> (realized-vec nums)
[0 1 2 3 4 5 6 7 8 9 10 11 12 13 14]
--8<---cut here---end--->8---

One thing I don't quite understand is why you cannot call `realized?` on
all sequential things.  For example, `iterate` is documented to return a
lazy seq, but in fact it creates a Cons whose rest is a lazy seq.  Thus,
calling `realized?` on its result errors.

--8<---cut here---start->8---
user> (realized? (iterate inc 1))
; clojure.lang.Cons cannot be cast to clojure.lang.IPending
;  [Thrown class java.lang.ClassCastException]
--8<---cut here---end--->8---

So my question is: shouldn't all sequential collections implement
IPending (simply returning true in the case of lists, cons, vector,
...)?  Or should `realized?` also test for IPending?

> (2) If I can't extract the cache, is there some way that I can at
> least discover how many realized sequence members have so far been put
> into the cache?

With the function above, that's (comp count realized-vec).

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