Generate all possible teams

2015-10-05 Thread Alan Moore
Not sure it would be a lot more efficient but you could try using 
logic/relational programming with core.match, a datalog library or even a rule 
engine such as Clara. With the later you can use heuristics to trim the search 
space as another poster suggested.

Good luck.

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.


Re: Library suggestions requested for clojure-toolbox.com

2015-10-05 Thread Chris Murphy
I found imagez  (with same name: imagez) 
to be useful for getting and setting pixels and changing the size of a 
raster image. It would go under the Graphics category.

~ Chris

On Tuesday, 6 October 2015 06:41:11 UTC+11, James Reeves wrote:
>
> If you've written or know about a Clojure or ClojureScript library, and 
> it's not already on clojure-toolbox.com , 
> I'd like to hear about it.
>
> Post the name and URL (and an optional category) as reply to this message, 
> and I'll add it to the site.
>
> - James
>

-- 
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] Shrubbery 0.3.0, a stubbing, spying, and mocking library for Clojure protocols

2015-10-05 Thread Brian Guthrie
Great to hear! Let me know if there are any questions I can answer.
Feedback gratefully accepted.

Cheers,

Brian

On Mon, Oct 5, 2015 at 11:56 AM, James Reeves  wrote:

> Very nice. I was looking for something like this.
>
> - James
>
> On 5 October 2015 at 15:14, Brian Guthrie  wrote:
>
>> Clojure protocols are a great way to encapsulate operations with side
>> effects, but suffer from a lack of general test tooling. Shrubbery provides
>> a small set of basic building blocks for working with them:
>>
>>  * stub, which accepts a variable list of protocols and a optional
>> hashmap of simple value implementations and returns an object that reifies
>> all given protocols;
>>  * spy, which accepts an object with at least one protocol
>> implementation and returns a new implementation that tracks the number of
>> times each of its members were called;
>>  * mock, which wraps a stub in a spy, allowing callers to supply basic
>> function implementations and assert against those calls; and
>>  * calls/received?, which in conjunction with the Matcher protocol
>> provide a way to query spies and assert against their state.
>>
>> Shrubbery is test-framework-agnostic, avoids altering runtime state to
>> the degree possible, and uses no macros. It should work nicely with
>> refactorings like rename-function.
>>
>> https://github.com/bguthrie/shrubbery
>>
>> [com.gearswithingears/shrubbery "0.3.0"]
>>
>>
>> New in this release:
>>
>> – Support for multiple protocols in both spies and stubs.
>> – Spies attempt to automatically derive the given implementation's
>> protocols, and tracks calls to all of them. (This behavior can be
>> overridden.)
>> – Replaced all macros with plain functions. (Unfortunately, this means
>> leaning on eval in some cases.)
>>
>> Cheers,
>>
>> Brian
>>
>> --
>> 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: Library suggestions requested for clojure-toolbox.com

2015-10-05 Thread James Reeves
On 6 October 2015 at 01:15, William la Forge  wrote:

> {:name "aatree",
>  :URL "https://github.com/laforge49/aatree";,
>  :category "Data Structures"}
>

Where is this library deployed to? I can't see it on Clojars and there
aren't any other Maven repositories listed in the project file or README.

- James

-- 
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: Library suggestions requested for clojure-toolbox.com

2015-10-05 Thread William la Forge
{:name "aatree", 
 :URL "https://github.com/laforge49/aatree";,
 :category "Data Structures"}

On Monday, October 5, 2015 at 3:41:11 PM UTC-4, James Reeves wrote:
>
> If you've written or know about a Clojure or ClojureScript library, and 
> it's not already on clojure-toolbox.com , 
> I'd like to hear about it.
>
> Post the name and URL (and an optional category) as reply to this message, 
> and I'll add it to the site.
>
> - James
>

-- 
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 Mark Engelberg
On Mon, Oct 5, 2015 at 1:08 PM, andrea crotti 
wrote:

> 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))
>
>
This line is wrong:
size (/ (combo/count-combinations players 2) 2)

You mean (for even number of players):
size (/ (combo/count-combinations players (/ players-count 2)) 2)

-- 
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: Library suggestions requested for clojure-toolbox.com

2015-10-05 Thread Max Countryman
Hi James,

I’m not sure if it’s worth mentioning, but I wrote a port of Boundary’s Flake 
k-ordered unique ID generator for Clojure:

