Re: [ANN] Skyscraper 0.2.0, a library for scraping entire websites

2015-10-03 Thread Daniel Janus
Skyscraper 0.2.0 has been released.  New in this release:

   - Skyscraper now supports pluggable cache backends.
   - The caching mechanism has been completely overhauled and Skyscraper no 
   longer creates temporary files when the HTML cache is disabled.
   - Support for capturing scraping results to CSV via scrape-csv.
   - Support for updating existing scrapes: new processor flag :updatable, 
   scrape now has an :update option.
   - New scrape option: :retries.
   - Fixed a bug whereby scraping huge datasets would result in an 
   OutOfMemoryError. (scrape no longer holds onto the head of the lazy seq 
   it produces).

Skyscraper's home is at https://github.com/nathell/skyscraper/ .

There is also a satellite project, skyscraper-cache-mapdb, which implements 
a MapDB backend for Skyscraper. skyscraper-cache-mapdb has just been 
released as version 0.1.0 to Clojars and the code is available at:

https://github.com/nathell/skyscraper-cache-mapdb/

Happy scraping,

-dj

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: cond->: Using of threading expression in tests?

2015-10-03 Thread ru
So am I! Sean, can you share code for condp->> too, please.

пятница, 2 октября 2015 г., 17:49:28 UTC+3 пользователь ru написал:
>
> Hi,
>
> Can I use in tests threading expression of cond->, and how?
>
> Thanx in advance,
>   Ru
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Help with macro.

2015-10-03 Thread gianluca torta
Hi,

the behavior you describe is not specific to macros, but is due to the use 
of aliases

after:
(require '[foo.bar :as b])

this will give you false:
(= 'foo.bar/x (first '(b/x)))

while this will give you true:
(= 'foo.bar/x (first '(foo.bar/x)))

