Re: How to read a file into a string up until a line? Any way to make it lazy?

2012-06-22 Thread Walter Tetzner
zy and I'm not seeing it / working with it properly? > > Best, > --Joseph > > On Friday, June 22, 2012 7:30:28 AM UTC-5, Walter Tetzner wrote: >> >> >> >> On Friday, June 22, 2012 8:28:02 AM UTC-4, Walter Tetzner wrote: >>> >>> >>>

Re: How to read a file into a string up until a line? Any way to make it lazy?

2012-06-22 Thread Walter Tetzner
On Friday, June 22, 2012 8:28:02 AM UTC-4, Walter Tetzner wrote: > > > (defn read-records > "Read the data from the given reader as a list of strings, where > each string is made up of multiple lines, separated by // on it's own > line." >

Re: How to read a file into a string up until a line? Any way to make it lazy?

2012-06-22 Thread Walter Tetzner
(defn read-records "Read the data from the given reader as a list of strings, where each string is made up of multiple lines, separated by // on it's own line." [reader] (->> (line-seq reader) (partition-by #{["//"]}) (filter (comp not #{["//"]})) (map (partial apply str

Re: clojure-csv library write-csv examples

2012-06-15 Thread Walter Tetzner
On Friday, June 15, 2012 10:01:24 AM UTC-4, octopusgrabbus wrote: > > The reason why I asked this question is this code looks like it's using > another csv library, so I'm confused. > That's because it is using another csv library: https://github.com/clojure/data.csv. clojure-csv: https://githu

Re: Is there a better way to do this

2012-06-15 Thread Walter Tetzner
> You could just do (vec (mc/find-maps "events")). > Also, to dissoc :_id from each item, do (vec (map #(dissoc % :_id) (mc/find-maps "events"))). -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googleg

Re: Is there a better way to do this

2012-06-15 Thread Walter Tetzner
On Friday, June 15, 2012 9:54:37 AM UTC-4, Joao_Salcedo wrote: > Is the right way? > You could just do (vec (mc/find-maps "events")). Also, using def creates a top-level var. You probably wanted (let [items (mc/find-maps "events")] ...) instead. -- You received this message because you are s

Re: 'dotimes' will not work inside a 'doto'...

2012-06-14 Thread Walter Tetzner
On Thursday, June 14, 2012 8:09:50 AM UTC-4, Jim foo.bar wrote: > > It has to be 'do' instead of 'doto'... > Well, if you want to be able to use doto, you could do something like (doto foo (.bar x) (.baz y) (#(dotimes [i 10] (.zab % g -- You received this message because you are sub

Re: Doseq, map-style

2012-06-09 Thread Walter Tetzner
> > Is there a philosophical difference underlying the syntax difference > (doseq [elem coll] (f coll)) and (each f coll)? > `doseq' is the side-effecty version of `'for', not map. It lets you do things like user> (doseq [x (range 100) :while (< x 20) :when (even? x)]

Re: what is the deal with ArraySeq?

2012-05-16 Thread Walter Tetzner
On Wednesday, May 16, 2012 12:51:15 PM UTC-4, Jim foo.bar wrote: > > I guess what I'm asking is at which point does the array become an > ArraySeq and why casting it back to a double array with 'doubles' doesn't > work? > Can you post the whole stack trace? -Walter -- You received this mess

Re: what is the deal with ArraySeq?

2012-05-16 Thread Walter Tetzner
On Wednesday, May 16, 2012 12:34:08 PM UTC-4, Jim foo.bar wrote: > --- > > > (defn normalize > [data high-end low-end] > (let [norm (NormalizeArray.)] > (do (. norm setNormalizedHigh high-end) >

Re: docstrings of if-let and when-let incorrect

2012-05-16 Thread Walter Tetzner
On Wednesday, May 16, 2012 9:16:29 AM UTC-4, Aaron Cohen wrote: > > Saying something is obvious and then using the word monad a paragraph > later is contradictory. ;) > > What should happen on the else branch of the if-let; which bindings are in > scope and what would be their values? > > None of

Re: docstrings of if-let and when-let incorrect

2012-05-16 Thread Walter Tetzner
> > On Wednesday, May 16, 2012 9:01:49 AM UTC-4, Stuart Sierra wrote:How would > multiple bindings for if-let or when-let work? Should every binding be > testedd? Should they be and-ed together? Should it short-circuit if the > first is false? > > I don't think there are obvious answers to thos

Re: docstrings of if-let and when-let incorrect

2012-05-15 Thread Walter Tetzner
On Tuesday, May 15, 2012 3:41:58 PM UTC-4, Dan Cross wrote: > > My own personal opinion is that it makes sense in combination with 'and', > but others may feel differently. E.g., > > (when-let [a (allocate-thing) b (read-into-thing a) c > (extract-something-from-thing b)] > (do-somethi

Re: docstrings of if-let and when-let incorrect

2012-05-15 Thread Walter Tetzner
On Tuesday, May 15, 2012 3:26:52 PM UTC-4, Aaron Cohen wrote: > > Does the principle of least surprise suggest that multiple bindings be > combined with AND or OR? > > For `when-let', I would expect it to work like nested when-lets: (when-let [x (exp-1) y (exp-2 x) z (exp-

Re: Defining custom tags using hiccup ?

2012-05-13 Thread Walter Tetzner
You could do this without adding anything to hiccup. If you wrote a function that, say, used walk, you could have it go through the vectors, and replace the custom tags with what they represent. Then you could just call that before calling `html'. (html (transform [:html [:head

Re: Defining custom tags using hiccup ?

2012-05-12 Thread Walter Tetzner
On Saturday, May 12, 2012 10:36:35 PM UTC-4, James Reeves wrote: > That seems more complicated, IMO. Why require an custom macro system > when normal functions do the same job? What's the advantage? > The same reason hiccup uses data structures to represent HTML instead of using nested function

Re: [ANN] Exploding Fish: A URI Library for Clojure

2012-05-12 Thread Walter Tetzner
> Second thing is your (ns ..) declarations. > I've updated it to use :require instead of :use. -- 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 moder

Re: [ANN] Exploding Fish: A URI Library for Clojure

2012-05-12 Thread Walter Tetzner
On Saturday, May 12, 2012 6:28:14 PM UTC-4, Moritz Ulrich wrote: > > Have you seen the recent buzz about java.net.URL's hashCode depending > on the state of the internet[1]? > Can Exploding Fish do something about this annoyance? > > [1]: > http://michaelscharf.blogspot.de/2006/11/javaneturlo

Re: [ANN] Exploding Fish: A URI Library for Clojure

2012-05-11 Thread Walter Tetzner
> It looks like you have written a little mini-library for creating and > working with association lists. Why on earth would you use association > lists instead of mas? The seq representation of a map is basically the > same. > > user=> (seq {"foo" "bar"}) > (["foo" "bar"]) > user=> (into {} (seq

Re: code as data vs. code injection vulnerability

2012-05-09 Thread Walter Tetzner
On Wednesday, May 9, 2012 9:35:57 AM UTC-4, Tassilo Horn wrote: I don't think code-as-data contributes to code injection vulnerability, neither positively nor negatively. Simply don't `eval` code/data from sources you don't trust. I think it does contribute through the reader. If y

Re: code as data vs. code injection vulnerability

2012-05-09 Thread Walter Tetzner
On Wednesday, May 9, 2012 9:35:57 AM UTC-4, Tassilo Horn wrote: > I don't think code-as-data contributes to code injection vulnerability, > neither positively nor negatively. Simply don't `eval` code/data from > sources you don't trust. > I think it does contribute through the reader. If you

Re: [ANN] Exploding Fish: A URI Library for Clojure

2012-05-07 Thread Walter Tetzner
>Provided examples look very much like https://github.com/michaelklishin/urly. Does e-f handle >relative resolution, parsing of broken (technically invalid) URLs? Yes, it handles relative resolution, as well as normalizing paths: user> (normalize-path "http://www.test.net/some/uri/../path/./her

[ANN] Exploding Fish: A URI Library for Clojure

2012-05-06 Thread Walter Tetzner
I've written a URI library for Clojure, whose functions work on a custom Uri type, java.net.URI, java.net.URL, and java.lang.String. It's intended to make working with URIs less painful. It makes it easy to get at the pieces of a URI, as well as doing functional updates. In particular, it makes it

Exploding Fish: A URI Library for Clojure

2012-05-06 Thread Walter Tetzner
I've written a URI library for Clojure, whose functions work on a custom Uri type, java.net.URI, java.net.URL, and java.lang.String. The source and some documentation (in the README) can be found at https://github.com/wtetzner/exploding-fish. Example usage: user> (scheme "http://www.example.com/