https://github.com/maxcountryman/flake 


Max

> On Oct 5, 2015, at 12:40, James Reeves  wrote:
> 
> If you've written or know about a Clojure or ClojureScript library, and it's 
> not already on clojure-toolbox.com , I'd 
> like to hear about it.
> 
> Post the name and URL (and an optional category) as reply to this message, 
> and I'll add it to the site.
> 
> - James
> 
> -- 
> 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: Library suggestions requested for clojure-toolbox.com

2015-10-05 Thread Sean Grove
Talaria https://github.com/dwwoelfel/talaria [client/server messaging]
"Messaging library for real-time client/server communication over
websockets with fallback to ajax long-polling"

On Mon, Oct 5, 2015 at 4:35 PM, Jony Hudson  wrote:

> Not exactly a library, but Gorilla REPL could fit in there.
> http://gorilla-repl.org . Maybe in the REPL category, although it's not
> really quite that. Probably a bit much to have its own 'notebook' category
> though!
>
>
> Jony
>
>
> On Monday, 5 October 2015 20:41:11 UTC+1, James Reeves wrote:
>>
>> If you've written or know about a Clojure or ClojureScript library, and
>> it's not already on clojure-toolbox.com ,
>> I'd like to hear about it.
>>
>> Post the name and URL (and an optional category) as reply to this
>> message, and I'll add it to the site.
>>
>> - James
>>
> --
> 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: Library suggestions requested for clojure-toolbox.com

2015-10-05 Thread Jony Hudson
Not exactly a library, but Gorilla REPL could fit in there. 
http://gorilla-repl.org . Maybe in the REPL category, although it's not 
really quite that. Probably a bit much to have its own 'notebook' category 
though!


Jony


On Monday, 5 October 2015 20:41:11 UTC+1, James Reeves wrote:
>
> If you've written or know about a Clojure or ClojureScript library, and 
> it's not already on clojure-toolbox.com , 
> I'd like to hear about it.
>
> Post the name and URL (and an optional category) as reply to this message, 
> and I'll add it to the site.
>
> - James
>

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


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

2015-10-05 Thread Andy-
Try to adapt my code:

https://gist.github.com/rauhs/63054a06631c0be598d3

where you change your accept function to incorporate:

http://stackoverflow.com/questions/813710/java-1-6-determine-symbolic-links

HTH

On Saturday, October 3, 2015 at 5:14:51 PM UTC-4, hpw...@gmail.com wrote:
>
> The directory structure is
>/path/top/dir1
>/path/top/dir1/f1
>/path/top/dir1/f2
>/path/top/dir2 -> /another/path/dir2 
> --
>/another/path/dir2/g1
>/another/path/dir2/g2
>
> I tried this (following suggestion):
>
>   (for [file (file-seq dir) :while (.isFile file)] (.getPath file))
>
> It prints out a list with following items:
>   /path/top/dir1/f1
>   /path/top/dir1/f2
>   /path/top/dir2/g1
>   /path/top/dir2/g2
>
> BUT the last two items are the ones that I do NOT want.
> So, I guess I will need to tweak  file-seq so that it will NOT traverse
> /path/top/dir2  since it is a symbolic link.
>
> Is there anyway to tweak file-seq ??
>
> THanks
> HP
>
> On Saturday, October 3, 2015 at 11:59:40 AM UTC-4, Gary Verhaegen wrote:
>>
>> I'm on Windows at the moment, so I can't test, but I think you can 
>> filter on isFile: 
>>
>> (for [file (file-seq dir) 
>>   :where (.isFile file)] 
>>   (.getName file)) 
>>
>> should work, I think. 
>>
>> On 3 October 2015 at 07:36,   wrote: 
>> > Under linux, I have a tree of directories like this: 
>> > 
>> > /path/top 
>> > 
>> > /path/top/dir1  (in here there are two files f1, f2) 
>> > 
>> > /path/top/dir2 -> /another-path/dir2 (a symbolic link) 
>> > 
>> >  and under /another-path/dir2 there are two files g1, 
>> g2 
>> > 
>> > If I use below code, I would get a list of files f1, f2, and g1, g2 
>> > 
>> > (def directory (clojure.java.io/file "/path/top")) 
>> > (def files 
>> > (for [file (file-seq directory)] (.getName file))) 
>> > (files) 
>> > 
>> > BUT I want to skip traversing the directory dir2 since it is a symbolic 
>> > link. 
>> > 
>> > i.e. the list of files that I want to get is f1, f2 only. 
>> > 
>> > Could you please suggest a way to do this ? 
>> > 
>> > THanks 
>> > 
>> > HP 
>> > 
>> > -- 
>> > You received this message because you are subscribed to the Google 
>> > Groups "Clojure" group. 
>> > To post to this group, send email to clo...@googlegroups.com 
>> > Note that posts from new members are moderated - please be patient with 
>> your 
>> > first post. 
>> > To unsubscribe from this group, send email to 
>> > clojure+u...@googlegroups.com 
>> > For more options, visit this group at 
>> > http://groups.google.com/group/clojure?hl=en 
>> > --- 
>> > You received this message because you are subscribed to the Google 
>> Groups 
>> > "Clojure" group. 
>> > To unsubscribe from this group and stop receiving emails from it, send 
>> an 
>> > email to clojure+u...@googlegroups.com. 
>> > For more options, visit https://groups.google.com/d/optout. 
>>
>

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


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


