Re: Clojure Repos - Some Dependencies are Not In Clojars

2016-11-15 Thread Didier
I feel like even if Clojars is not firewalled, you should probably get OSS 
approval from your legal team before important Clojars libs. Just a 
suggestion.

On Wednesday, 9 November 2016 05:55:41 UTC-8, Vitaly Peressada wrote:
>
> Hi All,
>
> FWIK the community uses both Maven Central and Clojars. But it appears 
> that Clojars does not have ALL Clojure dependencies. It is an annoying 
> issue in my present BIG company where Maven Central is blocked and it takes 
> 2-3 weeks to approve OSS library and upload it to company internal repo. 
> Luckily Clojars is proxied via Nexus and is available.
>
> Two examples are:
> org.clojure/tools.nrepl 0.2.12
> org.tcrawley:dynapath:jar:0.2.4 (dependency of 
> cider/cider-nrepl/0.15.0-SNAPSHOT)
>
> Don't know what historical context is but it would make sense to have ALL 
> deps in Clojars with some duplication in Maven Central (may be for clojure 
> itself, etc.)
>

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


Spec validation cache?

2016-11-15 Thread Gal Dolber
I'm having an issue with clojure.spec, its been great in more ways than I
expected but it's slowing down everything too much for development. On one
side when running the app on development with all fspecs instrumented and
on the other when running the tests.

For the first case, most of the fdef functions take the app state as the
first argument, and the app state, being a really big data structure, gets
constantly validated and re-validated, while only few parts change. So I've
been wondering if there's a way to memoize spec/valid? to speed everything
up (while sacrificing memory).

For the tests the case is different, because the app state gets generated
every time, so I don't see how this could speed them up.

I tried doing it with `with-redefs without any luck.
Any ideas? (I'm running on clojurescript)

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


How to check type of generic parameter with spec?

2016-11-15 Thread Eunmin Kim
Hi! I had a question while reading Functional Programming in Scala book.

The following code is Exercise 2:

// Exercise 2: Implement a polymorphic function to check whether
// an `Array[A]` is sorted

def isSorted[A](as: Array[A], gt: (A,A) => Boolean): Boolean = {
  @annotation.tailrec
  def go(n: Int): Boolean =
if (n >= as.length-1) true
else if (gt(as(n), as(n+1))) false
else go(n+1)

  go(0)
}

In the above code, Generic typ parameter(A) is displayed. How should I 
express it in clojure spec?

(defn sorted-coll? [as ordered-fn?]
  (loop [coll (seq as)]
(cond 
  (= 1 (count coll)) true
  (not (ordered-fn? (first coll) (second coll))) false
  :else (recur (rest coll)

-- 
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 me understand what part of this code is slow, and how to make it faster?

2016-11-15 Thread Didier
Hey all,

I came upon a benchmark of F#, Rust and OCaml, where F# performs much 
faster then the other two. I decided for fun to try and port it to Clojure 
to see how Clojure does. Benchmark link: 
https://github.com/c-cube/hashset_benchs

This is my code for it: 
https://gist.github.com/didibus/1fd4c00b69d927745fbce3dcd7ca461a

(ns hash-set-bench
  "A Benchmark I modified to Clojure from:
   https://github.com/c-cube/hashset_benchs;)

(defn iterNeighbors [f [i j]]
  (f [(dec i) j])
  (f [(inc i) j])
  (f [i (dec j)])
  (f [i (inc j)]))

(defn nth* [n p]
  (loop [n n s1 #{p} s2 #{}]
(if (= n 0)
  s1
  (let [s0 (atom #{})]
(letfn [(add [p]
 (when (not (or (contains? s1 p) (contains? s2 p)))
   (reset! s0 (conj @s0 p]
   (doseq [p s1] (iterNeighbors add p))
   (recur (dec n) @s0 s1))

#_(printf "result is %d" (count (time (nth* 2000 [0 0]

And here's the F# code: 
https://github.com/c-cube/hashset_benchs/blob/master/neighbors2.fsx

Currently, this takes about 30s in Clojure, while it only takes around 3s 
for OCaml, Rust and F#.

>From what I see, the differences between my code and theirs are:

   - Lack of a Point struct, I'm just using a vector.
   - They use a mutable set, I don't.
   - They overrode Hashing for their point struct, as well as equality. I 
   rely on Clojure's default hashing, and vector equality.

I'm not sure if any of these things should really impact performance that 
much though. And what I could do in Clojure if I wanted to improve it.


Any Help?


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: [ANN] Clojure Programming Cookbook

2016-11-15 Thread Alan Thompson
Ordered!  Looking forward to seeing it.  :)
Alan

On Mon, Nov 14, 2016 at 7:08 PM, Nicolas Modrzyk 
wrote:

> Hi Clojure people,
>
> So after one year and 23 days, (that would be 388 days) the IT book I was
> working on with Makoto (merci!) finally got published!
>
> It has been a long battle with many late nights to get it out, tough
> deadlines and never-ending reviews, but thanks to some skilled people at
> Packt, thank you Sachin, Pranav (and not forgetting Nikhil, you got it all
> started!) (http://packtpub.com/
> )
> it is finally there in all its 635 pages glory ;)
>
> (PACK) https://www.packtpub.com/application-development/
> clojure-programming-cookbook
>
> (AMAZON) http://a.co/3c9ckbp
>
> The book while also presenting Clojure language centric topics, wants to
> be slightly more focused around using Clojure at work and is bringing tons
> and tons of working examples for every day usage. Along its (long!) 10
> chapters, the book goes through many various topics but tries to keep each
> topic easy to follow, with fun and useful recipes for great projects and
> various creative ideas.
>
> The book may sometimes be too simple to many of the members of this
> mailing list, but we hope the book contribute to grow the Clojure community
> by sharing useful (and battled) Clojure code and stories.
>
> This is out now ! Enjoy!
> Nicolas & Makoto, all the way from Japan
>
> --
> 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.