Performant flattening of nested data structures

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

Currently I'm using the fn's:

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

  (cond

   (map? m) (reduce into

(map (fn [[k v]]

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

  (str ks . (name k))

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

   (and (sequential? m)

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

   (map-indexed (fn 
[idx itm]

  
(flatten-keys* a


 (str ks [ idx ])


 itm))

(seq 
m)))

   :else (assoc a ks m)))

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

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

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


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

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

Thanks for the help!

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


Re: Performant flattening of nested data structures

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

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

  (cond

   ;; Is a map?

   (map? m) (reduce into

(map (fn [[k v]]

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

 (seq m)))

   ;; Is an arr/vec/seq?

   (and (sequential? m)

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

   (map-indexed (fn 
[idx itm]

  
(flatten-keys* a


 (str ks [ idx ])


 itm))

(seq 
m)))

   ;; Is not a collection

   :else (assoc a ks m)))

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

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


Clojure and Maven

2014-06-13 Thread Mark Watson
Hey guys,

New to Maven and need to convert my leiningen project to Maven to integrate 
with TeamCity.

I can run:

mvn clean install


and it builds the .jar file.

However, when I try to run the jar file: 

java -jar target/my-app-jar-with-dependencies.jar


I get the error: 

Error: Could not find or load main class my-namespace.core


My namespace definition looks like:

(ns my-namespace.core
  (:gen-class))

My pom.xml looks like:

build
plugins
plugin
groupIdcom.theoryinpractise/groupId
artifactIdclojure-maven-plugin/artifactId
version1.3.20/version
configuration
scriptsrc/my-namespace/run.clj/script
testscripttest/my-namespace/run_test.clj/testscript
/configuration
/plugin

plugin
artifactIdmaven-jar-plugin/artifactId
version2.4/version
configuration
archive
manifest
mainClassmy-namespace.core/mainClass
/manifest
/archive
/configuration
/plugin

plugin
artifactIdmaven-assembly-plugin/artifactId
executions
execution
phasepackage/phase
goals
goalsingle/goal
/goals
/execution
/executions
configuration
archive
manifest
mainClassmy-namespace.core/mainClass
/manifest
/archive
descriptorRefs
descriptorRefjar-with-dependencies/descriptorRef
/descriptorRefs
/configuration
/plugin

/plugins
/build

What am I doing wrong? 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: Clojure and Maven

2014-06-13 Thread Mark Watson
Oh, and I have a function:

(defn -main []...)

In my-namespace.core

-- 
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 and Maven

2014-06-13 Thread Mark Watson
Ah, forgot about that.

Still having the same issue with that resolved unfortunately.



On Friday, June 13, 2014 12:08:00 PM UTC-4, Alex Miller wrote:

 Not sure if this is the only thing to change, but :

mainClassmy-namespace.core/mainClass

 should be:


mainClassmy_namespace.core/mainClass

 While Clojure uses -'s in namespace names, they are always _'s in the 
 output package/class names.


 On Friday, June 13, 2014 10:34:54 AM UTC-5, Mark Watson wrote:

 Hey guys,

 New to Maven and need to convert my leiningen project to Maven to 
 integrate with TeamCity.

 I can run:

 mvn clean install


 and it builds the .jar file.

 However, when I try to run the jar file: 

 java -jar target/my-app-jar-with-dependencies.jar


 I get the error: 

 Error: Could not find or load main class my-namespace.core


 My namespace definition looks like:

 (ns my-namespace.core
   (:gen-class))

 My pom.xml looks like:

 build
 plugins
 plugin
 groupIdcom.theoryinpractise/groupId
 artifactIdclojure-maven-plugin/artifactId
 version1.3.20/version
 configuration
 scriptsrc/my-namespace/run.clj/script
 testscripttest/my-namespace/run_test.clj/testscript
 /configuration
 /plugin

 plugin
 artifactIdmaven-jar-plugin/artifactId
 version2.4/version
 configuration
 archive
 manifest
 mainClassmy-namespace.core/mainClass
 /manifest
 /archive
 /configuration
 /plugin

 plugin
 artifactIdmaven-assembly-plugin/artifactId
 executions
 execution
 phasepackage/phase
 goals
 goalsingle/goal
 /goals
 /execution
 /executions
 configuration
 archive
 manifest
 mainClassmy-namespace.core/mainClass
 /manifest
 /archive
 descriptorRefs
 descriptorRefjar-with-dependencies/descriptorRef
 /descriptorRefs
 /configuration
 /plugin

 /plugins
 /build

 What am I doing wrong? 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: Clojure and Maven

2014-06-13 Thread Mark Watson
Ah, forgot about that.

Still having the same issue with that resolved unfortunately.

-- 
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 and Maven

2014-06-13 Thread Mark Watson
There are no .class files in my jar

I assume some file-path is messed up, I just can't figure out where.

-- 
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: Leiningen just hangs

2014-05-16 Thread Mark Watson
I suspect it was something of that nature.

Ended up being that someone else was in the process of moving my VM and I 
didn't read my emails :-)

All working now.

On Thursday, May 15, 2014 3:49:08 PM UTC-4, Gary Trakhman wrote:

 Oh yea, GC churn can take up a lot of time.  The illusion of 'infinite 
 memory' :-).


 On Thu, May 15, 2014 at 3:47 PM, Armando Blancas 
 abm2...@gmail.comjavascript:
  wrote:

 I've had this problem and I suspect is low memory. It happened often with 
 an old box with 1G running Fedora 20, but I've also seen it with my laptop 
 if I leave too many leftover jvm processes running (with 4G allocated for a 
 virtual box instance); on my 16G mac it never happens. So freeing up some 
 memory has fixed it for me.


 On Thursday, May 15, 2014 11:34:36 AM UTC-7, Mark Watson wrote:

 I'm running Leiningen on CentOS 6.5. Everything was working fine, and 
 today when I try lein run it just hangs. It takes about 15 minutes for 
 lein version to return.

 The project works fine on my macbook pro, and another CentOS box.

 I deleted ~/.m2 and reinstalled Leiningen. I updated Leiningen. I 
 removed and reinstalled Java as well.

 Has anyone else come across this? I have no clue what I did or what the 
 problem could be. Any help would be greatly appreciated.

 -bash-4.1$ java -version
 java version 1.7.0_55
 OpenJDK Runtime Environment (rhel-2.4.7.1.el6_5-x86_64 u55-b13)
 OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)

 -bash-4.1$ lein version
 Leiningen 2.3.4 on Java 1.7.0_55 OpenJDK 64-Bit Server VM

  -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.comjavascript:
 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 javascript:
 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 javascript:.
 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.


Leiningen just hangs

2014-05-15 Thread Mark Watson
I'm running Leiningen on CentOS 6.5. Everything was working fine, and today 
when I try lein run it just hangs. It takes about 15 minutes for lein 
version to return.

The project works fine on my macbook pro, and another CentOS box.

I deleted ~/.m2 and reinstalled Leiningen. I updated Leiningen. I removed 
and reinstalled Java as well.

Has anyone else come across this? I have no clue what I did or what the 
problem could be. Any help would be greatly appreciated.

-bash-4.1$ java -version
java version 1.7.0_55
OpenJDK Runtime Environment (rhel-2.4.7.1.el6_5-x86_64 u55-b13)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)