Library suggestions requested for clojure-toolbox.com

2015-10-05 Thread James Reeves
If you've written or know about a Clojure or ClojureScript library, and
it's not already on clojure-toolbox.com ,
I'd like to hear about it.

Post the name and URL (and an optional category) as reply to this message,
and I'll add it to the site.

- James

-- 
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: Clojure Dev Environment

2015-10-05 Thread Sean Corfield
Miguel Ping wrote on Monday, October 5, 2015 at 3:00 AM:
- do you code functions in the repl and copy them to respective files?

I use Emacs/CIDER and code functions in a file, then use C-M-x to evaluate each 
one into the running REPL. I usually keep the REPL in the user namespace and 
require in the namespace I’m working on (C-c C-z to jump to the REPL as needed) 
and then type in expressions to test functions as I go. Later I’ll take a 
transcript of parts of the REPL and add them to my unit test namespace — 
usually just copy’n’paste, followed by some minor edits to turn them into 
Expectations format: (expect {expected} {actual}) which means using C-M-t to 
swap REPL output which has:

user> (some test expression)
{the actual output}

=>

(expect {the actual output}
(some test expression))

Put the cursor after the prompt: user>| then M-delete, type (expect) and slurp 
twice M-) then forward one s-exp C-M-f and swap C-M-t

- do you edit files directly and hook them into the repl?

Yes, but I don’t save them every time since I can use C-M-x to evaluate the 
current form as I type.

- how do you set breakpoints?

