Contest description:
http://www.codetown.us/group/contesttown/forum/topics/wari-contest-1
Code:
http://github.com/ericlavigne/island-wari/
Running application:
http://ericlavigne.net:8054/
The only suggestion I have is that compojure.html automatically
expands seqs, so:
[:span '(a b c)]
Is equivalent to:
[:span 'a 'b 'c]
This means you can use functions like 'map' in a more concise fashion:
[:tr (map #(vector :td %) (interpose horiz (repeat 7 small)))]
Or perhaps using a for:
[:tr (for [x (interpose horiz (repeat 7 small))] [:td x])]
- James
The part that bothered me most was my routes definition, specifically:
(GET "/:whosturn/:computerplays/:a/:b/:c/:d/:e/:f/:g/:h/:i/:j/:k/:l/:m/:n"
(let [turn (Integer/parseInt (params :whosturn))
board (map #(Integer/parseInt (params %))
[:a :b :c :d :e :f :g
:h :i :j :k :l :m :n])]
...
I would have wanted to specify names for the first two params, then
indicate that there were 14 other params that should be put in a list.
My approach of typing out 14 letters would not have worked so well for
a larger game board.
> --
>
> You received this message because you are subscribed to the Google Groups "Compojure" group.
> To post to this group, send email to comp...@googlegroups.com.
> To unsubscribe from this group, send email to compojure+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/compojure?hl=en.
>
>
>
(GET
"/:whosturn/:computerplays/:x/:x/:x/:x/:x/:x/:x/:x/:x/:x/:x/:x/:x/:x"
(let [turn (Integer/parseInt (params :whosturn))
board (map #(Integer/parseInt %) (params :x))]
...))
If a Compojure route contains more than one parameter with the same
name, it collects the results in a vector.
- James
On Dec 28, 2:07 pm, Eric Lavigne <lavigne.e...@gmail.com> wrote:
> Thanks, James. I simplified the rendering as you suggested.
>
> The part that bothered me most was my routes definition, specifically:
>
> (GET "/:whosturn/:computerplays/:a/:b/:c/:d/:e/:f/:g/:h/:i/:j/:k/:l/:m/:n"
> (let [turn (Integer/parseInt (params :whosturn))
> board (map #(Integer/parseInt (params %))
> [:a :b :c :d :e :f :g
> :h :i :j :k :l :m :n])]
> ...
>
> I would have wanted to specify names for the first two params, then
> indicate that there were 14 other params that should be put in a list.
> My approach of typing out 14 letters would not have worked so well for
> a larger game board.
>
> On Mon, Dec 28, 2009 at 5:57 AM, James Reeves
>