one way to solve it, is comparing the resolved vars instead of the names:
(= (resolve 'foo.bar/x) (resolve (first '(b/x
;=>true
(= (resolve 'foo.bar/x) (resolve (first '(foo.bar/x
;=>true

hth,
Gianluca


On Saturday, October 3, 2015 at 3:03:49 PM UTC+2, Andrey Antukh wrote:
>
> Hi!
>
> I have a little trouble writing a macro because I'm getting unexpected 
> (for me) behavior.
>
> Let see some code:
>
> (ns foo.bar)
>
> (defn debug
>   [x]
>   (println "debug:" x)
>   x)
>
> (defn debug-expr?
>   [expr]
>   (and (seq? expr)
>(symbol? (first expr))
>*(= 'foo.bar/debug  (first expr))*))
>
> (defmacro without-debug
>   [& body]
>   (let [body' (reduce (fn [acc v]
> (if (debug-expr? v)
>   (conj acc (second v))
>   (conj acc v)))
>   [] body)]
> `(do
>~@body')))
>
>
> And then I use it from other namespace:
>
> (ns foo.baz)
>
> (require '[foo.bar :as b])
>
> (macroexpand '(b/without-debug (b/debug 3)))
> ;; => (do (b/debug 3))
>
> (macroexpand '(b/without-debug (foo.bar/debug 3)))
> ;; =>(do 3)
>   
> I expect that the both expressions will evaluate to the same result, but 
> is not. Seems that symbols inside macros are not fully qualified. It there 
> any way to get them fully qualified? I'm missing something?
>
> Any help is welcome!
>
> Thank you very much.
>
> Andrey
> -- 
> Andrey Antukh - Андрей Антух - 
> http://www.niwi.nz
> https://github.com/niwinz
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Help with macro.

2015-10-03 Thread Andrey Antukh
On Sat, Oct 3, 2015 at 5:24 PM, gianluca torta  wrote:

> Hi,
>
> the behavior you describe is not specific to macros, but is due to the use
> of aliases
>
> after:
> (require '[foo.bar :as b])
>
> this will give you false:
> (= 'foo.bar/x (first '(b/x)))
>
> while this will give you true:
> (= 'foo.bar/x (first '(foo.bar/x)))
>
> one way to solve it, is comparing the resolved vars instead of the names:
> (= (resolve 'foo.bar/x) (resolve (first '(b/x
> ;=>true
> (= (resolve 'foo.bar/x) (resolve (first '(foo.bar/x
> ;=>true
>
>
Yes, your solution works, but only on clojure. ClojureScript doesn't have
`resolve`. It there any portable solution?

Thanks!

Andrey


> hth,
> Gianluca
>
>
>
> On Saturday, October 3, 2015 at 3:03:49 PM UTC+2, Andrey Antukh wrote:
>
>> Hi!
>>
>> I have a little trouble writing a macro because I'm getting unexpected
>> (for me) behavior.
>>
>> Let see some code:
>>
>> (ns foo.bar)
>>
>> (defn debug
>>   [x]
>>   (println "debug:" x)
>>   x)
>>
>> (defn debug-expr?
>>   [expr]
>>   (and (seq? expr)
>>(symbol? (first expr))
>>*(= 'foo.bar/debug  (first expr))*))
>>
>> (defmacro without-debug
>>   [& body]
>>   (let [body' (reduce (fn [acc v]
>> (if (debug-expr? v)
>>   (conj acc (second v))
>>   (conj acc v)))
>>   [] body)]
>> `(do
>>~@body')))
>>
>>
>> And then I use it from other namespace:
>>
>> (ns foo.baz)
>>
>> (require '[foo.bar :as b])
>>
>> (macroexpand '(b/without-debug (b/debug 3)))
>> ;; => (do (b/debug 3))
>>
>> (macroexpand '(b/without-debug (foo.bar/debug 3)))
>> ;; =>(do 3)
>>
>> I expect that the both expressions will evaluate to the same result, but
>> is not. Seems that symbols inside macros are not fully qualified. It there
>> any way to get them fully qualified? I'm missing something?
>>
>> Any help is welcome!
>>
>> Thank you very much.
>>
>> Andrey
>> --
>> Andrey Antukh - Андрей Антух - 
>> http://www.niwi.nz
>> https://github.com/niwinz
>>
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Andrey Antukh - Андрей Антух - 
http://www.niwi.nz
https://github.com/niwinz

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Where do I find javadoc for clojure interfaces?

2015-10-03 Thread Stuart Sierra
Interfaces like ISeq are internal details of Clojure's implementation. 
They're not part of the public API, so there is no guarantee that they 
won't change in future releases.

–S


On Thursday, October 1, 2015 at 4:59:12 AM UTC-4, crocket wrote:
>
> http://clojure.github.io/clojure/javadoc/ doesn't expost interfaces like 
> clojure.lang.ISeq, so when I refer to such interfaces, I have to download 
> clojure javadoc from maven.
> I'd like to refer to those interface on web browsers. Why are they not 
> exposed on the web?
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Help with macro.

2015-10-03 Thread Andrey Antukh
Hi!

I have a little trouble writing a macro because I'm getting unexpected (for
me) behavior.

Let see some code:

(ns foo.bar)

(defn debug
  [x]
  (println "debug:" x)
  x)

(defn debug-expr?
  [expr]
  (and (seq? expr)
   (symbol? (first expr))
   *(= 'foo.bar/debug  (first expr))*))

(defmacro without-debug
  [& body]
  (let [body' (reduce (fn [acc v]
(if (debug-expr? v)
  (conj acc (second v))
  (conj acc v)))
  [] body)]
`(do
   ~@body')))


And then I use it from other namespace:

(ns foo.baz)

(require '[foo.bar :as b])

(macroexpand '(b/without-debug (b/debug 3)))
;; => (do (b/debug 3))

(macroexpand '(b/without-debug (foo.bar/debug 3)))
;; =>(do 3)

I expect that the both expressions will evaluate to the same result, but is
not. Seems that symbols inside macros are not fully qualified. It there any
way to get them fully qualified? I'm missing something?

Any help is welcome!

Thank you very much.

Andrey
-- 
Andrey Antukh - Андрей Антух - 
http://www.niwi.nz
https://github.com/niwinz

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


macroexpand and syntax-quote

2015-10-03 Thread bentav
Common Lisp:

(defmacro foo () 
  `(defmacro bar () 
`(baz)))

(macroexpand-1 '(foo)) 

=> (DEFMACRO BAR () `(BAZ))




Clojure:

(defmacro foo [] 
  `(defmacro bar [] 
`(baz)))

(macroexpand-1 '(foo))

=> (clojure.core/defmacro user/bar [] (clojure.core/seq 
(clojure.core/concat (clojure.core/list (quote user/baz)


Looks awful. Is it possible to do something about that?

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Origin for Clojure using the term 'vector' instead of 'array'?

2015-10-03 Thread Tj Gabbour
Yep:

https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html
https://docs.oracle.com/javase/7/docs/api/java/util/Vector.html

“The Vector class implements a growable array of objects. Like an array, it 
contains components that can be accessed using an integer index. However, 
the size of a Vector can grow or shrink as needed to accommodate adding and 
removing items after the Vector has been created.”



On Saturday, October 3, 2015 at 9:32:13 AM UTC+2, Gary Verhaegen wrote:
>
> For people with a C/Java-style background, array typically designates a 
> contiguous piece of memory that has been allocated at once, is thus 
> fixed-size, and can be accessed randomly (i.e. by index). Vectors are 
> typically structures or objects at a higher level, that still present a 
> random-access collection, but can also for example change size.
>
> With that Background, Clojure's choice makes perfect sense. Please also 
> consider that Clojure does not use vector instead of array, but in addition 
> to; see make-array, geta, seta, et al.
>
> On Saturday, 3 October 2015, Mars0i  
> wrote:
>
>> I have no idea about the official reason, but outside of certain 
>> programming languages that use "array" for one-dimensional data structures, 
>> an array often has two (or more) dimensions.  In R, for example, arrays can 
>> have an arbitrary number of dimensions.  Honestly, when I'm away from Java 
>> for a while and then encounter the term "array" in Java, I have to stop and 
>> remember that it's 1-D, or check some documentation, because "array" 
>> doesn't automatically mean 1-D to me.
>>
>> On the other hand, I believe that vectors are always one-dimensional, as 
>> in linear algebra.
>>
>> So maybe Rich Hickey just decided that "vector" was a better, less 
>> ambiguous name.
>>
>> -- 
>> 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 unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Origin for Clojure using the term 'vector' instead of 'array'?

2015-10-03 Thread Erik Price
I always assumed it was because vectors have similar properties to the
classic java.util.Vector: they’re variable-length, contain heterogenous
objects accessible by integer index, and safe for concurrent access from
multiple threads:
http://docs.oracle.com/javase/7/docs/api/java/util/Vector.html

e
​

On Fri, Oct 2, 2015 at 11:46 PM, Mars0i  wrote:

> I have no idea about the official reason, but outside of certain
> programming languages that use "array" for one-dimensional data structures,
> an array often has two (or more) dimensions.  In R, for example, arrays can
> have an arbitrary number of dimensions.  Honestly, when I'm away from Java
> for a while and then encounter the term "array" in Java, I have to stop and
> remember that it's 1-D, or check some documentation, because "array"
> doesn't automatically mean 1-D to me.
>
> On the other hand, I believe that vectors are always one-dimensional, as
> in linear algebra.
>
> So maybe Rich Hickey just decided that "vector" was a better, less
> ambiguous name.
>
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


newbie question: how to selectively iterate through a tree of directories ?

2015-10-03 Thread hpwei01


Under linux, I have a tree of directories like this:

/path/top

/path/top/dir1  (in here there are two files f1, f2)

/path/top/dir2 -> /another-path/dir2 (a symbolic link) 

 and under /another-path/dir2 there are two files g1, g2

If I use below code, I would get a list of files f1, f2, and g1, g2

(def directory (clojure.java.io/file "/path/top"))(def files 
(for [file (file-seq directory)] (.getName file)))(files)

BUT I want to skip traversing the directory dir2 since it is a symbolic link.

i.e. the list of files that I want to get is f1, f2 only.

Could you please suggest a way to do this ?

THanks

HP

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: newbie Q: how to tweak file-seq (original: how to selectively iterate through a tree of directories) ?

2015-10-03 Thread hpwei01
The directory structure is
   /path/top/dir1
   /path/top/dir1/f1
   /path/top/dir1/f2
   /path/top/dir2 -> /another/path/dir2 
--
   /another/path/dir2/g1
   /another/path/dir2/g2

I tried this (following suggestion):
   
  (for [file (file-seq dir) :while (.isFile file)] (.getPath file))

It prints out a list with following items:
  /path/top/dir1/f1
  /path/top/dir1/f2
  /path/top/dir2/g1
  /path/top/dir2/g2

BUT the last two items are the ones that I do NOT want.
So, I guess I will need to tweak  file-seq so that it will NOT traverse
/path/top/dir2  since it is a symbolic link.

Is there anyway to tweak file-seq ??

THanks
HP

On Saturday, October 3, 2015 at 11:59:40 AM UTC-4, Gary Verhaegen wrote:
>
> I'm on Windows at the moment, so I can't test, but I think you can 
> filter on isFile: 
>
> (for [file (file-seq dir) 
>   :where (.isFile file)] 
>   (.getName file)) 
>
> should work, I think. 
>
> On 3 October 2015 at 07:36,   wrote: 
> > Under linux, I have a tree of directories like this: 
> > 
> > /path/top 
> > 
> > /path/top/dir1  (in here there are two files f1, f2) 
> > 
> > /path/top/dir2 -> /another-path/dir2 (a symbolic link) 
> > 
> >  and under /another-path/dir2 there are two files g1, g2 
> > 
> > If I use below code, I would get a list of files f1, f2, and g1, g2 
> > 
> > (def directory (clojure.java.io/file "/path/top")) 
> > (def files 
> > (for [file (file-seq directory)] (.getName file))) 
> > (files) 
> > 
> > BUT I want to skip traversing the directory dir2 since it is a symbolic 
> > link. 
> > 
> > i.e. the list of files that I want to get is f1, f2 only. 
> > 
> > Could you please suggest a way to do this ? 
> > 
> > THanks 
> > 
> > HP 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Clojure" group. 
> > To post to this group, send email to clo...@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+u...@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 unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to clojure+u...@googlegroups.com . 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: 4clojure count problem

2015-10-03 Thread Michael Blume
Reduce can take either two or three arguments; when it takes two arguments,
it makes some assumptions about the argument that was left out. You're
using reduce with two arguments, so you might want to rethink those
assumptions.

On Sat, Oct 3, 2015 at 2:19 PM Roelof Wobben  wrote:

> Hello,
>
> I have to make a function which counts a collection without using count.
>
> So I came up with this :
>
> (fn [coll]  (reduce (fn [counter _ ] (inc counter)) coll)))
>
> it works well with coll is [ 1 2 3]
>
> but it fails with "Hello World"
>
> How can I improve my code to work in both cases.
>
> Please , do not only give the answer but rather explain how I can make
> this work.
> So I learn a lot and not do only a copy/paste.
>
> Roelof
>
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: macroexpand and syntax-quote

2015-10-03 Thread Gary Verhaegen
This is very much by design. Clojure is somewhere between Common Lisp and
Scheme in terms of macro hygiene.

Being compatible with Common Lisp is explicitly not a goal for Clojure.
Watch out for similarly named functions with different behavior too.

On Saturday, 3 October 2015, bentav  wrote:

> Common Lisp:
>
> (defmacro foo ()
>   `(defmacro bar ()
> `(baz)))
>
> (macroexpand-1 '(foo))
>
> => (DEFMACRO BAR () `(BAZ))
>
>
>
>
> Clojure:
>
> (defmacro foo []
>   `(defmacro bar []
> `(baz)))
>
> (macroexpand-1 '(foo))
>
> => (clojure.core/defmacro user/bar [] (clojure.core/seq
> (clojure.core/concat (clojure.core/list (quote user/baz)
>
>
> Looks awful. Is it possible to do something about that?
>
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Lazy deserialization / reserialization, aatree release 0.3.0

2015-10-03 Thread William la Forge
I've just written the API for 
aatree: https://github.com/laforge49/aatree/wiki/API

Please let me know if anything needs clarification! (I'm way way to close 
to all this, having worked on similar logic for the past several years.)

(We should strive for beauty in the eye of the reader.)

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


4clojure count problem

2015-10-03 Thread Roelof Wobben
Hello, 

I have to make a function which counts a collection without using count.

So I came up with this : 

(fn [coll]  (reduce (fn [counter _ ] (inc counter)) coll)))

it works well with coll is [ 1 2 3] 

but it fails with "Hello World"

How can I improve my code to work in both cases.

Please , do not only give the answer but rather explain how I can make this 
work.
So I learn a lot and not do only a copy/paste.

Roelof

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: cond->: Using of threading expression in tests?

2015-10-03 Thread Oliver Hine
You may also find a use for condas-> which I describe in a mini blog post 
here: http://blog.juxt.pro/posts/condas.html

It combines cond-> and as-> which I find super useful when dealing with 
various fn type signatures.

On Saturday, 3 October 2015 15:59:51 UTC+1, ru wrote:
>
> So am I! Sean, can you share code for condp->> too, please.
>
> пятница, 2 октября 2015 г., 17:49:28 UTC+3 пользователь ru написал:
>>
>> Hi,
>>
>> Can I use in tests threading expression of cond->, and how?
>>
>> Thanx in advance,
>>   Ru
>>
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Origin for Clojure using the term 'vector' instead of 'array'?

2015-10-03 Thread Daniel Barlow
Common Lisp also has multi dimensional arrays and one - dimensional
vectors.  I believe Rich was pretty familiar with that language in a former
life

http://clhs.lisp.se/Body/t_array.htm
On 3 Oct 2015 15:44, "Erik Price"  wrote:

> I always assumed it was because vectors have similar properties to the
> classic java.util.Vector: they’re variable-length, contain heterogenous
> objects accessible by integer index, and safe for concurrent access from
> multiple threads:
> http://docs.oracle.com/javase/7/docs/api/java/util/Vector.html
>
> e
> ​
>
> On Fri, Oct 2, 2015 at 11:46 PM, Mars0i  wrote:
>
>> I have no idea about the official reason, but outside of certain
>> programming languages that use "array" for one-dimensional data structures,
>> an array often has two (or more) dimensions.  In R, for example, arrays can
>> have an arbitrary number of dimensions.  Honestly, when I'm away from Java
>> for a while and then encounter the term "array" in Java, I have to stop and
>> remember that it's 1-D, or check some documentation, because "array"
>> doesn't automatically mean 1-D to me.
>>
>> On the other hand, I believe that vectors are always one-dimensional, as
>> in linear algebra.
>>
>> So maybe Rich Hickey just decided that "vector" was a better, less
>> ambiguous name.
>>
>> --
>> 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 unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: newbie question: how to selectively iterate through a tree of directories ?

2015-10-03 Thread Gary Verhaegen
I'm on Windows at the moment, so I can't test, but I think you can
filter on isFile:

(for [file (file-seq dir)
  :where (.isFile file)]
  (.getName file))

should work, I think.

On 3 October 2015 at 07:36,   wrote:
> Under linux, I have a tree of directories like this:
>
> /path/top
>
> /path/top/dir1  (in here there are two files f1, f2)
>
> /path/top/dir2 -> /another-path/dir2 (a symbolic link)
>
>  and under /another-path/dir2 there are two files g1, g2
>
> If I use below code, I would get a list of files f1, f2, and g1, g2
>
> (def directory (clojure.java.io/file "/path/top"))
> (def files
> (for [file (file-seq directory)] (.getName file)))
> (files)
>
> BUT I want to skip traversing the directory dir2 since it is a symbolic
> link.
>
> i.e. the list of files that I want to get is f1, f2 only.
>
> Could you please suggest a way to do this ?
>
> THanks
>
> HP
>
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Where do I find javadoc for clojure interfaces?

2015-10-03 Thread Daniel Compton
This has come up before
https://groups.google.com/forum/#!topic/clojure/2ZHYa-Bv8UU.

Alex's 
statement on the matter:

> The Clojure internal Java interfaces are certainly intended to allow
library builders to create useful stuff that plays in the Clojure world. I
do not know that anyone has ever said that they are "public", but I
certainly think that any change to a core interface likely to break
external users would be considered very carefully.

I think that documentation on these interfaces would be very helpful. If
they are meant to be private then it would be good to document that too,
it's not obvious to an onlooker that this is the case. I took a look in
JIRA and couldn't find a ticket for this, but it's a hard thing to search
for.

On Sun, Oct 4, 2015 at 3:47 AM Stuart Sierra 
wrote:

> Interfaces like ISeq are internal details of Clojure's implementation.
> They're not part of the public API, so there is no guarantee that they
> won't change in future releases.
>
>
> –S
>
>
>
> On Thursday, October 1, 2015 at 4:59:12 AM UTC-4, crocket wrote:
>>
>> http://clojure.github.io/clojure/javadoc/ doesn't expost interfaces like
>> clojure.lang.ISeq, so when I refer to such interfaces, I have to download
>> clojure javadoc from maven.
>> I'd like to refer to those interface on web browsers. Why are they not
>> exposed on the web?
>>
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
-- 
Daniel

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: java web start and clojure application

2015-10-03 Thread Jason Zwolak
Fantastic!  Thanks for reporting this.  Your work helped me get my 
application working with Clojure code in a webstart environment.

I do have a question about security in relation to step 3 where the Policy 
is set.  Is this the strictest policy that will work with Clojure code 
compiled at runtime?  Does this policy leave an application open to 
security problems?  My interpretation of step 3 is that all class loaders 
now have all-privileges.  This could be a problem if some third party jar, 
which my have been compromised or contain malicious code, creates its own 
class loader and loads arbitrary code from a server.  All this code would 
then have all permissions where it wouldn't have them without step 3.  Is 
my assessment correct?

Thanks,
Jason

On Tuesday, April 22, 2008 at 9:44:27 AM UTC-4, Pawel Ostrowski wrote:
>
> Hello, 
>
> I managed to successfully deploy simple clojure application with java 
> web start. I will share my experience here, because I had some 
> problems with granting enough security privileges to run clojure 
> application as java web start applet (getting AccessControlException) 
> and I did not find complete solution in group's archive. Editing 
> java.policy file was not an option because I wanted to share my 
> application with users who might not understand java policies at all. 
>
> My application is written entirely in clojure except one java class 
> with static main method. This main method looks like this: 
>
>  public static void main(String[] args) throws Exception { 
> RT.init(); 
> // load clj resource 
> loadFromClasspath("alphabet/alphabet.clj"); 
> // get clojure fun 
> StringReader sr = new StringReader("clojure-main"); 
> PushbackReader r = new PushbackReader(sr); 
> IFn clojureFun = (IFn) Compiler.eval(LispReader.read(r, false, 
> null, false)); 
> // call clojure fun 
> clojureFun.invoke(); 
> ... 
>
> So all I do here is: load clojure source file, get clojure main 
> function and then call it. 
>
> To run it as java web start applet I had to: 
>
> 1) Include   element in 
> my .jnlp file. 
> 2) Sign clojure.jar and my application .jar files. Instructions found 
> on http://www.dallaway.com/acad/webstart/ were helpful 
> 3) Put the following code in static section in class with the static 
> main method: 
>
> static { 
> Policy.setPolicy( new Policy() { 
> public PermissionCollection 
> getPermissions(CodeSource codesource) { 
> Permissions perms = new Permissions(); 
> perms.add(new AllPermission()); 
> return(perms); 
> } 
> public void refresh(){ 
> } 
> }); 
> } 
>
> Third step was necessary because all permissions from first step were 
> granted to javaws classloader only and clojure creates it's own 
> classloaders, at least I think so :). 
>
> ps. This is a simple alphabet typing swing application, it measures 
> your time to type whole alphabet. Time starts with typing letter a and 
> ends with letter z. Space resets the game. It may be run with javaws 
> from here: http://www.pasza.org/files/alphabet/alphabet.jnlp 
>
> clojure code may be found in this jar: 
> http://www.pasza.org/files/alphabet/alphabet.jar 
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: 4clojure count problem

2015-10-03 Thread Moe Aboulkheir
Roelof,

Unless supplied with an initial value, reduce will use the first value from
the collection you supply - every sequence which doesn't start with "1"
will give you the wrong answer.

Take care,
Moe

On Sat, Oct 3, 2015 at 9:40 PM, Roelof Wobben 
wrote:

> Hello,
>
> I have to make a function which counts a collection without using count.
>
> So I came up with this :
>
> (fn [coll]  (reduce (fn [counter _ ] (inc counter)) coll)))
>
> it works well with coll is [ 1 2 3]
>
> but it fails with "Hello World"
>
> How can I improve my code to work in both cases.
>
> Please , do not only give the answer but rather explain how I can make
> this work.
> So I learn a lot and not do only a copy/paste.
>
> Roelof
>
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Origin for Clojure using the term 'vector' instead of 'array'?

2015-10-03 Thread Gary Verhaegen
For people with a C/Java-style background, array typically designates a
contiguous piece of memory that has been allocated at once, is thus
fixed-size, and can be accessed randomly (i.e. by index). Vectors are
typically structures or objects at a higher level, that still present a
random-access collection, but can also for example change size.

With that Background, Clojure's choice makes perfect sense. Please also
consider that Clojure does not use vector instead of array, but in addition
to; see make-array, geta, seta, et al.

On Saturday, 3 October 2015, Mars0i  wrote:

> I have no idea about the official reason, but outside of certain
> programming languages that use "array" for one-dimensional data structures,
> an array often has two (or more) dimensions.  In R, for example, arrays can
> have an arbitrary number of dimensions.  Honestly, when I'm away from Java
> for a while and then encounter the term "array" in Java, I have to stop and
> remember that it's 1-D, or check some documentation, because "array"
> doesn't automatically mean 1-D to me.
>
> On the other hand, I believe that vectors are always one-dimensional, as
> in linear algebra.
>
> So maybe Rich Hickey just decided that "vector" was a better, less
> ambiguous name.
>
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.