I don’t bother. I’ve never liked step debuggers in any language in my 30+ years 
of development :(

- can you do hot-replacement easily? I always see a bunch of stack traces while 
using lein and ring with reload flags

If I want to hot-swap into a running process, I just start a REPL server inside 
the process and connect CIDER to that, instead of starting a standalone REPL in 
Emacs. I tend to use standalone REPLs only for running Expectations anyway 
(where I use a slightly different workflow and keep the REPL in the same 
namespace as the Expectations file (C-c M-n to swap REPL namespaces).

- is there an article or screencast explaining the "feel" of this?

I don’t know, sorry.

Sean


-- 
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 Fluid Dynamics
On Monday, October 5, 2015 at 2:33:50 PM UTC-4, puzzler wrote:
>
> 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:
>

Is a combinatorics library even needed for this?

(-> (for [a teams
  b teams
  :when (= (count a) (count b))]
   #{a b})
  (hash-set))

Should produce all distinct pairs with equal player counts, given that 
"teams" is bound to a collection of teams, each of which is a collection of 
player objects, and "seq" works on the former collection and "count" on the 
latter ones. If each team is something more complex (e.g. a map with a 
:players key) things get only slightly more complicated (e.g. changing 
(count a) to (count (:players a))).

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

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.


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.

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.

-- 
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: Clojure Dev Environment

2015-10-05 Thread Nelson Morris
http://www.parens-of-the-dead.com/ is a screencast series that shows a nice
emacs/cider workflow with some additional usage of figwheel for the cljs
frontend development. No showing off of the debugger yet though. Cursive
should be able to do something similar with keybindings for running tests
and refactorings.

There is little direct repl interaction in this series.  However, many of
the commands use the connection to the development environment to run
things for the user.  For example, clj-autotest runs
https://github.com/magnars/.emacs.d/blob/master/site-lisp/clj-autotest.el#L4
over the connection. Hot swapping works by the tooling sending the new code
over the connection.

Personally, I use the repl a bit more, but for exploratory testing. Does
`(repeat 1 2)` return '(1 1) or '(2) type things.  The majority of writing
code happens in the file, and I let the tooling load it for me.
Additionally, for web development I use a ring server component much like
the screencasts, instead of `lein ring server`. Then I can use the
reloaded/refresh style system to restart everything when needed rather then
needing to kill the whole jvm.

On Mon, Oct 5, 2015 at 5:00 AM, Miguel Ping  wrote:

> Hi Guys,
>
> I've been doing some personal clj for a while, but I never quite grokked
> the whole REPL thing. I normally use Lighttable and/or Cursive as editors,
> I can set up breakpoints and debug the code, but for web I'd like to know
> how seasoned developers work.
> AFAIK people fire up the repl and "do everything from there" but I still
> don't understand some parts:
>
> - do you code functions in the repl and copy them to respective files?
> - do you edit files directly and hook them into the repl?
> - how do you set breakpoints?
> - can you do hot-replacement easily? I always see a bunch of stack traces
> while using lein and ring with reload flags
> - is there an article or screencast explaining the "feel" of this?
>
> My current worfklow is just starting > lein ring server and developing,
> but my general impression is that I need to restart it sometimes.
>
> As I understand it, the repl workflow is very much a lisp thing.
> 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.


Re: Clojure Dev Environment

2015-10-05 Thread Erik Price
vim-fireplace lets you compile individual S-expressions into an existing
nREPL (one in which the rest of your code is typically also loaded and
available), so I typically make all my code changes right in the editor
against the actual file I'm working on. Then I just compile the function
I'm editing and send it to the REPL. I'll usually just add a comment block
near the changes I'm making and put test expressions inside of it, and
execute those expressions as needed to test my changes. It's awesome.

(Of course, I delete that comment block prior to committing my work.)

e

On Monday, October 5, 2015, Robin Heggelund Hansen 
wrote:

> Basically, I use stuart sierra's tools.namespace and component libraries
> to write an application that can be easily reloaded. So I write my code in
> regular files, then i tell the repl to reload my application with the
> latest changes from disk. I can also test the application while it's
> running, because I have access to every function. Hot-replacement is a
> matter of calling 'reset. Although that does technically shut down the
> application, so maybe it can't be called "hot".
>
> Anyway, you can read more here: https://github.com/stuartsierra/component
>
> --
> 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: Changing font size in IntelliJ IDEA / Cursive

2015-10-05 Thread Alan Thompson
Here is the IDEA doc page:
https://www.jetbrains.com/idea/help/configuring-colors-and-fonts.html


On Mon, Oct 5, 2015 at 9:39 AM, Alan Thompson  wrote:

> I came across this super-handy blog posting just now on how to globally
> set the font size/type in IntelliJ.  It is very non-intuitive!
>
> -
>
> from:
> http://www.tilcode.com/how-to-globally-change-the-font-size-in-intellij-idea/
> How to globally change the font size in IntelliJ IDEAToday I learned…
> that you *can* change the font size in IntelliJ IDEA across all editor
> tabs and consistently! It’s not a missing feature and you don’t have to
> rely on the awkward trackpad zoom feature.
>
> Here’s how you do it (on a Mac, anyway).
>
> Go to IntelliJ IDEA —> Preferences —> Editor —> Colors & Fonts —>Font
>
> [image: Screen Shot 2015-02-19 at 9.05.28 AM]
> 
>
> On the right, look for Scheme name.
>
> [image: Screen Shot 2015-02-19 at 9.04.34 AM]
> 
>
> Click the Save As… button and give it a unique name.
>
> [image: Screen Shot 2015-02-19 at 9.03.47 AM]
> 
>
> This step is essential! If you don’t do this step, changes you make to
> Sizefurther down won’t stick, and IntelliJ won’t tell you why. (The popup
> is titled “Save Color Scheme” so it’s easy to see why users might overlook
> its effect on the ability to save font size.)
>
> Now alter the Size setting and you should see the typeface preview change
> to reflect your input. Press OK and you’re done!
>
> [image: Screen Shot 2015-02-19 at 9.06.31 AM]
> 
>
> Googling this problem, I found some conflicting answers
> 
>  about
> how to increase IntelliJ’s font size.
>
> Many IntelliJ users recommend the “trackpad zoom” solution (which you have
> to enable in Preferences —> General —> Change font size (Zoom) with
> Command+ Mouse Wheel), but relying on zooming in results in a patchwork
> of mismatched zoom levels across all your tabs, and you have to manually
> re-zoom each tab. I wanted a consistently larger font-size across all tabs,
> with no manual zoom step, and this did the trick!
>

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


Changing font size in IntelliJ IDEA / Cursive

2015-10-05 Thread Alan Thompson
I came across this super-handy blog posting just now on how to globally set
the font size/type in IntelliJ.  It is very non-intuitive!

-

from:
http://www.tilcode.com/how-to-globally-change-the-font-size-in-intellij-idea/
How to globally change the font size in IntelliJ IDEAToday I learned… that
you *can* change the font size in IntelliJ IDEA across all editor tabs and
consistently! It’s not a missing feature and you don’t have to rely on the
awkward trackpad zoom feature.

Here’s how you do it (on a Mac, anyway).

Go to IntelliJ IDEA —> Preferences —> Editor —> Colors & Fonts —>Font

[image: Screen Shot 2015-02-19 at 9.05.28 AM]


On the right, look for Scheme name.

[image: Screen Shot 2015-02-19 at 9.04.34 AM]


Click the Save As… button and give it a unique name.

[image: Screen Shot 2015-02-19 at 9.03.47 AM]


This step is essential! If you don’t do this step, changes you make to
Sizefurther
down won’t stick, and IntelliJ won’t tell you why. (The popup is titled
“Save Color Scheme” so it’s easy to see why users might overlook its effect
on the ability to save font size.)

Now alter the Size setting and you should see the typeface preview change
to reflect your input. Press OK and you’re done!

[image: Screen Shot 2015-02-19 at 9.06.31 AM]


Googling this problem, I found some conflicting answers

about
how to increase IntelliJ’s font size.

Many IntelliJ users recommend the “trackpad zoom” solution (which you have
to enable in Preferences —> General —> Change font size (Zoom) with
Command+ Mouse Wheel), but relying on zooming in results in a patchwork of
mismatched zoom levels across all your tabs, and you have to manually
re-zoom each tab. I wanted a consistently larger font-size across all tabs,
with no manual zoom step, and this did the trick!

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


Re: newbie Q: where is isSymbolicLink function and how to access it ?

2015-10-05 Thread Ray Miller
You need Java interop for this:

(import 'java.nio,file.Files)

(Files/isSymbolicLink (.toPath (io/file "/some/path")))

See http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html
for the other methods provided by this class.

On 5 October 2015 at 16:47,   wrote:
>
> In the clojure.java.io  there are these two functions:
> isDirectory
> isFile
>
> But there is no isSymbolicLink (for unix, linux).
>
> (1) Could someone tell me where I can find such a function ?
>  In another library not listed on clojure,org ??
>
> (2) What do I need to do in order to use it ?
>
> Thanks
> HP
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

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


Re: [ANN] Shrubbery 0.3.0, a stubbing, spying, and mocking library for Clojure protocols

2015-10-05 Thread James Reeves
Very nice. I was looking for something like this.

- James

On 5 October 2015 at 15:14, Brian Guthrie  wrote:

> Clojure protocols are a great way to encapsulate operations with side
> effects, but suffer from a lack of general test tooling. Shrubbery provides
> a small set of basic building blocks for working with them:
>
>  * stub, which accepts a variable list of protocols and a optional
> hashmap of simple value implementations and returns an object that reifies
> all given protocols;
>  * spy, which accepts an object with at least one protocol implementation
> and returns a new implementation that tracks the number of times each of
> its members were called;
>  * mock, which wraps a stub in a spy, allowing callers to supply basic
> function implementations and assert against those calls; and
>  * calls/received?, which in conjunction with the Matcher protocol
> provide a way to query spies and assert against their state.
>
> Shrubbery is test-framework-agnostic, avoids altering runtime state to the
> degree possible, and uses no macros. It should work nicely with
> refactorings like rename-function.
>
> https://github.com/bguthrie/shrubbery
>
> [com.gearswithingears/shrubbery "0.3.0"]
>
>
> New in this release:
>
> – Support for multiple protocols in both spies and stubs.
> – Spies attempt to automatically derive the given implementation's
> protocols, and tracks calls to all of them. (This behavior can be
> overridden.)
> – Replaced all macros with plain functions. (Unfortunately, this means
> leaning on eval in some cases.)
>
> Cheers,
>
> Brian
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


newbie Q: where is isSymbolicLink function and how to access it ?

2015-10-05 Thread hpwei01

In the clojure.java.io  there are these two functions:
isDirectory
isFile

But there is no isSymbolicLink (for unix, linux).

(1) Could someone tell me where I can find such a function ?
 In another library not listed on clojure,org ??

(2) What do I need to do in order to use it ?

Thanks
HP

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


[ANN] Shrubbery 0.3.0, a stubbing, spying, and mocking library for Clojure protocols

2015-10-05 Thread Brian Guthrie
Clojure protocols are a great way to encapsulate operations with side
effects, but suffer from a lack of general test tooling. Shrubbery provides
a small set of basic building blocks for working with them:

 * stub, which accepts a variable list of protocols and a optional hashmap
of simple value implementations and returns an object that reifies all
given protocols;
 * spy, which accepts an object with at least one protocol implementation
and returns a new implementation that tracks the number of times each of
its members were called;
 * mock, which wraps a stub in a spy, allowing callers to supply basic
function implementations and assert against those calls; and
 * calls/received?, which in conjunction with the Matcher protocol provide
a way to query spies and assert against their state.

Shrubbery is test-framework-agnostic, avoids altering runtime state to the
degree possible, and uses no macros. It should work nicely with
refactorings like rename-function.

https://github.com/bguthrie/shrubbery

[com.gearswithingears/shrubbery "0.3.0"]


New in this release:

– Support for multiple protocols in both spies and stubs.
– Spies attempt to automatically derive the given implementation's
protocols, and tracks calls to all of them. (This behavior can be
overridden.)
– Replaced all macros with plain functions. (Unfortunately, this means
leaning on eval in some cases.)

Cheers,

Brian

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


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

2015-10-05 Thread ru
Thank you very much, Sean and Oliver!

condas-> really awesome!

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

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


Re: 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 :
> On Oct 5, 2015, at 0545, andrea crotti  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
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 :
> 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 
> 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 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 :
> 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
>  wrote:
>>
>> On 5 Oct 2015, at 11:45, andrea crotti  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
> 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 fr

Re: Generate all possible teams

2015-10-05 Thread Mark Engelberg
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  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 
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 'Alan Forrester' via Clojure
On 5 Oct 2015, at 11:45, andrea crotti  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.


Re: Generate all possible teams

2015-10-05 Thread Mark Engelberg
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 
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.


Re: Generate all possible teams

2015-10-05 Thread Franklin M. Siler
On Oct 5, 2015, at 0545, andrea crotti  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.


Re: Clojure Dev Environment

2015-10-05 Thread Robin Heggelund Hansen
Basically, I use stuart sierra's tools.namespace and component libraries to 
write an application that can be easily reloaded. So I write my code in 
regular files, then i tell the repl to reload my application with the 
latest changes from disk. I can also test the application while it's 
running, because I have access to every function. Hot-replacement is a 
matter of calling 'reset. Although that does technically shut down the 
application, so maybe it can't be called "hot".

Anyway, you can read more here: https://github.com/stuartsierra/component

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


Clojure Dev Environment

2015-10-05 Thread Miguel Ping
Hi Guys,

I've been doing some personal clj for a while, but I never quite grokked 
the whole REPL thing. I normally use Lighttable and/or Cursive as editors, 
I can set up breakpoints and debug the code, but for web I'd like to know 
how seasoned developers work.
AFAIK people fire up the repl and "do everything from there" but I still 
don't understand some parts:

- do you code functions in the repl and copy them to respective files?
- do you edit files directly and hook them into the repl?
- how do you set breakpoints?
- can you do hot-replacement easily? I always see a bunch of stack traces 
while using lein and ring with reload flags
- is there an article or screencast explaining the "feel" of this?

My current worfklow is just starting > lein ring server and developing, but 
my general impression is that I need to restart it sometimes.

As I understand it, the repl workflow is very much a lisp thing.
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.