internet access required?

2016-02-20 Thread andrea crotti
This might be a Cider issue more than Clojure but I'm not sure.

Sometimes on train/plane I try to work on some Clojure project and I
normally don't manage to start the REPL inside Emacs.

The issue calling (cider-jack-in) is the following:

Starting nREPL server via lein update-in :dependencies conj
\[org.clojure/tools.nrepl\ \"0.2.12\"\] -- update-in :plugins conj
\[refactor-nrepl\ \"2.2.0-SNAPSHOT\"\] -- update-in :plugins conj
\[cider/cider-nrepl\ \"0.11.0-SNAPSHOT\"\] -- repl :headless...

error in process sentinel: nrepl-server-sentinel: Could not start
nREPL server: Could not transfer artifact
refactor-nrepl:refactor-nrepl:pom:2.2.0-SNAPSHOT from/to clojars
(https://clojars.org/repo/): clojars.org

but the weird thing I don't have that plugin declared as SNAPSHOT
version anywhere, and in fact doing a "lein repl" from the terminal
works fine instead.

I tried to look in the Cider code and can't find anything there
either, so any idea where that comes from?
And a more general question there unless I use -SNAPSHOT versions,
there should be no case when lein needs to reconnect to clojars if all
the dependencies were already downloaded right?

Thanks

PS. this is my .lein/profiles_clj btw:

{:user
 {:dependencies
  [[pjstadig/humane-test-output "0.6.0"]
   [org.clojure/tools.nrepl "0.2.12"]
   [acyclic/squiggly-clojure "0.1.4"]
   [spyscope "0.1.5"]
   [org.clojure/tools.namespace "0.2.4"]
   [io.aviso/pretty "0.1.8"]
   [im.chit/vinyasa "0.1.2"]
   [org.clojure/tools.trace "0.7.8"]]

  :plugins
  [[cider/cider-nrepl "0.10.2"]
   [lein-annotations "0.1.0"]
   [com.jakemccrary/lein-test-refresh "0.7.0"]
   [lein-checkall "0.1.1"]
   [lein-droid "0.3.5"]
   [lein-githooks "0.1.0"]
   [lein-shell "0.4.0"]
   [lein-ancient "0.6.7" :exclusions [org.clojure/core.cache]]
   [lein-try "0.4.3"]
   [lein-midje "3.1.3"]
   [nodisassemble "0.1.3"]
   [lein-cloverage "1.0.3"]
   [refactor-nrepl "2.0.0"]
   ]}
 }

-- 
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: Generate all possible teams

2015-10-05 Thread andrea crotti
2015-10-05 19:33 GMT+01:00 Mark Engelberg :
> You're not using the combinatorics library as efficiently as you could be.
> Here's the best strategy for generating all the team combinations with the
> same number of players:
>
> Case 1: Even number of players.
> Let's call the first player "A".  "A" is going to be assigned to a team.  To
> avoid duplication, we want to find all the team combinations that will
> include player "A".  Then we can figure out the opposing team in each case
> by simply subtracting the team with player "A" from the total set of
> players.  Compare their skill sets as you did in your code.

Yes I came up with the same idea in the end, this is the code that does that.

(defn list-teams-combo [players]
  "List all the possible team combinations"
  (let [players-count (count players)
size (/ (combo/count-combinations players 2) 2)
team-size (/ (count players) 2)]

(for [team1 (take size (combo/combinations players team-size))]
  (list team1 (into () (clojure.set/difference (set players) team1))

For how combinations work also the nice thing is that I can just go
until the middle so this seems to work well :)

>
> So to get the teams with player A, you simply add in A to all the (n/2)-1
> size subsets of (rest players).
>
> Case 2: Odd number of players.
> Add player A to all the (n-1)/2 and (n-1)/2-1 subsets of (rest players).
>
> This should be substantially more efficient than your strategy involving
> permutations.
>
> Furthermore, you are essentially reducing the players down to a single skill
> value.  Your code code be even more efficient if you just work with the
> final skill values directly, because combinatorics uses a more efficient
> strategy when it sees duplicate values; if two players have the same skill
> value, there's no real reason to view them as distinct.  Get two balanced
> sets of skill values and then match them back up with the players at the
> end.

Yeah well about that I realized that during the possible teams generation
I don't need to carry around all the values, all I care about is the
name of the player.
The final skill value can be computed later anyway once I have all possible
teams selections..

>
>
> Beyond this brute force strategy, it would be interesting to model this
> problem using the Clojure library "loco", which can optimize using a
> branch-and-bound strategy which is more efficient than trying every possible
> combination.  (I can provide an example of that if you are interested).
> Loco can also take a timeout at which it will return the best thing it has
> found so far.

Yes that would be interesting sure I'll give a look.

>
> Another route is to use Clojure to generate a model to be passed into a
> mixed-integer optimization solver.
>
>
> Once you are dealing with so many players that it is impractical to find the
> optimal solution, you need to look at heuristics. Often, a very simple
> strategy works really well, for example, sort the team into two equal groups
> and randomly make swaps of players between the two teams if it balances
> things out.  When you can't improve things further, restart from another
> random division.  Do this many times and take the best match-up you've
> found.  It will likely be close to optimal.  Beyond that, heuristics like
> tabu search, simulated annealing, genetic algorithms, etc. help you avoid
> getting stuck at a local optimum and get closer to the true optimum.
>
>

Yeah that's a good idea, the first implementation was just a greedy selection
(get the next best player available) and it still works reasonably
well, specially
if the players are more or less on a similar level.
It would be interesting also to train the settings I could add with
some human input,
there are so many adjustements I could do to how the scoring works..

Thanks a lot anyway

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


Generate all possible teams

2015-10-05 Thread andrea crotti
Hi everyone,

I was trying for fun to solve the following problem:

given a list of football players with some defined skills, find out which
team selection would be balanced.

For example given just 4 players A, B, C, D there would be the following
team selections:

- (A, B) vs (C, D)
- (A, C) vs (B, D)
- (A, D) vs (B, C)

So it's a combinatorial problem however both inside teams and inside the
selection the order does not count, so the number of possible teams
is a lot smaller than the actual all possible permutations.

I came up with a brute force solution here:

https://github.com/AndreaCrotti/football/blob/master/src/cljc/football/engine.cljc#L75

which however explodes already for 12 players because:

- it does all the possible permutations of teams (12! in that case)
- partition accordingly (using sets to remove duplicates) and evaluate
  every single one of them

Any idea how to make this faster?
Other advices on the code are welcome as well..

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: Generate all possible teams

2015-10-05 Thread andrea crotti
1. it could be odd in case we don't manage, the first solution I did
was just a greedy algorithm, but that only worked with even number of
players
2. yes well now I pass the rankings and the list of players
separately, but yeah every player will be part of a team
3. this looks the same as 1), and sometimes there can be 5 vs 6 for example

2015-10-05 12:25 GMT+01:00 Mark Engelberg <mark.engelb...@gmail.com>:
> Are there an even number of players?
> Are all players assigned to teams?
> Are the two teams necessarily of equal sizes?
>
> On Mon, Oct 5, 2015 at 3:45 AM, andrea crotti <andrea.crott...@gmail.com>
> wrote:
>>
>> Hi everyone,
>>
>> I was trying for fun to solve the following problem:
>>
>> given a list of football players with some defined skills, find out which
>> team selection would be balanced.
>>
>> For example given just 4 players A, B, C, D there would be the following
>> team selections:
>>
>> - (A, B) vs (C, D)
>> - (A, C) vs (B, D)
>> - (A, D) vs (B, C)
>>
>> So it's a combinatorial problem however both inside teams and inside the
>> selection the order does not count, so the number of possible teams
>> is a lot smaller than the actual all possible permutations.
>>
>> I came up with a brute force solution here:
>>
>>
>> https://github.com/AndreaCrotti/football/blob/master/src/cljc/football/engine.cljc#L75
>>
>> which however explodes already for 12 players because:
>>
>> - it does all the possible permutations of teams (12! in that case)
>> - partition accordingly (using sets to remove duplicates) and evaluate
>>   every single one of them
>>
>> Any idea how to make this faster?
>> Other advices on the code are welcome as well..
>>
>> 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.
>
>
> --
> 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: Generate all possible teams

2015-10-05 Thread andrea crotti
Yes this could actually work thanks, I only need to iterate over all
the possible permutations of the first partition and combine it, still
certainly a lot less stuff to compute.

2015-10-05 12:08 GMT+01:00 Franklin M. Siler <m...@franksiler.com>:
> On Oct 5, 2015, at 0545, andrea crotti <andrea.crott...@gmail.com> wrote:
>
>> Any idea how to make this faster?
>> Other advices on the code are welcome as well..
>
> Why not generate the the possible left-hand teams and then cartesian product 
> with the leftover players?  E.g., if you want to match 2 on 2 and have 
> players A B C D E:
>
> (A,B) cartesian product with (combinations #{C D E})
> (B,C) cartesian product with (combinations #{A D E})
> and so on with
> (C,D)
> (D,E)
>
> I think this will generate each possible match exactly twice- mirror images 
> of each other, but proof is left as an exercise for the reader.
>
> I would imagine there is a better algorithm for this than mine.
>
> Cheers,
>
> Frank Siler
> Siler Industrial Analytics
> 314.799.9405
>
> --
> 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: Generate all possible teams

2015-10-05 Thread andrea crotti
Yes so well for example the rankings can be defined in this way

[{:name "P1"
  :skills {:control 3
   :speed 3
   :tackle 4
   :dribbling 10
   :shoot 4}
  :position :attack}

 {:name "P2"
  :skills {:control 3
   :speed 3
   :tackle 4
   :dribbling 10
   :shoot 4}
  :position :attack}]

and the list of players
["P1"
 "P2"]


Assuming they are in two different files then calling
lein run -r sample_rankings.edn -l sample_players.edn

would produce the desired result.

Well the input gets too big already for 12 players (I didn't wait it
to finish but 12! is 39916800), while it still works in around 2
minutes for 2 players.

The real alternative would be to do some dynamic programming but I was
just hacking something together now and I'm sure even the brute force
can still work quite well in theory..

2015-10-05 13:30 GMT+01:00 Mark Engelberg <mark.engelb...@gmail.com>:
> Sample input data would also be useful, including some examples that are too
> large for you to currently solve with your existing approach.
>
> On Mon, Oct 5, 2015 at 4:36 AM, 'Alan Forrester' via Clojure
> <clojure@googlegroups.com> wrote:
>>
>> On 5 Oct 2015, at 11:45, andrea crotti <andrea.crott...@gmail.com> wrote:
>>
>> > Hi everyone,
>> >
>> > I was trying for fun to solve the following problem:
>> >
>> > given a list of football players with some defined skills, find out
>> > which
>> > team selection would be balanced.
>> >
>> > For example given just 4 players A, B, C, D there would be the following
>> > team selections:
>> >
>> > - (A, B) vs (C, D)
>> > - (A, C) vs (B, D)
>> > - (A, D) vs (B, C)
>> >
>> > So it's a combinatorial problem however both inside teams and inside the
>> > selection the order does not count, so the number of possible teams
>> > is a lot smaller than the actual all possible permutations.
>> >
>> > I came up with a brute force solution here:
>> >
>> >
>> > https://github.com/AndreaCrotti/football/blob/master/src/cljc/football/engine.cljc#L75
>> >
>> > which however explodes already for 12 players because:
>> >
>> > - it does all the possible permutations of teams (12! in that case)
>> > - partition accordingly (using sets to remove duplicates) and evaluate
>> >  every single one of them
>> >
>> > Any idea how to make this faster?
>> > Other advices on the code are welcome as well..
>>
>> I find your code unclear. I can’t tell what problem you’re trying to solve
>> by reading the code or the comments. Do you have a specification of what
>> problem you’re trying to solve? If not, you should write one before you do
>> anything else.
>>
>> Having said that, there is one way I can see that you might make the code
>> slightly less bad. You define a field for your players called “:position”
>> and then never use it. I know almost nothing about football, but I should
>> think you might want the team to have at least one player in each position.
>> So I might do something like (group-by :position players)
>>
>> https://clojuredocs.org/clojure.core/group-by.
>>
>> Then I might generate teams by picking one player in each position or
>> something like that. This would reduce the number of combinations by some
>> unknown amount. More generally, if you have too many combinations, introduce
>> constraints in how you generate them.
>>
>> Alan
>>
>> --
>> 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
> f

Re: Reviewers needed for new Clojure book!

2015-08-26 Thread andrea crotti
I reviewed the Python3 cookbook a while ago and would love to do the
same for a Clojure book,
thanks,
Andrea

2015-08-26 7:03 GMT+01:00 Akhil Wali green.transis...@gmail.com:
 It's great to see so many volunteers for this project!
 Like I mentioned earlier, I have notified Packt and they shall contact
 anyone who is shortlisted as a reviewer.

 On Monday, August 24, 2015 at 12:16:06 PM UTC+5:30, Akhil Wali wrote:

 If anyone is interested in being a reviewer for a new book Mastering
 Clojure by Packt Publishing, please let me know.
 Reviewers will be entitled to a 6 montn subscription of PacktLib.

 Here's the list of topics covered in this title.


 Working with Sequences and Types
 Orchestrating Concurrency and Parallelism
 Parallelization using Reducers
 Writing Macros
 Composing Transducers
 Using Functors and Monads
 Programming with Logic
 Asynchronous Programming
 Reactive Programming
 Working with Tests
 Troubleshooting and Best Practices


 --
 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: feedback on side project

2015-04-14 Thread andrea crotti
Yes thanks to everyone, I actually did read that guide it but after I
implemented that function.
And I really like this convention, but I just need to get used before
I remember to add the rigth ? and !.

Anyway another question about that, so suppose my ref is initialized
as (defonce live-games (ref {}))
what am I supposed to do in the tests?

Should I just create a reset-games function there that resets the
thing again to (ref {})

Or is that wrong because in that case I would access and set some
private implementation detail?
So I should then still move the reset-games function into the
implementation file?

Thanks

2015-04-14 11:03 GMT+01:00 myguidingstar phuthuycuoimayhut...@gmail.com:
 On Tuesday, April 14, 2015 at 2:53:16 AM UTC+7, Sebastian Bensusan wrote:

 As a side notes, in Lisp it is convention to append ! to those functions
 that have side-effects (i.e. mutate state). A good candidate would be
 `reset-games!`.


 This is also an evidence that Andrea hasn't read the Clojure style guide and
 I highly recommend anyone in the community follow it:

 https://github.com/bbatsov/clojure-style-guide#naming

 --
 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: feedback on side project

2015-04-13 Thread andrea crotti
Awesome thanks, the only thing is that the reason why I did the
reset-games thing is because in the tests I can reset things every
time.

  (testing create new game
(reset-games)
(new-game)
(is (= 1 (length-current-games

If I don't do that then it's harder in the tests to have a clean environment..
Maybe that shows a wrong approach in general.
These are the tests I'm talking about
https://github.com/AndreaCrotti/hackthetower_clojurescript/blob/master/hangman/test/hangman/secret_test.clj

2015-04-11 10:02 GMT+01:00 Sebastian Bensusan sbe...@gmail.com:
 Hi,

 I browsed over it, a couple of things:

 `defonce` is meant for code reloading:

 (defonce live-games (ref {})))

 Don't use `for` when you can use `map`:

 (mapv (fn [i] {:char i :visible (not (valid-char i))}))

 Strings can be treated as sequences:

 (first (.toLowerCase (str char)))

 Hope this helps

 Sebastian

 On Friday, April 10, 2015 at 11:35:33 AM UTC+2, Andrea Crotti wrote:

 I created a small project just for learning more Clojure and wanted some
 feedback to improve it and learn some more.

 The code is all here, and it's both a desktop app that can be run with
 lein run or a web API that can be run with lein ring server:


 https://github.com/AndreaCrotti/hackthetower_clojurescript/tree/master/hangman

 The game is basically this
 http://en.wikipedia.org/wiki/Hangman_%28game%29 (without the fancy
 graphics still)

 This is the sample structure of a move right now:
 {:attempts 0
  :seen #{}
  :struct [{:char \a :visible false} {:char \b :visible false} {:char
 \c :visible false}]}

 So every time someone makes a move it will add a new game position to
 a list of game snapshots, for example:

 {long-game-id: [{:attempts 1 :seen ${\a} :struct [{...}]} {:attempts
 0 :seen #{} :struct [{...}]}]}

 and so on and so forth.

 This is the function that alters the reference for example

 (defn set-secret
   Set the secret for a given name
   [game-id game-struct]
   (dosync
(alter live-games
   (fn [d] (assoc d game-id (conj (get d game-id) game-struct))

 Any suggestions is welcome, I also had some troubles trying to
 minimize the refs/atoms while at the same time avoiding passing too
 many things around.

 I think now the solution of using game-id to hide the implementation
 detail in
 https://github.com/AndreaCrotti/hackthetower_clojurescript/blob/master/hangman/src/hangman/secret.clj
 is not too bad but open for better ideas.

 Thanks a lot, and if anyone is interested in joining the project
 please let me know.

 PS. next things to do are some deployment nice stuff, graphics with
 Quill and a UI with 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.

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


Lein repl and Cider repl

2015-04-05 Thread andrea crotti
Hi guys, one question about the Repl and Cider.

When I start the Repl with lein repl, I am in the namespace x.y,
and if I do (doc swap!) I see the documentation showing up.

If instead I start the repl with Cider, it looks like I'm in the same
namespace, however (doc swap!) doesn't work, but if I do
(clojure.repl/doc swap!) actually works.

So I wonder what's the difference, how does running lein repl differ
from using the cider repl?

Is it possible to have the same behaviour in both?

-- 
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: Lein repl and Cider repl

2015-04-05 Thread andrea crotti
Ah thanks awesome, yes that's true I only have to get used to the Cider.
The only thing is not also in Cider then would be find-doc?

And in general, what would be the best way to add some extra
customization to how the Cider repl works?

2015-04-05 9:46 GMT+01:00 Bozhidar Batsov bozhi...@batsov.com:
 Maybe reply interns `clojure.repl/doc` in every namespace. I can tell you
 for a fact that in CIDER the `clojure.repl` functions are interned only in
 the user namespace. We can always change this, but it doesn't make a lot
 of sense. CIDER users normally never use functions like doc as they have
 much more powerful options at their disposal (e.g. `C-c C-d d` (cider-doc)
 or the `C-c C-d g`).

 On 5 April 2015 at 11:41, andrea crotti andrea.crott...@gmail.com wrote:

 Hi guys, one question about the Repl and Cider.

 When I start the Repl with lein repl, I am in the namespace x.y,
 and if I do (doc swap!) I see the documentation showing up.

 If instead I start the repl with Cider, it looks like I'm in the same
 namespace, however (doc swap!) doesn't work, but if I do
 (clojure.repl/doc swap!) actually works.

 So I wonder what's the difference, how does running lein repl differ
 from using the cider repl?

 Is it possible to have the same behaviour in both?

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Some guidance on how to write good property tests with test.check?

2015-03-28 Thread andrea crotti
I think this is almost borderline to be too trivial to test, and
definitively rewriting the same logic in the test is normally not a
good idea..

I would just consider on some simple cases and on the the corner cases.
For example:

(is (false (valid-vector? {:vec []}))
(is (true (valid-vector? {:vec [1 2]}))

And if it makes sense to check that it does not blow up when the input
is very large:
(is (true (valid-vector? {:vec (vec (range 1))})))

So for me you should really just think about the use cases and worry
more about testing the more complex parts of the code.


2015-03-27 7:13 GMT+00:00 John Louis Del Rosario joh...@gmail.com:
 I have a function I want to try out test.check on. But I'm having trouble
 grokking how to write the tests.
 Basically the function checks if a vector value in a hash-map has at least 2
 elements.

 (defn valid-vector?
   [d]
   (= 2 (count (:vec d


 and in my tests (I'm using test.chuck)

 (def gen-data
   (gen/hash-map :v (gen/vector gen/string)))

 (deftest valid-vector-test
   (checking data with at least 2 elements in :vec 100 [d gen-data]
 ;; what to do here?
   ))

 I'm confused on how I should write the body of the test. My first thought is
 to do something like:

 (checking data with at least 2 elements in :vec 100 [d gen-data]
   (if (= 2 (count (:vec d)))
 (is (true? (valid-vector d)))
 (is (false? (valid-vector d)

 But that means I just re-wrote my function definition in the `if` condition.
 Is there a better way to test my function? Or does test.check just not a
 good fit for it?

 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: lein discovery issues

2015-01-30 Thread andrea crotti
Noone on the topic?

Any smarter ways to lookup and try out new stuff with lein otherwise?

2015-01-26 14:22 GMT+00:00 andrea crotti andrea.crott...@gmail.com:
 Hello everyone

 A couple of questions about Lein and how to find templates/libraries.

 I found out now that lein search allows me to search for the last
 stable version of a library, however every time I run it it takes
 forever downloading the index:

 Downloading 
 https://repo1.maven.org/maven2/.index/nexus-maven-repository-index.gz

 Is that normal and if yes how can I make it usable?

 Then if I want to find out the correct version of clojurescript I go to 
 Clojars:
 https://clojars.org/search?q=clojurescript

 And there I find a lot of things but  none of them seems the correct
 thing, this is probably not the right thing:
 https://clojars.org/clojurescript

 I also noticed that many things in clojars don't have code available or
 links to the project, how am I supposed to know what they are actually
 useful for if there is no Readme/Source code or any other information?

 And the last thing is that it would be interesting to see all the
 possible project templates that can be used with a lein new, but from
 what I can understand it depends on the plugins that are currently
 installed with lein, is that correct?

 Thanks a lot,
 Andrea

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


lein discovery issues

2015-01-26 Thread andrea crotti
Hello everyone

A couple of questions about Lein and how to find templates/libraries.

I found out now that lein search allows me to search for the last
stable version of a library, however every time I run it it takes
forever downloading the index:

Downloading 
https://repo1.maven.org/maven2/.index/nexus-maven-repository-index.gz

Is that normal and if yes how can I make it usable?

Then if I want to find out the correct version of clojurescript I go to Clojars:
https://clojars.org/search?q=clojurescript

And there I find a lot of things but  none of them seems the correct
thing, this is probably not the right thing:
https://clojars.org/clojurescript

I also noticed that many things in clojars don't have code available or
links to the project, how am I supposed to know what they are actually
useful for if there is no Readme/Source code or any other information?

And the last thing is that it would be interesting to see all the
possible project templates that can be used with a lein new, but from
what I can understand it depends on the plugins that are currently
installed with lein, is that correct?

Thanks a lot,
Andrea

-- 
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: TDD and lein

2015-01-09 Thread andrea crotti
Thank you all for the great suggestions I'll start using some of these
libraries.

I tried now again with cider and found out what I needed to do.
Apparently if I change any file I have to first do a M-x cider-refresh
and then running the tests will reflect the situation.

Can that not be automated for every save file?
Could be a simple hook on save file that calls that, isn't there
something like this already?

2015-01-09 5:21 GMT+00:00 Dave Della Costa ddellaco...@gmail.com:
 One more suggestion as you mentioned wanting to see more output,
 although this may be different from what you were asking--but still
 worth knowing about:

 https://github.com/pjstadig/humane-test-output

 Cheers,

 DD

 On 2015/01/08 20:30, andrea crotti wrote:
 Hi guys,

 I'm starting to use Clojure a bit more seriously, I knew already Lisp a
 bit and Haskell, in plus I've been using Emacs for a long time so
 luckily it's not as hard, and it's a lot of fun.

 I'm using Emacs + Cider for development and it works wonderfully,
 however I have a few problems/questions trying to do TDD.

 1. Isn't it possible to make Lein more verbose?

It's often quite slow and it would be nice to know what is going
on, I can stand the slowness but at least tell me something :D

 2. When is exactly that I need to run again lein test (which is
painfully slow) and when just rerunning the tests from the same REPL
suffice?

I thought only when changing dependencies, but I had different
experiences so I'm not too sure about the rule.

And what command exactly is Cider triggering when I run the tests?
It would be nice to be able to see somewhere more information like:
- compiling file x
- running tests for y with command z

  3. Does incremental compilation work well/make sense for Clojure?
 I found something but the fact that it's not done straight away in
 Leiningen makes me think it's maybe not much used?

 Thanks a lot, and congratulations to all the developers for the great 
 language!


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


TDD and lein

2015-01-08 Thread andrea crotti
Hi guys,

I'm starting to use Clojure a bit more seriously, I knew already Lisp a
bit and Haskell, in plus I've been using Emacs for a long time so
luckily it's not as hard, and it's a lot of fun.

I'm using Emacs + Cider for development and it works wonderfully,
however I have a few problems/questions trying to do TDD.

1. Isn't it possible to make Lein more verbose?

   It's often quite slow and it would be nice to know what is going
   on, I can stand the slowness but at least tell me something :D

2. When is exactly that I need to run again lein test (which is
   painfully slow) and when just rerunning the tests from the same REPL
   suffice?

   I thought only when changing dependencies, but I had different
   experiences so I'm not too sure about the rule.

   And what command exactly is Cider triggering when I run the tests?
   It would be nice to be able to see somewhere more information like:
   - compiling file x
   - running tests for y with command z

 3. Does incremental compilation work well/make sense for Clojure?
I found something but the fact that it's not done straight away in
Leiningen makes me think it's maybe not much used?

Thanks a lot, and congratulations to all the developers for the great language!

-- 
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: TDD and lein

2015-01-08 Thread andrea crotti
Ah great that's what I wanted, I'll try later.
Does it give some feedback on what it's compiling and what is going on?

I would use just cider in theory but I had some errors with namespaces
(probably my fault) and more importantly it seemed that it didn't
always recompiled things that were changed (again probably my fault).

So in short only changing dependencies should require a new lein
test or lein deps?

And this useful plugins do you normally put them in your
./lein/profiles.clj or in every project you have?

thanks a lot

2015-01-08 11:41 GMT+00:00 Robin Heggelund Hansen skinney...@gmail.com:
 The reason lein is initially slow, has to do with Clojures bootstrapping
 process, which is slow. People tend to avoid starting clojure programs
 repeatedly, and thus do alot of work from the repl, or using leiningen
 plugins which keeps running and listens for changes.

 Take a look at lein-test-refresh for tdd:

 https://github.com/jakemcc/lein-test-refresh

 It detects when you change your code, incrementally compiles and re-runs the
 tests. It runs your tests everytime you save a file :)

 kl. 12:32:44 UTC+1 torsdag 8. januar 2015 skrev Andrea Crotti følgende:

 Hi guys,

 I'm starting to use Clojure a bit more seriously, I knew already Lisp a
 bit and Haskell, in plus I've been using Emacs for a long time so
 luckily it's not as hard, and it's a lot of fun.

 I'm using Emacs + Cider for development and it works wonderfully,
 however I have a few problems/questions trying to do TDD.

 1. Isn't it possible to make Lein more verbose?

It's often quite slow and it would be nice to know what is going
on, I can stand the slowness but at least tell me something :D

 2. When is exactly that I need to run again lein test (which is
painfully slow) and when just rerunning the tests from the same REPL
suffice?

I thought only when changing dependencies, but I had different
experiences so I'm not too sure about the rule.

And what command exactly is Cider triggering when I run the tests?
It would be nice to be able to see somewhere more information like:
- compiling file x
- running tests for y with command z

  3. Does incremental compilation work well/make sense for Clojure?
 I found something but the fact that it's not done straight away in
 Leiningen makes me think it's maybe not much used?

 Thanks a lot, and congratulations to all the developers for the great
 language!

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