Re: [ANN] clj-uuid: thread-safe, performant unique identifiers

2015-02-17 Thread danle...@gmail.com
Adding a UUIDNameBytes protocol is an excellent idea.  That is definitely 
something I will look at doing. 

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


Use core.async executor with aleph

2015-02-17 Thread Robin Heggelund Hansen
>From what I can see, aleph allows me to set a executor to handle client 
requests. I'm already using core.async pretty heavily. Is there any reason 
why I shouldn't pass core.async's executor to aleph? I see I can also make 
every client request start on aleph's dispatch thread. Considering 
absolutely every request spawns a go-block, might it even be a good idea to 
not run aleph with an executor at all?

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
--- 
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: datomic <-> datascript transfers

2015-02-17 Thread henry w
For anyone else looking at this option, here is some code which is doing 
the work on the cljs side.

https://gist.github.com/henryw-erudine/73cbcdea1eda150e78da

The server code is straightforward so not included. 

-- 
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: [ANN] clj-uuid: thread-safe, performant unique identifiers

2015-02-17 Thread Steven Deobald
It's always a pleasure to see someone fill these gaps. :) Thanks Dan.

Steven Deobald -- ⌀ -- nilenso.com

On Tue, Feb 17, 2015 at 6:55 AM, danle...@gmail.com 
wrote:

> Hello Clojurians,
>
> I've just been polishing my modest library, clj-uuid <
> http://danlentz.github.io/clj-uuid/> and would like to invite everyone to
> have a look if such a thing might be of interest.
>
> What is it?
>
> clj-uuid is a Clojure library for generation and utilization of UUIDs
> (Universally Unique Identifiers) as described by RFC-4122. This library
> extends the standard Java UUID class to provide true v1 (time based) and
> v3/v5 (namespace based) identifier generation. Additionally, a number of
> useful supporting utilities are provided to support serialization and
> manipulation of these UUIDs in a simple, efficient manner.
>
> Why is it useful?
>
> The JVM UUID class only provides a constructor for random (v4) and
> (non-namespaced) pseudo-v3 UUID's. Where appropriate, this library does use
> the internal JVM UUID implementation. The benefit with this library is that
> clj-uuid provides an easy way to get v1 and true namespaced v3 and v5
> UUIDs.  v1 UUIDs are really useful because they can be generated faster
> than v4's as they don't need to call a cryptographic random number
> generator.  v5 UUID's are necessary because many of the interesting
> things that you can do with UUID's require namespaced identifiers.
> http://danlentz.github.io/clj-uuid/
> http://github.com/danlentz/clj-uuid/
>
>
> Best,
> Dan Lentz
>
> --
> 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.


Performant flattening of nested data structures

2015-02-17 Thread Mark Watson
I want to flatten a map of nested maps/vecs

Currently I'm using the fn's:

(defn- flatten-keys* [a ks m]

  (cond

   (map? m) (reduce into

(map (fn [[k v]]

   (flatten-keys* a (if-not (empty? ks)

  (str ks "." (name k))

  (str "$." (name k))) v)) (seq m)))

   (and (sequential? m)

(not (instance? clojure.lang.MapEntry m))) (reduce into

   (map-indexed (fn 
[idx itm]

  
(flatten-keys* a


 (str ks "[" idx "]")


 itm))

(seq 
m)))

   :else (assoc a ks m)))

(defn flatten-keys [m] (flatten-keys* {} "" m))

(flatten-keys {:name {:first "Rich" :last "Hickey"} :number [1 415 123 4567]})

;; => {"$.number[0]" 1, "$.number[1]" 415, "$.number[2]" 123, "$.number[3]" 
4567, "$.name.first" "Rich", "$.name.last" "Hickey"}


However, I was wondering if anyone had suggestions on a more performant fn?

I have a white-list of possible flattened keys. But, the list is big 
(~1200), and with with most (~95%) of the keys having corresponding vals = 
nil it was much less performant using get-in on every possible key.

Thanks for the help!

-- 
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: Performant flattening of nested data structures

2015-02-17 Thread Mark Watson
A slightly cleaner version:

(defn- flatten-keys* [a ks m]

  (cond

   ;; Is a map?

   (map? m) (reduce into

(map (fn [[k v]]

   (flatten-keys* a (str ks "." (name k)) v))

 (seq m)))

   ;; Is an arr/vec/seq?

   (and (sequential? m)

(not (instance? clojure.lang.MapEntry m))) (reduce into

   (map-indexed (fn 
[idx itm]

  
(flatten-keys* a


 (str ks "[" idx "]")


 itm))

(seq 
m)))

   ;; Is not a collection

   :else (assoc a ks m)))

(defn flatten-keys [m] (flatten-keys* {} "$" m))

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


[ANN] Sweet Liberty: Set Your Data Free with Clojure and REST

2015-02-17 Thread Bill Piel
Blog post: 
https://blog.rjmetrics.com/2015/02/15/sweet-liberty-set-your-data-free-with-clojure-and-rest/


Sweet-Liberty is a library for building database-backed RESTful services 
using Clojure. You can think of it as a means to build and configure 
components that translate between REST and SQL. Or, you might say that it 
helps you wrap a REST interface around a relational database. Besides 
standard CRUD operations (available via appropriate HTTP methods), it also 
supports some other features through query parameters, such as: filtering, 
paging and returning a subset of fields. 


Feedback is welcome and appreciated. 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
--- 
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.


Continuously Integrating Leiningen Projects

2015-02-17 Thread Rick Moynihan
Hi all,

At work, we use Jenkins to continuously integrate our Clojure projects
which are factored into both applications and a small number of
supporting libraries; all of which use Leiningen as their project
build tool.

Leiningen builds each project, and runs its tests; and then if they
pass it lein installs the project jar into the local ~/.m2 repo and
triggers any dependent builds to start.  The dependencies then start
building and pick up the latest SNAPSHOT build from the ~/.m2
directory.

This works ok; but it has a relatively major flaw, which is that just
because a project passes its local tests; it doesn't mean that it
hasn't broken an upstream library.  When this happens the broken
library is left in the shared ~/.m2 directory - breaking other builds
and generally lying around causing havoc.

Fortunately this rarely happens in practice; but it is a potential
cause of hard to diagnose (unrepeatable build) problems - especially
when using snapshot builds - which is what I think we want to use for
tracking branches until we

We currently use the Jenkins leiningen plugin, but I don't think it
supports a more sophisticated setup than this.

I was wondering if anyone with experience of running robust CI builds
(with Jenkins) might have any ideas about to solve this in a more
robust manner??

Many thanks,

Rick
--
http://twitter.com/RickMoynihan

-- 
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: Continuously Integrating Leiningen Projects