-bash-4.1$ lein version
Leiningen 2.3.4 on Java 1.7.0_55 OpenJDK 64-Bit Server VM

-- 
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: Leiningen just hangs

2014-05-15 Thread Mark Watson
I don't have a ~/.lein/profiles.clj file. I removed all the Leiningen 
files, tried with a fresh install, still no luck.



On Thursday, May 15, 2014 2:38:34 PM UTC-4, Gary Trakhman wrote:

 Did you try to clean out ~/.lein/profiles.clj?


 On Thu, May 15, 2014 at 2:34 PM, Mark Watson mkw...@gmail.comjavascript:
  wrote:

 I'm running Leiningen on CentOS 6.5. Everything was working fine, and 
 today when I try lein run it just hangs. It takes about 15 minutes for 
 lein version to return.

 The project works fine on my macbook pro, and another CentOS box.

 I deleted ~/.m2 and reinstalled Leiningen. I updated Leiningen. I removed 
 and reinstalled Java as well.

 Has anyone else come across this? I have no clue what I did or what the 
 problem could be. Any help would be greatly appreciated.

 -bash-4.1$ java -version
 java version 1.7.0_55
 OpenJDK Runtime Environment (rhel-2.4.7.1.el6_5-x86_64 u55-b13)
 OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)

 -bash-4.1$ lein version
 Leiningen 2.3.4 on Java 1.7.0_55 OpenJDK 64-Bit Server VM
  
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.comjavascript:
 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 javascript:
 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 javascript:.
 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: Leiningen just hangs

2014-05-15 Thread Mark Watson
Tried it

On Thursday, May 15, 2014 3:17:58 PM UTC-4, Magomimmo wrote:

 try removing ~/.m2

 On 15 May 2014, at 20:56, Mark Watson mkw...@gmail.com javascript: 
 wrote:

 I don't have a ~/.lein/profiles.clj file. I removed all the Leiningen 
 files, tried with a fresh install, still no luck.



 On Thursday, May 15, 2014 2:38:34 PM UTC-4, Gary Trakhman wrote:

 Did you try to clean out ~/.lein/profiles.clj?


 On Thu, May 15, 2014 at 2:34 PM, Mark Watson mkw...@gmail.com wrote:

 I'm running Leiningen on CentOS 6.5. Everything was working fine, and 
 today when I try lein run it just hangs. It takes about 15 minutes for 
 lein version to return.

 The project works fine on my macbook pro, and another CentOS box.

 I deleted ~/.m2 and reinstalled Leiningen. I updated Leiningen. I 
 removed and reinstalled Java as well.

 Has anyone else come across this? I have no clue what I did or what the 
 problem could be. Any help would be greatly appreciated.

 -bash-4.1$ java -version
 java version 1.7.0_55
 OpenJDK Runtime Environment (rhel-2.4.7.1.el6_5-x86_64 u55-b13)
 OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)

 -bash-4.1$ lein version
 Leiningen 2.3.4 on Java 1.7.0_55 OpenJDK 64-Bit Server VM

 -- 
 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 clo...@googlegroups.com javascript:
 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 javascript:
 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 javascript:.
 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.