2015-02-17 Thread Michael Blume
What we do at Climate is avoid SNAPSHOT builds. Every build gets a version
string with timestamp and git commit. If an upstream library is changed,
it's up to downstream maintainers to update their dependency on it. If you
update a dependency and your build fails, you a) don't update your
dependency just yet b) complain to the library maintainer that their new
version breaks your project.

On Tue Feb 17 2015 at 9:51:18 AM Rick Moynihan 
wrote:

> Hi all,
>
> At work, we use Jenkins to continuously integrate our Clojure projects
> which are factored into both applications and a small number of
> supporting libraries; all of which use Leiningen as their project
> build tool.
>
> Leiningen builds each project, and runs its tests; and then if they
> pass it lein installs the project jar into the local ~/.m2 repo and
> triggers any dependent builds to start.  The dependencies then start
> building and pick up the latest SNAPSHOT build from the ~/.m2
> directory.
>
> This works ok; but it has a relatively major flaw, which is that just
> because a project passes its local tests; it doesn't mean that it
> hasn't broken an upstream library.  When this happens the broken
> library is left in the shared ~/.m2 directory - breaking other builds
> and generally lying around causing havoc.
>
> Fortunately this rarely happens in practice; but it is a potential
> cause of hard to diagnose (unrepeatable build) problems - especially
> when using snapshot builds - which is what I think we want to use for
> tracking branches until we
>
> We currently use the Jenkins leiningen plugin, but I don't think it
> supports a more sophisticated setup than this.
>
> I was wondering if anyone with experience of running robust CI builds
> (with Jenkins) might have any ideas about to solve this in a more
> robust manner??
>
> Many thanks,
>
> Rick
> --
> http://twitter.com/RickMoynihan
>
> --
> 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: Continuously Integrating Leiningen Projects

2015-02-17 Thread Michael Blume
Related -- we run lein ancient as part of a lot of our builds so that we
can easily pick up dependencies with newer available versions.

On Tue Feb 17 2015 at 11:13:44 AM Michael Blume 
wrote:

> What we do at Climate is avoid SNAPSHOT builds. Every build gets a version
> string with timestamp and git commit. If an upstream library is changed,
> it's up to downstream maintainers to update their dependency on it. If you
> update a dependency and your build fails, you a) don't update your
> dependency just yet b) complain to the library maintainer that their new
> version breaks your project.
>
> On Tue Feb 17 2015 at 9:51:18 AM Rick Moynihan 
> wrote:
>
>> Hi all,
>>
>> At work, we use Jenkins to continuously integrate our Clojure projects
>> which are factored into both applications and a small number of
>> supporting libraries; all of which use Leiningen as their project
>> build tool.
>>
>> Leiningen builds each project, and runs its tests; and then if they
>> pass it lein installs the project jar into the local ~/.m2 repo and
>> triggers any dependent builds to start.  The dependencies then start
>> building and pick up the latest SNAPSHOT build from the ~/.m2
>> directory.
>>
>> This works ok; but it has a relatively major flaw, which is that just
>> because a project passes its local tests; it doesn't mean that it
>> hasn't broken an upstream library.  When this happens the broken
>> library is left in the shared ~/.m2 directory - breaking other builds
>> and generally lying around causing havoc.
>>
>> Fortunately this rarely happens in practice; but it is a potential
>> cause of hard to diagnose (unrepeatable build) problems - especially
>> when using snapshot builds - which is what I think we want to use for
>> tracking branches until we
>>
>> We currently use the Jenkins leiningen plugin, but I don't think it
>> supports a more sophisticated setup than this.
>>
>> I was wondering if anyone with experience of running robust CI builds
>> (with Jenkins) might have any ideas about to solve this in a more
>> robust manner??
>>
>> Many thanks,
>>
>> Rick
>> --
>> http://twitter.com/RickMoynihan
>>
>> --
>> 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: Performant flattening of nested data structures

2015-02-17 Thread Ivan L
i wasn't able to squeeze that much more out of it, informally maybe around 
10% as it gets larger.

(defn- flx 
  ([obj] (flx obj ["$"] {}))
  ([obj curr res]
(cond
  (map? obj)
  (reduce 
#(flx (%2 obj) (conj curr (str "." (name %2))) %1) 
res 
(keys obj))
  (sequential? obj)
  (reduce 
#(flx (second %2) (conj curr (str "[" (first %2) "]")) %1) 
res 
(map #(identity (list %1 %2)) (range (count obj)) obj))
  :else
  (assoc res (apply str curr) obj


On Tuesday, February 17, 2015 at 11:18:58 AM UTC-5, Mark Watson wrote:
>
> A slightly cleaner version:
>
> (defn- flatten-keys* [a ks m]
>
>   (cond
>
>;; Is a map?
>
>(map? m) (reduce into
>
> (map (fn [[k v]]
>
>(flatten-keys* a (str ks "." (name k)) v))
>
>  (seq m)))
>
>;; Is an arr/vec/seq?
>
>(and (sequential? m)
>
> (not (instance? clojure.lang.MapEntry m))) (reduce into
>
>(map-indexed (fn 
> [idx itm]
>
>   
> (flatten-keys* a
>
>   
>(str ks "[" idx "]")
>
>   
>itm))
>
> (seq 
> m)))
>
>;; Is not a collection
>
>:else (assoc a ks m)))
>
> (defn flatten-keys [m] (flatten-keys* {} "$" m))
>
>

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


Removing the 5th, 10th, 15th ... element of a list

2015-02-17 Thread Cecil Westerhof
What is the best way to remove all elements which position (counting from
1) is a multiply of five out of a list?

So the list:
(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21)
​becomes:
(1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21)​

-- 
Cecil Westerhof

-- 
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: Removing the 5th, 10th, 15th ... element of a list

2015-02-17 Thread Ivan L
this works

=> (filter #(not= (mod % 5) 0) (range 22))
(1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21)


On Tuesday, February 17, 2015 at 2:21:20 PM UTC-5, Cecil Westerhof wrote:
>
> What is the best way to remove all elements which position (counting from 
> 1) is a multiply of five out of a list?
>
> So the list:
> (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21)
> ​becomes:
> (1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21)​
>
> -- 
> Cecil Westerhof
>  

-- 
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: Removing the 5th, 10th, 15th ... element of a list

2015-02-17 Thread Timothy Baldridge
True, that works, but he wants to remove based on element position, not
element value.

Timothy

On Tue, Feb 17, 2015 at 12:28 PM, Ivan L  wrote:

> this works
>
> => (filter #(not= (mod % 5) 0) (range 22))
> (1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21)
>
>
> On Tuesday, February 17, 2015 at 2:21:20 PM UTC-5, Cecil Westerhof wrote:
>>
>> What is the best way to remove all elements which position (counting from
>> 1) is a multiply of five out of a list?
>>
>> So the list:
>> (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21)
>> ​becomes:
>> (1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21)​
>>
>> --
>> Cecil Westerhof
>>
>  --
> 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.
>



-- 
“One of the main causes of the fall of the Roman Empire was that–lacking
zero–they had no way to indicate successful termination of their C
programs.”
(Robert Firth)

-- 
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: Removing the 5th, 10th, 15th ... element of a list

2015-02-17 Thread Timothy Baldridge
Tweak as needed:

(keep-indexed
  (fn [i v]
(if (= 0 (mod i 5))
  nil
  v))
  (range 30))

On Tue, Feb 17, 2015 at 12:21 PM, Cecil Westerhof 
wrote:

> What is the best way to remove all elements which position (counting from
> 1) is a multiply of five out of a list?
>
> So the list:
> (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21)
> ​becomes:
> (1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21)​
>
> --
> Cecil Westerhof
>
> --
> 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.
>



-- 
“One of the main causes of the fall of the Roman Empire was that–lacking
zero–they had no way to indicate successful termination of their C
programs.”
(Robert Firth)

-- 
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: Removing the 5th, 10th, 15th ... element of a list

2015-02-17 Thread Cecil Westerhof
2015-02-17 20:26 GMT+01:00 Timothy Baldridge :

> Tweak as needed:
>
> (keep-indexed
>   (fn [i v]
> (if (= 0 (mod i 5))
>   nil
>   v))
>   (range 30))
>

​I made the following:
​

​(defn indexed-sieve [index this-list]
  (keep-indexed
(fn [i v]
  (if (= 0 (mod (inc i) index))
  nil
v))
this-list))

The first element should not be filtered (counting from 1) and because I
will use it more often I created a function.​



> On Tue, Feb 17, 2015 at 12:21 PM, Cecil Westerhof 
> wrote:
>
>> What is the best way to remove all elements which position (counting from
>> 1) is a multiply of five out of a list?
>>
>> So the list:
>> (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21)
>> ​becomes:
>> (1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21)​
>>
>
-- 
Cecil Westerhof

-- 
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: Removing the 5th, 10th, 15th ... element of a list

2015-02-17 Thread Colin Yates
Style police would point out zero? and when-not :).
On 17 Feb 2015 20:40, "Cecil Westerhof"  wrote:

> 2015-02-17 20:26 GMT+01:00 Timothy Baldridge :
>
>> Tweak as needed:
>>
>> (keep-indexed
>>   (fn [i v]
>> (if (= 0 (mod i 5))
>>   nil
>>   v))
>>   (range 30))
>>
>
> ​I made the following:
> ​
>
> ​(defn indexed-sieve [index this-list]
>   (keep-indexed
> (fn [i v]
>   (if (= 0 (mod (inc i) index))
>   nil
> v))
> this-list))
>
> The first element should not be filtered (counting from 1) and because I
> will use it more often I created a function.​
>
>
>
>> On Tue, Feb 17, 2015 at 12:21 PM, Cecil Westerhof > > wrote:
>>
>>> What is the best way to remove all elements which position (counting
>>> from 1) is a multiply of five out of a list?
>>>
>>> So the list:
>>> (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21)
>>> ​becomes:
>>> (1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21)​
>>>
>>
> --
> Cecil Westerhof
>
> --
> 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: Removing the 5th, 10th, 15th ... element of a list

2015-02-17 Thread Timothy Baldridge
Clearly the answer is a program that runs every snippet posted to this
mailing list through kibit (https://github.com/jonase/kibit).

On Tue, Feb 17, 2015 at 1:49 PM, Colin Yates  wrote:

> Style police would point out zero? and when-not :).
> On 17 Feb 2015 20:40, "Cecil Westerhof"  wrote:
>
>> 2015-02-17 20:26 GMT+01:00 Timothy Baldridge :
>>
>>> Tweak as needed:
>>>
>>> (keep-indexed
>>>   (fn [i v]
>>> (if (= 0 (mod i 5))
>>>   nil
>>>   v))
>>>   (range 30))
>>>
>>
>> ​I made the following:
>> ​
>>
>> ​(defn indexed-sieve [index this-list]
>>   (keep-indexed
>> (fn [i v]
>>   (if (= 0 (mod (inc i) index))
>>   nil
>> v))
>> this-list))
>>
>> The first element should not be filtered (counting from 1) and because I
>> will use it more often I created a function.​
>>
>>
>>
>>> On Tue, Feb 17, 2015 at 12:21 PM, Cecil Westerhof <
>>> cldwester...@gmail.com> wrote:
>>>
 What is the best way to remove all elements which position (counting
 from 1) is a multiply of five out of a list?

 So the list:
 (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21)
 ​becomes:
 (1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21)​

>>>
>> --
>> Cecil Westerhof
>>
>> --
>> 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.
>



-- 
“One of the main causes of the fall of the Roman Empire was that–lacking
zero–they had no way to indicate successful termination of their C
programs.”
(Robert Firth)

-- 
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: Removing the 5th, 10th, 15th ... element of a list

2015-02-17 Thread Colin Yates
+1

And don't forget Eastwood as well :).

On a more serious note, I found
http://blog.mattgauger.com/blog/2014/09/15/clojure-code-quality-tools/ has
some other great tips related to this.
On 17 Feb 2015 20:51, "Timothy Baldridge"  wrote:

> Clearly the answer is a program that runs every snippet posted to this
> mailing list through kibit (https://github.com/jonase/kibit).
>
> On Tue, Feb 17, 2015 at 1:49 PM, Colin Yates 
> wrote:
>
>> Style police would point out zero? and when-not :).
>> On 17 Feb 2015 20:40, "Cecil Westerhof"  wrote:
>>
>>> 2015-02-17 20:26 GMT+01:00 Timothy Baldridge :
>>>
 Tweak as needed:

 (keep-indexed
   (fn [i v]
 (if (= 0 (mod i 5))
   nil
   v))
   (range 30))

>>>
>>> ​I made the following:
>>> ​
>>>
>>> ​(defn indexed-sieve [index this-list]
>>>   (keep-indexed
>>> (fn [i v]
>>>   (if (= 0 (mod (inc i) index))
>>>   nil
>>> v))
>>> this-list))
>>>
>>> The first element should not be filtered (counting from 1) and because I
>>> will use it more often I created a function.​
>>>
>>>
>>>
 On Tue, Feb 17, 2015 at 12:21 PM, Cecil Westerhof <
 cldwester...@gmail.com> wrote:

> What is the best way to remove all elements which position (counting
> from 1) is a multiply of five out of a list?
>
> So the list:
> (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21)
> ​becomes:
> (1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21)​
>

>>> --
>>> Cecil Westerhof
>>>
>>> --
>>> 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.
>>
>
>
>
> --
> “One of the main causes of the fall of the Roman Empire was that–lacking
> zero–they had no way to indicate successful termination of their C
> programs.”
> (Robert Firth)
>
> --
> 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: Performant flattening of nested data structures

2015-02-17 Thread Francis Avila
This is probably easier if you do it in two passes: one to assemble the 
get-in path down to a value, and another to stringify that path. 

(def input {:name {:first "Rich" :last "Hickey"} :number [1 415 123 4567]})
;=> #'user/input
(def expected {"$.number[0]" 1, "$.number[1]" 415, "$.number[2]" 123, 
"$.number[3]" 4567, "$.name.first" "Rich", "$.name.last" "Hickey"})
;=> #'user/expected
(defn keypaths
  ([xs] (keypaths [] xs))
  ([path-prefix xs]
(reduce-kv
  (fn [kp+v k v]
(let [path (conj path-prefix k)]
  (if (associative? v) ;; You may need to change this.
(into kp+v (keypaths path v))
(conj kp+v [path v]
  []
  xs)))
;=> #'user/keypaths
(defn keypath->str [path]
  (let [str-part
(fn [x] (cond
  (or (string? x) (char? x)) (str \. x)
  (instance? clojure.lang.Named x) (str \. (name x))
  :else (str \[ x \])))
str-path ^String (apply str (map str-part path))]
(if (.startsWith str-path ".")
  (subs str-path 1)
  str-path)))
;=> #'user/keypath->str
(keypaths input)
;=> [[[:number 0] 1] [[:number 1] 415] [[:number 2] 123] [[:number 3] 4567] 
[[:name :first] "Rich"] [[:name :last] "Hickey"]]
(keypaths ["$"] input)
;=> [[["$" :number 0] 1] [["$" :number 1] 415] [["$" :number 2] 123] [["$" :
number 3] 4567] [["$" :name :first] "Rich"] [["$" :name :last] "Hickey"]]
(->> (keypaths ["$"] input)
 (map (fn [[path v]] [(keypath->str path) v]))
 (into {}))
;=> {"$.number[0]" 1, "$.number[1]" 415, "$.number[2]" 123, "$.number[3]" 
4567, "$.name.first" "Rich", "$.name.last" "Hickey"}
(= *1 expected)
;=> true

So that increases readability. What about performance?

I'm not entirely sure what you are trying to optimize. You mention a 
whitelist of keys. Is there something related to that you want to optimize? 
Maybe you don't need to stringify keys at all? Perhaps you need to 
represent your whitelist as a set of vectors (each of which is a keypath), 
then filter the un-stringified keypaths from maps by that whitelist:

(def whitelist #{[:number 0] [:number 1] [:number 2] [:name :first] [:name 
:last]})
;=> #'user/whitelist
(->> (keypaths input)
 (filter (comp whitelist first)))
;=> ([[:number 0] 1] [[:number 1] 415] [[:number 2] 123] [[:name :first] 
"Rich"] [[:name :last] "Hickey"])


If the problem is that you have extremely large maps to flatten, you can 
try folding reducers. There are two opportunities for parallelism: 
constructing the paths, and stringifying the paths. Stringifying the paths 
is more obvious:

(require '[clojure.core.reducers :as r])
;=> nil
(defn r-flatten-assoc [m]
  (->> (keypaths [\$] m)
   (r/map (fn [[path v]] [(keypath->str path) v]
;=> #'breeze.mast.repl/r-flatten-assoc
(->> (r-flatten-assoc input) (r/foldcat) (into {}) (= expected)
;=> true


But paralleling construction of paths is a bit harder. The following 
example only folds over maps; to fold over the vectors with index without 
lazy seqs or realizing maps requires a custom reducer. (I also use 
transients for good measure.)

(defn r-keypaths
  ([xs] (r-keypaths [] xs))
  ([path-prefix xs]
(if (map? xs)
  (->> xs
   (r/mapcat (fn [k v]
   (let [path (conj path-prefix k)]
 (if (associative? v)
   (r-keypaths path v)
   [[path v]]
   (r/foldcat))
  (->> (reduce-kv
 (fn [kp+v k v]
   (let [path (conj path-prefix k)]
 (if (associative? v)
   (reduce conj! kp+v (r-keypaths path v))
   (conj! kp+v [path v]
 (transient [])
 xs)
   (persistent!)







On Tuesday, February 17, 2015 at 10:18:58 AM UTC-6, Mark Watson wrote:
>
> A slightly cleaner version:
>
> (defn- flatten-keys* [a ks m]
>
>   (cond
>
>;; Is a map?
>
>(map? m) (reduce into
>
> (map (fn [[k v]]
>
>(flatten-keys* a (str ks "." (name k)) v))
>
>  (seq m)))
>
>;; Is an arr/vec/seq?
>
>(and (sequential? m)
>
> (not (instance? clojure.lang.MapEntry m))) (reduce into
>
>(map-indexed (fn 
> [idx itm]
>
>   
> (flatten-keys* a
>
>   
>(str ks "[" idx "]")
>
>   
>itm))
>
> (seq 
> m)))
>
>;; Is not a collection
>
>:else (assoc a ks m)))
>
> (defn flatten-keys [m] (flatten-keys* {} "$" m))
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email t

Re: Removing the 5th, 10th, 15th ... element of a list

2015-02-17 Thread Colin Jones
Sounds almost like a mirror image of `clojure.core/take-nth`, so something 
like this is kind of fun:

(defn drop-nth [n coll] 
  (lazy-seq 
(when-let [s (seq coll)] 
  (concat (take (dec n) s) (drop-nth n (drop n s))



On Tuesday, February 17, 2015 at 1:21:20 PM UTC-6, Cecil Westerhof wrote:
>
> What is the best way to remove all elements which position (counting from 
> 1) is a multiply of five out of a list?
>
> So the list:
> (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21)
> ​becomes:
> (1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21)​
>
> -- 
> Cecil Westerhof
>  

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


Lucky numbers

2015-02-17 Thread Cecil Westerhof
I programmed Lucky Numbers in Clojure:
(defn indexed-sieve [index this-list]
  (keep-indexed
(fn [i v]
  (if (= 0 (mod (inc i) index))
  nil
v))
this-list))

(defn lucky-numbers [max-value]
  (let [current-list(atom (indexed-sieve 2 (range 1 max-value)))
current-index   (atom 1)]
(while (< @current-index (count @current-list))
  (reset! current-list (indexed-sieve (nth @current-list
@current-index) @current-list))
  (reset! current-index (inc @current-index)))
current-list))

It is short, but is it good? For a large max-value it takes 'some' time.

(time (def lucky (lucky-numbers 100)))
"Elapsed time: 790832.407467 msecs"
#'user/lucky

-- 
Cecil Westerhof

-- 
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: Summer of Code 2015

2015-02-17 Thread Daniel Lee
Great! Looking forward to applying for it.
On Friday, February 13, 2015 at 9:41:58 AM UTC-8, Ambrose Bonnaire-Sergeant 
wrote:
>
> We're planning to apply.
>
> On Fri, Feb 13, 2015 at 12:10 PM, Rinu Boney  > wrote:
>
>> Hi all,
>>
>>   I was wondering if the Clojure community is applying to Google 
>> Summer of Code 2015. The last date for organizations to apply is 20th Feb 
>> and I see no activity from the Clojure community. I have done some work on 
>> a proposal and I'm very interested in applying.
>>
>> -- 
>> 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: Lucky numbers

2015-02-17 Thread Steve Miner

> On Feb 17, 2015, at 4:39 PM, Colin Jones  wrote:
> 
> Sounds almost like a mirror image of `clojure.core/take-nth`, so something 
> like this is kind of fun:
> 
> (defn drop-nth [n coll] 
>   (lazy-seq 
> (when-let [s (seq coll)] 
>   (concat (take (dec n) s) (drop-nth n (drop n s))
> 

I like that drop-nth.  Here's my version of lucky:

(defn lucky
  "Returns sequence of Lucky numbers less than max"
  ([max] (when (pos? max) (lucky 1 (range 1 max 2
  ([i acc]
   (if-let [n (nth acc i nil)]
 (recur (inc i) (drop-nth n acc))
 acc)))

The recur in this case loops back to the top.

-- 
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: Performant flattening of nested data structures

2015-02-17 Thread Fluid Dynamics
You've probably gotten nearly all of the performance you're going to get 
out of it without resorting to mutability, perhaps by threading a 
StringBuilder instance through the whole affair, or at least accumulating 
not a string (via a sequence of "str" calls) but a coll and doing a big 
"apply str" over that at the base case: (assoc a (apply str ks) m), which 
amounts to the same thing (should end up using a single StringBuilder under 
the hood to assemble the entire string in one pass, without creating a 
temporary String object at each intermediate level).

-- 
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: Removing the 5th, 10th, 15th ... element of a list

2015-02-17 Thread Fluid Dynamics
On Tuesday, February 17, 2015 at 2:21:20 PM UTC-5, Cecil Westerhof wrote:
>
> What is the best way to remove all elements which position (counting from 
> 1) is a multiply of five out of a list?
>
> So the list:
> (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21)
> ​becomes:
> (1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21)​
>

The correct answer, obviously, is

(->> s
  (cons ::sentinel)
  (partition n n nil)
  (map next)
  (mapcat identity))

with, in this case, s = (range 1 22) and n = 5

-- 
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: Removing the 5th, 10th, 15th ... element of a list

2015-02-17 Thread Ben Wolfson
why not (mapcat next)?

On Tue, Feb 17, 2015 at 3:45 PM, Fluid Dynamics  wrote:

> On Tuesday, February 17, 2015 at 2:21:20 PM UTC-5, Cecil Westerhof wrote:
>>
>> What is the best way to remove all elements which position (counting from
>> 1) is a multiply of five out of a list?
>>
>> So the list:
>> (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21)
>> becomes:
>> (1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21)
>>
>
> The correct answer, obviously, is
>
> (->> s
>   (cons ::sentinel)
>   (partition n n nil)
>   (map next)
>   (mapcat identity))
>
> with, in this case, s = (range 1 22) and n = 5
>
>  --
> 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.
>



-- 
Ben Wolfson
"Human kind has used its intelligence to vary the flavour of drinks, which
may be sweet, aromatic, fermented or spirit-based. ... Family and social
life also offer numerous other occasions to consume drinks for pleasure."
[Larousse, "Drink" entry]

-- 
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: Lucky numbers

2015-02-17 Thread Cecil Westerhof
2015-02-18 0:28 GMT+01:00 Steve Miner :

>
> > On Feb 17, 2015, at 4:39 PM, Colin Jones  wrote:
> >
> > Sounds almost like a mirror image of `clojure.core/take-nth`, so
> something like this is kind of fun:
> >
> > (defn drop-nth [n coll]
> >   (lazy-seq
> > (when-let [s (seq coll)]
> >   (concat (take (dec n) s) (drop-nth n (drop n s))
> >
>
> I like that drop-nth.  Here's my version of lucky:
>
> (defn lucky
>   "Returns sequence of Lucky numbers less than max"
>   ([max] (when (pos? max) (lucky 1 (range 1 max 2
>   ([i acc]
>(if-let [n (nth acc i nil)]
>  (recur (inc i) (drop-nth n acc))
>  acc)))
>
> The recur in this case loops back to the top.
>

​It looks good, but with 100 I get a stack overflow. And even with
10. It takes also about two times as long to execute.
​

-- 
Cecil Westerhof

-- 
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: Continuously Integrating Leiningen Projects

2015-02-17 Thread Rick Moynihan
Avoiding SNAPSHOT builds certainly solves the problem, but I was
hoping to continue to either fully automate the process or use
SNAPSHOTs between official releases library while integrating.

For example right now I have four private projects on our CI server
that depend on a common library I am also working on - and then there
are perhaps 3 or 4 additional projects by other developers within the
organisation who may choose to use a release or on occaision a
SNAPSHOT build of some of these libraries.

Not to mention how I'd ultimately like to move to a model where the CI
server is building and integrating on perhaps 3 or 4 different
branches for each of those projects.

I'm really after advice on how to configure Jenkins to help automate
this process.  You mentioned including the git commit in the version
number for snapshot builds.  This is a great idea, but how can I get
Jenkins and leiningen to do this for me?  I know I can access the
commit/build_id through environment variables but how can I easily
insert them into the leiningen project.clj version number?

Without automation here I feel like I'll literally spend my life
updating version numbers.

R.

On 17 February 2015 at 19:13, Michael Blume  wrote:
> What we do at Climate is avoid SNAPSHOT builds. Every build gets a version
> string with timestamp and git commit. If an upstream library is changed,
> it's up to downstream maintainers to update their dependency on it. If you
> update a dependency and your build fails, you a) don't update your
> dependency just yet b) complain to the library maintainer that their new
> version breaks your project.
>
> On Tue Feb 17 2015 at 9:51:18 AM Rick Moynihan 
> wrote:
>>
>> Hi all,
>>
>> At work, we use Jenkins to continuously integrate our Clojure projects
>> which are factored into both applications and a small number of
>> supporting libraries; all of which use Leiningen as their project
>> build tool.
>>
>> Leiningen builds each project, and runs its tests; and then if they
>> pass it lein installs the project jar into the local ~/.m2 repo and
>> triggers any dependent builds to start.  The dependencies then start
>> building and pick up the latest SNAPSHOT build from the ~/.m2
>> directory.
>>
>> This works ok; but it has a relatively major flaw, which is that just
>> because a project passes its local tests; it doesn't mean that it
>> hasn't broken an upstream library.  When this happens the broken
>> library is left in the shared ~/.m2 directory - breaking other builds
>> and generally lying around causing havoc.
>>
>> Fortunately this rarely happens in practice; but it is a potential
>> cause of hard to diagnose (unrepeatable build) problems - especially
>> when using snapshot builds - which is what I think we want to use for
>> tracking branches until we
>>
>> We currently use the Jenkins leiningen plugin, but I don't think it
>> supports a more sophisticated setup than this.
>>
>> I was wondering if anyone with experience of running robust CI builds
>> (with Jenkins) might have any ideas about to solve this in a more
>> robust manner??
>>
>> Many thanks,
>>
>> Rick
>> --
>> http://twitter.com/RickMoynihan
>>
>> --
>> 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
htt

Re: Continuously Integrating Leiningen Projects

2015-02-17 Thread Rick Moynihan
Thanks for the tip,  I had used lein-ancient in the past and it seems
to have come along a bit since then.

How is it that you have this configured?

Do you run lein ancient upgrade before each build that you want to
check its dependencies?  I tried this locally and I can't find a way
to tell lein ancient to only try and upgrade certain libraries, rather
than all or nothing.

For example I have a dependency on incanter 1.5.5 - I don't want it to
upgrade to 1.9.0 because it will break the build catastrophically just
now...  I do however want to whitelist it to my library, which I'm
expecting to keep more current.

R.

On 17 February 2015 at 19:14, Michael Blume  wrote:
> Related -- we run lein ancient as part of a lot of our builds so that we can
> easily pick up dependencies with newer available versions.
>
> On Tue Feb 17 2015 at 11:13:44 AM Michael Blume 
> wrote:
>>
>> What we do at Climate is avoid SNAPSHOT builds. Every build gets a version
>> string with timestamp and git commit. If an upstream library is changed,
>> it's up to downstream maintainers to update their dependency on it. If you
>> update a dependency and your build fails, you a) don't update your
>> dependency just yet b) complain to the library maintainer that their new
>> version breaks your project.
>>
>> On Tue Feb 17 2015 at 9:51:18 AM Rick Moynihan 
>> wrote:
>>>
>>> Hi all,
>>>
>>> At work, we use Jenkins to continuously integrate our Clojure projects
>>> which are factored into both applications and a small number of
>>> supporting libraries; all of which use Leiningen as their project
>>> build tool.
>>>
>>> Leiningen builds each project, and runs its tests; and then if they
>>> pass it lein installs the project jar into the local ~/.m2 repo and
>>> triggers any dependent builds to start.  The dependencies then start
>>> building and pick up the latest SNAPSHOT build from the ~/.m2
>>> directory.
>>>
>>> This works ok; but it has a relatively major flaw, which is that just
>>> because a project passes its local tests; it doesn't mean that it
>>> hasn't broken an upstream library.  When this happens the broken
>>> library is left in the shared ~/.m2 directory - breaking other builds
>>> and generally lying around causing havoc.
>>>
>>> Fortunately this rarely happens in practice; but it is a potential
>>> cause of hard to diagnose (unrepeatable build) problems - especially
>>> when using snapshot builds - which is what I think we want to use for
>>> tracking branches until we
>>>
>>> We currently use the Jenkins leiningen plugin, but I don't think it
>>> supports a more sophisticated setup than this.
>>>
>>> I was wondering if anyone with experience of running robust CI builds
>>> (with Jenkins) might have any ideas about to solve this in a more
>>> robust manner??
>>>
>>> Many thanks,
>>>
>>> Rick
>>> --
>>> http://twitter.com/RickMoynihan
>>>
>>> --
>>> 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, vis

Re: Removing the 5th, 10th, 15th ... element of a list

2015-02-17 Thread Fluid Dynamics
On Tuesday, February 17, 2015 at 6:47:59 PM UTC-5, Ben wrote:
>
> why not (mapcat next)?
>

Yeah, that should work too, though conceptually trimming each part and then 
reflattening the partition are two separate steps of the computation. :)
 

> The correct answer, obviously, is
>
> (->> s
>   (cons ::sentinel)
>   (partition n n nil)
>   (map next)
>   (mapcat identity))
>
> with, in this case, s = (range 1 22) and n = 5
>  

-- 
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: Removing the 5th, 10th, 15th ... element of a list

2015-02-17 Thread Udayakumar Rayala
Then probably (apply concat) is better than (mapcat identity) isnt it?

What is (cons ::sentinel)? Why do you need it here?

On Wed, Feb 18, 2015 at 5:58 AM, Fluid Dynamics  wrote:

> On Tuesday, February 17, 2015 at 6:47:59 PM UTC-5, Ben wrote:
>>
>> why not (mapcat next)?
>>
>
> Yeah, that should work too, though conceptually trimming each part and
> then reflattening the partition are two separate steps of the computation.
> :)
>
>
>> The correct answer, obviously, is
>>
>> (->> s
>>   (cons ::sentinel)
>>   (partition n n nil)
>>   (map next)
>>   (mapcat identity))
>>
>> with, in this case, s = (range 1 22) and n = 5
>>
>  --
> 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: Removing the 5th, 10th, 15th ... element of a list

2015-02-17 Thread Fluid Dynamics
On Tuesday, February 17, 2015 at 10:24:29 PM UTC-5, Udayakumar Rayala wrote:
>
> Then probably (apply concat) is better than (mapcat identity) isnt it?
>
> What is (cons ::sentinel)? Why do you need it here?
>

It'll drop the wrong elements otherwise:

=> (->> (range 1 22)
 (partition 5 5 nil)
 (mapcat next))
(2 3 4 5 7 8 9 10 12 13 14 15 17 18 19 20)

All the partitions need to be shifted by one position to the left, so the 
elements to drop are at their left edges, if we want to use the efficient 
"next" instead of the evil linear-time "butlast" in the later step. But 
that can be done by prepending a dummy element to the input, which will 
conveniently go away as one of the elided elements.

-- 
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: Removing the 5th, 10th, 15th ... element of a list

2015-02-17 Thread Udayakumar Rayala
Ah ok. Got it.

On Wed, Feb 18, 2015 at 9:13 AM, Fluid Dynamics  wrote:

> On Tuesday, February 17, 2015 at 10:24:29 PM UTC-5, Udayakumar Rayala
> wrote:
>>
>> Then probably (apply concat) is better than (mapcat identity) isnt it?
>>
>> What is (cons ::sentinel)? Why do you need it here?
>>
>
> It'll drop the wrong elements otherwise:
>
> => (->> (range 1 22)
>  (partition 5 5 nil)
>  (mapcat next))
> (2 3 4 5 7 8 9 10 12 13 14 15 17 18 19 20)
>
> All the partitions need to be shifted by one position to the left, so the
> elements to drop are at their left edges, if we want to use the efficient
> "next" instead of the evil linear-time "butlast" in the later step. But
> that can be done by prepending a dummy element to the input, which will
> conveniently go away as one of the elided elements.
>
> --
> 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: Lucky numbers

2015-02-17 Thread Udayakumar Rayala
Do you want the check if your initial code is working correctly? Because
when I ran it, this is the output with 100 numbers:

(1 3 7 9 13 15 21 25 31 33 37 43 49 51 63 67 69 73 75 79 87 93 99)

I have modified it like this. I have highlighted what I have changed.:

(defn indexed-sieve [index this-list]
  (keep-indexed
   (fn [i v]
 (if (= 0 (mod (inc i) index))
   nil
   v))
   this-list))

(defn lucky-numbers [max-value]
  (let [current-list*(atom (range 1 max-value)) *
current-index   *(atom 2)*]
(while (< @current-index (count @current-list))
  (reset! current-list (indexed-sieve *@current-index* @current-list))
  (reset! current-index (inc @current-index)))
@current-list))

This give the following output:

(1 3 7 13 19 27 39 49 63 79 91)

This seems more correct.

You can further convert the while to loop recur to avoid using atoms.

On Wed, Feb 18, 2015 at 5:28 AM, Cecil Westerhof 
wrote:

> 2015-02-18 0:28 GMT+01:00 Steve Miner :
>
>>
>> > On Feb 17, 2015, at 4:39 PM, Colin Jones  wrote:
>> >
>> > Sounds almost like a mirror image of `clojure.core/take-nth`, so
>> something like this is kind of fun:
>> >
>> > (defn drop-nth [n coll]
>> >   (lazy-seq
>> > (when-let [s (seq coll)]
>> >   (concat (take (dec n) s) (drop-nth n (drop n s))
>> >
>>
>> I like that drop-nth.  Here's my version of lucky:
>>
>> (defn lucky
>>   "Returns sequence of Lucky numbers less than max"
>>   ([max] (when (pos? max) (lucky 1 (range 1 max 2
>>   ([i acc]
>>(if-let [n (nth acc i nil)]
>>  (recur (inc i) (drop-nth n acc))
>>  acc)))
>>
>> The recur in this case loops back to the top.
>>
>
> It looks good, but with 100 I get a stack overflow. And even with
> 10. It takes also about two times as long to execute.
>
> --
> Cecil Westerhof
>
> --
> 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: [ANN] Clojure 1.7.0-alpha5 now available

2015-02-17 Thread Colin Fleming
I added a comment

in CLJ-979, I believe I have a case which is broken by the change in
delegation order, if I'm correct in my understanding of what the CLJ-979
change is actually doing.

On 30 January 2015 at 07:36, Jozef Wagner  wrote:

> Thank you very much Nicola!
>
> On Thu, Jan 29, 2015 at 7:24 PM, Nicola Mometto 
> wrote:
>
>>
>> Jozef, I looked into this and opened a ticket with a proposed patch to
>> fix this issue: http://dev.clojure.org/jira/browse/CLJ-1650
>>
>> Jozef Wagner writes:
>>
>> > With CLJ-979 applied, lein may crash when doing :aot :all. This is
>> caused
>> > when lein forces recompilation of already compiled classes. Not sure
>> > whether this should be considered a lein of clojure bug though.
>> >
>> > See https://github.com/wagjo/aotbug for contrived example.
>> >
>> > Jozef
>> >
>> > On Saturday, January 10, 2015 at 4:37:04 PM UTC+1, Alex Miller wrote:
>> >>
>> >> Clojure 1.7.0-alpha5 is now available.
>> >>
>> >> Try it via
>> >> - Download:
>> >> https://repo1.maven.org/maven2/org/clojure/clojure/1.7.0-alpha5/
>> >> - Leiningen: [org.clojure/clojure "1.7.0-alpha5"]
>> >>
>> >> A few of the highlights in alpha5:
>> >>
>> >> 1) New transducer arities for map-indexed, distinct, and interpose.
>> >> The transducer versions are generally faster than the sequence
>> versions.
>> >> See CLJ-1601 for more details.
>> >>
>> >> 2) The set and vec functions should now be faster in many cases. Some
>> of
>> >> the
>> >> vec improvements will not kick in until CLJ-1499 is committed in the
>> >> future.
>> >> See CLJ-1546 and CLJ-1618 for more details.
>> >>
>> >> 3) Two particularly troublesome AOT classloading bugs have been
>> addressed
>> >> -
>> >> CLJ-979 and CLJ-1544. Many other tickets were found to be duplicates of
>> >> one of
>> >> these as well. Big thanks to Nicola Mometto for doing the hard work on
>> >> debugging and providing fixes for these.
>> >>
>> >> For all changes new in alpha5, see the issues marked "(alpha5)" in the
>> >> full changes below.
>> >>
>> >> 
>> >> Clojure 1.7.0-alpha5 has the changes below from 1.6.0:
>> >>
>> >> ## 1 New and Improved Features
>> >>
>> >> ### 1.1 Transducers
>> >>
>> >> Transducers is a new way to decouple algorithmic transformations from
>> their
>> >> application in different contexts. Transducers are functions that
>> transform
>> >> reducing functions to build up a "recipe" for transformation.
>> >>
>> >> Also see: http://clojure.org/transducers
>> >>
>> >> Many existing sequence functions now have a new arity (one fewer
>> argument
>> >> than before). This arity will return a transducer that represents the
>> same
>> >> logic but is independent of lazy sequence processing. Functions
>> included
>> >> are:
>> >>
>> >> * conj (conjs to [])
>> >> * map
>> >> * mapcat
>> >> * filter
>> >> * remove
>> >> * take
>> >> * take-while
>> >> * drop
>> >> * drop-while
>> >> * cycle
>> >> * take-nth
>> >> * replace
>> >> * partition-by
>> >> * partition-all
>> >> * keep
>> >> * keep-indexed
>> >> * map-indexed (alpha5)
>> >> * distinct (alpha5)
>> >> * interpose (alpha5)
>> >>
>> >> Additionally some new transducer functions have been added:
>> >>
>> >> * cat - concatenates the contents of each input
>> >> * de-dupe - removes consecutive duplicated values
>> >> * random-sample - returns items from coll with random probability
>> >>
>> >> And this function can be used to make completing transforms:
>> >>
>> >> * completing
>> >>
>> >> There are also several new or modified functions that can be used to
>> apply
>> >> transducers in different ways:
>> >>
>> >> * sequence - takes a transformation and a coll and produces a lazy seq
>> >> * transduce - reduce with a transformation (eager)
>> >> * eduction - returns a reducible/seqable/iterable seq of applications
>> of
>> >> the transducer to items in coll. Applications are re-performed with
>> every
>> >> reduce/seq/iterator.
>> >> * run! - run the transformation for side effects on the collection
>> >>
>> >> There have been a number of internal changes to support transducers:
>> >>
>> >> * volatiles - there are a new set of functions (volatile!, vswap!,
>> >> vreset!, volatile?) to create and use volatile "boxes" to hold state in
>> >> stateful transducers. Volatiles are faster than atoms but give up
>> atomicity
>> >> guarantees so should only be used with thread isolation.
>> >> * array iterators - added support for iterators over arrays
>> >>
>> >> Some related issues addressed during development:
>> >> * [CLJ-1511](http://dev.clojure.org/jira/browse/CLJ-1511)
>> >> * [CLJ-1497](http://dev.clojure.org/jira/browse/CLJ-1497)
>> >> * [CLJ-1549](http://dev.clojure.org/jira/browse/CLJ-1549)
>> >> * [CLJ-1537](http://dev.clojure.org/jira/browse/CLJ-1537)
>> >> * [CLJ-1554](http://dev.clojure.or

Re: Continuously Integrating Leiningen Projects

2015-02-17 Thread Michael Blume
We use a Leiningen plugin to set the version dynamically

https://github.com/technomancy/leiningen/blob/master/doc/PLUGINS.md -- if
you skip down to "project middleware" you'll see how to create the kind of
plugin I'm talking about. Within the middleware function, we update the
:version key in the project map to a version string composed of a timestamp
and the first few characters of the commit hash. The timestamp part is
important because it ensures that maven/lein consider newer builds to be
newer.

As for lein-ancient, we don't really have it *do* anything, it just prints
its suggestions in the build output, and if you look at your build from
time to time, you'll see there are libraries you can upgrade. It's not a
perfect system, but it helps.

On Tue Feb 17 2015 at 4:23:03 PM Rick Moynihan 
wrote:

> Thanks for the tip,  I had used lein-ancient in the past and it seems
> to have come along a bit since then.
>
> How is it that you have this configured?
>
> Do you run lein ancient upgrade before each build that you want to
> check its dependencies?  I tried this locally and I can't find a way
> to tell lein ancient to only try and upgrade certain libraries, rather
> than all or nothing.
>
> For example I have a dependency on incanter 1.5.5 - I don't want it to
> upgrade to 1.9.0 because it will break the build catastrophically just
> now...  I do however want to whitelist it to my library, which I'm
> expecting to keep more current.
>
> R.
>
> On 17 February 2015 at 19:14, Michael Blume  wrote:
> > Related -- we run lein ancient as part of a lot of our builds so that we
> can
> > easily pick up dependencies with newer available versions.
> >
> > On Tue Feb 17 2015 at 11:13:44 AM Michael Blume 
> > wrote:
> >>
> >> What we do at Climate is avoid SNAPSHOT builds. Every build gets a
> version
> >> string with timestamp and git commit. If an upstream library is changed,
> >> it's up to downstream maintainers to update their dependency on it. If
> you
> >> update a dependency and your build fails, you a) don't update your
> >> dependency just yet b) complain to the library maintainer that their new
> >> version breaks your project.
> >>
> >> On Tue Feb 17 2015 at 9:51:18 AM Rick Moynihan  >
> >> wrote:
> >>>
> >>> Hi all,
> >>>
> >>> At work, we use Jenkins to continuously integrate our Clojure projects
> >>> which are factored into both applications and a small number of
> >>> supporting libraries; all of which use Leiningen as their project
> >>> build tool.
> >>>
> >>> Leiningen builds each project, and runs its tests; and then if they
> >>> pass it lein installs the project jar into the local ~/.m2 repo and
> >>> triggers any dependent builds to start.  The dependencies then start
> >>> building and pick up the latest SNAPSHOT build from the ~/.m2
> >>> directory.
> >>>
> >>> This works ok; but it has a relatively major flaw, which is that just
> >>> because a project passes its local tests; it doesn't mean that it
> >>> hasn't broken an upstream library.  When this happens the broken
> >>> library is left in the shared ~/.m2 directory - breaking other builds
> >>> and generally lying around causing havoc.
> >>>
> >>> Fortunately this rarely happens in practice; but it is a potential
> >>> cause of hard to diagnose (unrepeatable build) problems - especially
> >>> when using snapshot builds - which is what I think we want to use for
> >>> tracking branches until we
> >>>
> >>> We currently use the Jenkins leiningen plugin, but I don't think it
> >>> supports a more sophisticated setup than this.
> >>>
> >>> I was wondering if anyone with experience of running robust CI builds
> >>> (with Jenkins) might have any ideas about to solve this in a more
> >>> robust manner??
> >>>
> >>> Many thanks,
> >>>
> >>> Rick
> >>> --
> >>> http://twitter.com/RickMoynihan
> >>>
> >>> --
> >>> 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 o

Re: Lucky numbers

2015-02-17 Thread Cecil Westerhof
2015-02-18 5:06 GMT+01:00 Udayakumar Rayala :

> Do you want the check if your initial code is working correctly? Because
> when I ran it, this is the output with 100 numbers:
>
> (1 3 7 9 13 15 21 25 31 33 37 43 49 51 63 67 69 73 75 79 87 93 99)
>

​That is the correct output:
http://en.wikipedia.org/wiki/Lucky_number

There was a stupid mistake: it should return @current-list instead of
current-list.



> I have modified it like this. I have highlighted what I have changed.:
>
> (defn indexed-sieve [index this-list]
>   (keep-indexed
>(fn [i v]
>  (if (= 0 (mod (inc i) index))
>nil
>v))
>this-list))
>
> (defn lucky-numbers [max-value]
>   (let [current-list*(atom (range 1 max-value)) *
>
> current-index   *(atom 2)*]
>
> (while (< @current-index (count @current-list))
>   (reset! current-list (indexed-sieve *@current-index*
> @current-list))
>   (reset! current-index (inc @current-index)))
> @current-list))
>
> This give the following output:
>
> (1 3 7 13 19 27 39 49 63 79 91)
>
> This seems more correct.
>
> You can further convert the while to loop recur to avoid using atoms.
>
​There was a solution posted with recur. Two problems:
- It gives a StackOverflowError with 100 and 10. My solution has no
problem with those values. At the moment I am trying 1000, but it will
take two hours two finish I am afraid.
- It takes about two times as long​

​to execute​

-- 
Cecil Westerhof

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


Using 1_000_000_000

2015-02-17 Thread Cecil Westerhof
In Java I can use:
1_000_000_000

This makes code a lot more readable. But it seems this is not possible in
Clojure. Am I overlooking something?

-- 
Cecil Westerhof

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