Reduce vs. Comp

2014-05-07 Thread Mark Watson
What is the difference between:

(reduce #(%2 %) 6 [(partial + 12) (partial * -1)])

and

((apply comp [(partial * -1) (partial + 12)]) 6)

Using reduce *looks* nicer to me, but I feel like I'm re-implementing comp. 
Their performance is also the same (go inlining!).

-- 
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: Reduce vs. Comp

2014-05-07 Thread Mark Watson
I agree. I guess I was specifically thinking of a list of functions where 
the length of the list, and the functions themselves, are defined at 
run-time. Which would lead to some nasty code using the threading macros. 
(Unless someone has an example of this not being the case)


On Wednesday, May 7, 2014 1:00:17 PM UTC-4, Gary Johnson wrote:

 Reduce is indeed a swiss-army knife for functional programming over 
 sequences.
 Of course, in this particular case (i.e., apply a sequence of functions in 
 order to an initial value), Clojure's threading operators are the idiomatic 
 way to go.

 (- 6 (+ 12) (* -1))

   Cheers,
 ~Gary


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


Mock db data for unit tests

2014-03-07 Thread Mark Watson
I have a web service that uses Korma for interacting with my db. To mock 
data for unit tests I want to re-bind korma.core/select to return known 
data and not hit a db.

Currently I have a db ns:

(nsservices.db
  (:require [korma.core :refer :all]
   [korma.db :refer :all]))


With a function 'func-select' that calls korma.core/select

And a test ns:

(ns ad-gallery-services.core-test
  (:require [clojure.test :refer :all]
[ad-gallery-services.db :refer :all]
[ad-gallery-services.web :refer :all]))

(deftest func-select-test
  (testing Return nil if select returns empty
(with-redefs [korma.core/select (fn [ _] [])]
  (require 'ad-gallery-services.db :reload)
  (is (= (func-select 1)
 nil)


However, it keeps throwing the exception:

ArityException Wrong number of args (1) passed to: core$where

Why is it even evaluating 'where', and (most importantly) how can I mock 
this data?

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


Maximize Fantasy Baseball Lineup

2013-09-13 Thread Mark Watson
Hey, newish user here.

I want to make an app that finds the optimal lineup for fantasy baseball 
games.

Each player is assigned a cost, the average points they earn a game, and 
position. For example: Andrew McCutchen, 3.4, 4900, OF

You have to pick one catcher, one pitcher, one first basemen, one second 
basemen, one shortstop, one third basemen, and three outfielders. The catch 
is you also have to stay below a predetermined total cost of your team. I 
want to maximize my total average points while staying under the cost limit.

My plan was to iterate through every possible combo, and swap an atom if I 
find a lineup with a better total average points while staying under the 
total cost limit.

My issues are:

1) This seems like an inelegant solution (brute force)

2) I don't know of a good way to handle the fact that I need to choose 
three outfielders, but can't choose any one outfielder multiple times

Any advice? 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/groups/opt_out.


Fantasy Baseball Lineup Optimization

2013-09-13 Thread Mark Watson
Hi, newish user here.

I want to make an app that finds a simple, optimized, fantasy baseball 
lineup.

Each player has a cost associated with them, as well as the average points 
per game they score, and position. For example: Mike Napoli, 4600, 2.9, 1B

You have to choose one of each position: catcher, pitcher, 1st base, 2nd 
base, 3rd base, and shortstop. You also have to pick three outfielders. It 
would be easy to just pick the players with the highest points per game, 
but you also need to stay under a specified total cost.

Currently, I iterate through every possibility, and swap an atom with a new 
lineup if the total average points is higher, while staying under the total 
cost limit.

My issues are:

1) This seems like an inelegant solution (brute force)
2) I don't know how to best handle the fact that I need to select three 
outfielders from a single list, and cannot select one player more than once

Any advice, suggestions would be great. 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/groups/opt_out.


Re: A Performance Comparison of SBCL Clojure

2012-08-25 Thread Mark Watson
Hello Ray,

Just a factor of 3 slower is pretty good :-)

The increased memory use is more disturbing to me since I often use
Clojure+Noir for deploying small web services and web apps. The extra
memory is more of a hassle than slightly slower execution speed.

Best regards,
Mark


On Sat, Aug 25, 2012 at 1:51 PM, Raymond de Lacaze dela...@hotmail.com wrote:
 Folks,



 Here’s a performance benchmark comparison of SBCL and Clojure.



 http://shootout.alioth.debian.org/u32/benchmark.php?test=alllang=clojurelang2=sbcl



 Interesting…



 --rpl



 Raymond Pierre de Lacaze

 dela...@hotmail.com





-- 
Mark Watson, consultant and author: http://markwatson.com

It is better to travel well than to arrive. - Buddha

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