A clojurescript newbie q.

2012-08-12 Thread mmwaikar
Hi,

I am experimenting with clojurescript, and have the following page -

(ns maze.views.mm
  (:use [noir.core :only [defpartial]]
[hiccup.page :only [html5 include-js]]
[hiccup.element :only [javascript-tag]]
[maze.views.cssgenerator]
[maze.constants]))

(defn generate-options []
  (map #(html5 [:option {:value %1} %2]) (range 0 4) difficulty-levels))

;; Creates the main html layout
(defpartial generate-layout
  [params title & content]
  (html5
   [:head [:title title]
[:meta {:charset "UTF-8"}]
[:style {:type "text/css"} (global-css params)]
(include-js 
"https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js";)]
   
   [:body {:bgcolor "#FF"}
[:table {:cellpading 20 :cellspacing 0 :width "100%" :border 0}
 [:tr
  [:td {:width "70%" :align "center"}
   [:div#mazediv]]
  
  [:td {:width "30%" :align "center" :valign "top"}
   [:h1 "Mysterious"
[:br "Maze"]]
   [:small directions]
   [:p]
   [:div#scorediv {:style "background-color: grey;color: yellow"}
"SCORE : 0"]
   [:p]
   [:div#statdiv {:style "background-color: grey;color: yellow"}
"WAITING..."]
   [:p]
   [:select#level
(generate-options)]
   [:p]
   [:input#start {:type :button :value "Start New Game"}

[:div.copy
 "Copyright © 2012 Manoj Waikar. All Rights Reserved."]
(javascript-tag "var CLOSURE_NO_DEPS = true;")
(include-js "/cljs/main.js")]))

and this is in my main.cljs file -

(ns maze.main
  (:use [jayq.core :only [$]]))

;; frequently used selectors
(def $start ($ :#start))
(def $statdiv ($ :#statdiv))
(def $scorediv ($ :#scorediv))

(defn start-game []
  ())

(.click ($ :#start
 (fn [e]
   (println "hey")
   (js/alert "clicked"

Here's my project.clj (just in case) -

(defproject maze "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME";
  :license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.4.0"]
 [hiccup "1.0.0"]
 [noir "1.3.0-beta10"]
 [cssgen "0.2.6"]
 [jayq "0.1.0-alpha4"]]
  :plugins [[lein-cljsbuild "0.1.10"]]
  :hooks [leiningen.cljsbuild]
  :jvm-opts ["-Dfile.encoding=utf-8"]
  :cljsbuild
  {:builds
   [{:source-path "src-cljs",
 :compiler
 {:output-dir "resources/public/cljs/",
  :output-to "resources/public/cljs/main.js",
  :optimizations :whitespace,
  :pretty-print true}}]}
  :main maze.server)

The problem is that the click event of the start button is not getting 
properly registered.
Please let me know what is the problem.

Thanks,
Manoj.

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

Re: A clojurescript newbie q.

2012-08-12 Thread Moritz Ulrich
Take a look at the javascript console. Most likely the `prinln'
generates an error because *print-fn* isn't bound. It's not usual to
use println on the client side. Logging to console is done via (.log
js/console obj1 obj2 ...)

On Sun, Aug 12, 2012 at 10:01 AM, mmwaikar  wrote:
> Hi,
>
> I am experimenting with clojurescript, and have the following page -
>
> (ns maze.views.mm
>   (:use [noir.core :only [defpartial]]
> [hiccup.page :only [html5 include-js]]
> [hiccup.element :only [javascript-tag]]
> [maze.views.cssgenerator]
> [maze.constants]))
>
> (defn generate-options []
>   (map #(html5 [:option {:value %1} %2]) (range 0 4) difficulty-levels))
>
> ;; Creates the main html layout
> (defpartial generate-layout
>   [params title & content]
>   (html5
>[:head [:title title]
> [:meta {:charset "UTF-8"}]
> [:style {:type "text/css"} (global-css params)]
> (include-js
> "https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js";)]
>
>[:body {:bgcolor "#FF"}
> [:table {:cellpading 20 :cellspacing 0 :width "100%" :border 0}
>  [:tr
>   [:td {:width "70%" :align "center"}
>[:div#mazediv]]
>
>   [:td {:width "30%" :align "center" :valign "top"}
>[:h1 "Mysterious"
> [:br "Maze"]]
>[:small directions]
>[:p]
>[:div#scorediv {:style "background-color: grey;color: yellow"}
> "SCORE : 0"]
>[:p]
>[:div#statdiv {:style "background-color: grey;color: yellow"}
> "WAITING..."]
>[:p]
>[:select#level
> (generate-options)]
>[:p]
>[:input#start {:type :button :value "Start New Game"}
>
> [:div.copy
>  "Copyright © 2012 Manoj Waikar. All Rights Reserved."]
> (javascript-tag "var CLOSURE_NO_DEPS = true;")
> (include-js "/cljs/main.js")]))
>
> and this is in my main.cljs file -
>
> (ns maze.main
>   (:use [jayq.core :only [$]]))
>
> ;; frequently used selectors
> (def $start ($ :#start))
> (def $statdiv ($ :#statdiv))
> (def $scorediv ($ :#scorediv))
>
> (defn start-game []
>   ())
>
> (.click ($ :#start
>  (fn [e]
>(println "hey")
>(js/alert "clicked"
>
> Here's my project.clj (just in case) -
>
> (defproject maze "0.1.0-SNAPSHOT"
>   :description "FIXME: write description"
>   :url "http://example.com/FIXME";
>   :license {:name "Eclipse Public License"
> :url "http://www.eclipse.org/legal/epl-v10.html"}
>   :dependencies [[org.clojure/clojure "1.4.0"]
>  [hiccup "1.0.0"]
>  [noir "1.3.0-beta10"]
>  [cssgen "0.2.6"]
>  [jayq "0.1.0-alpha4"]]
>   :plugins [[lein-cljsbuild "0.1.10"]]
>   :hooks [leiningen.cljsbuild]
>   :jvm-opts ["-Dfile.encoding=utf-8"]
>   :cljsbuild
>   {:builds
>[{:source-path "src-cljs",
>  :compiler
>  {:output-dir "resources/public/cljs/",
>   :output-to "resources/public/cljs/main.js",
>   :optimizations :whitespace,
>   :pretty-print true}}]}
>   :main maze.server)
>
> The problem is that the click event of the start button is not getting
> properly registered.
> Please let me know what is the problem.
>
> Thanks,
> Manoj.
>
> --
> 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 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


Re: Strange coercions

2012-08-12 Thread Pierre-Henry Perret

Project is here : bOOtOne 
Le dimanche 5 août 2012 03:45:59 UTC+2, Pierre-Henry Perret a écrit :
>
> Running a lein2 check gives ->
> ___
> Exception in thread "main" java.lang.IllegalArgumentException: No 
> implementation of method: :as-file of protocol: #'
> clojure.java.io/Coercions found for class: c
> lojure.lang.PersistentVector
> _
>
> I would precate my lein1 project becoming a lein2 one ..
>
> Someone has an idea ?
> 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

Pattern of Succinctness

2012-08-12 Thread Takahiro Hozumi
Hi,
I would like to know common technics that make code succinct.

For example:
(or (:b {:a 1}) 0)
(:b {:a 1} 0)

(if-not x 1 2)
(if x 2 1)

(filter #(not (nil? %)) coll)
(filter identity coll) ;; nearly equal

Please let me know any tips you found.

Cheers,
Takahiro.

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

Re: Pattern of Succinctness

2012-08-12 Thread Tamreen Khan
Is the last one considered generally more readable? I think the following
is clearer while still not having as much noise as the first filter example:

(filter (partial not nil?) coll)

On Sun, Aug 12, 2012 at 1:35 PM, Takahiro Hozumi wrote:

> Hi,
> I would like to know common technics that make code succinct.
>
> For example:
> (or (:b {:a 1}) 0)
> (:b {:a 1} 0)
>
> (if-not x 1 2)
> (if x 2 1)
>
> (filter #(not (nil? %)) coll)
> (filter identity coll) ;; nearly equal
>
> Please let me know any tips you found.
>
> Cheers,
> Takahiro.
>
> --
> 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 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

Re: Pattern of Succinctness

2012-08-12 Thread Bill Caputo

On Aug 12, 2012, at 12:38 PM, Tamreen Khan wrote:
> (filter #(not (nil? %)) coll)
> (filter identity coll) ;; nearly equal

> Is the last one considered generally more readable? I think the following is 
> clearer while still not having as much noise as the first filter example:
> 
> (filter (partial not nil?) coll)

To me it is. I read/heard somewhere that the identity check was idiomatic, and 
started using it to the point where I find myself saying "filter identity" as 
slang for keeping only the valid things.

but that's just me (maybe)... don't know that it is generally considered more 
readable (but I think so).


bill

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

AW: Re: Pattern of Succinctness

2012-08-12 Thread Meikel Brandmeyer
Hi,

in case you really want only nils filtered out:

(filter (complement nil?) coll)
or
(remove nil? coll)

Kind regards
Meikel

-Ursprüngliche Nachricht-
Von: Bill Caputo 
An: Tamreen Khan 
Cc: clojure@googlegroups.com
Gesendet: So, 12 Aug 2012, 19:43:58 MESZ
Betreff: Re: Pattern of Succinctness


On Aug 12, 2012, at 12:38 PM, Tamreen Khan wrote:
> (filter #(not (nil? %)) coll)
> (filter identity coll) ;; nearly equal

> Is the last one considered generally more readable? I think the following is 
> clearer while still not having as much noise as the first filter example:
> 
> (filter (partial not nil?) coll)

To me it is. I read/heard somewhere that the identity check was idiomatic, and 
started using it to the point where I find myself saying "filter identity" as 
slang for keeping only the valid things.

but that's just me (maybe)... don't know that it is generally considered more 
readable (but I think so).


bill

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

Re: Pattern of Succinctness

2012-08-12 Thread Alex Baranosky
(filter identity foos) and (filter #(not (nil? %)) foos) aren't equivalent.

I prefer (remove nil? foos)  Succint and direct.

On Sun, Aug 12, 2012 at 11:13 PM, Bill Caputo  wrote:

>
> On Aug 12, 2012, at 12:38 PM, Tamreen Khan wrote:
>
> (filter #(not (nil? %)) coll)
>> (filter identity coll) ;; nearly equal
>>
>
> Is the last one considered generally more readable? I think the following
> is clearer while still not having as much noise as the first filter example:
>
> (filter (partial not nil?) coll)
>
>
> To me it is. I read/heard somewhere that the identity check was idiomatic,
> and started using it to the point where I find myself saying "filter
> identity" as slang for keeping only the valid things.
>
> but that's just me (maybe)... don't know that it is generally considered
> more readable (but I think so).
>
>
> bill
>
>  --
> 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 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

AW: Pattern of Succinctness

2012-08-12 Thread Meikel Brandmeyer
Hi,

pay attention:
(or (:a {:a false}) 0)
(:a {:a false} 0)

Same holds in case false is nil.

Using these "transformations" can easily introduce bugs, depending on the 
context.

Kind regards
Meikel

-Ursprüngliche Nachricht-
Von: Takahiro Hozumi 
An: clojure@googlegroups.com
Gesendet: So, 12 Aug 2012, 19:35:16 MESZ
Betreff: Pattern of Succinctness

Hi,
I would like to know common technics that make code succinct.

For example:
(or (:b {:a 1}) 0)
(:b {:a 1} 0)

(if-not x 1 2)
(if x 2 1)

(filter #(not (nil? %)) coll)
(filter identity coll) ;; nearly equal

Please let me know any tips you found.

Cheers,
Takahiro.

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

Re: Pattern of Succinctness

2012-08-12 Thread Takahiro Hozumi
> (filter (partial not nil?) coll)
You mean (filter (comp not nil?) coll).
I'm not sure which is more readable, but thanks for Meikel and Alex, I now 
prefer (remove nil? coll).

Thanks.

On Monday, August 13, 2012 2:38:23 AM UTC+9, Tamreen Khan (Scriptor) wrote:
>
> Is the last one considered generally more readable? I think the following 
> is clearer while still not having as much noise as the first filter example:
>
> (filter (partial not nil?) coll)
>
> On Sun, Aug 12, 2012 at 1:35 PM, Takahiro Hozumi 
> 
> > wrote:
>
>> Hi,
>> I would like to know common technics that make code succinct.
>>
>> For example:
>> (or (:b {:a 1}) 0)
>> (:b {:a 1} 0)
>>
>> (if-not x 1 2)
>> (if x 2 1)
>>
>> (filter #(not (nil? %)) coll)
>> (filter identity coll) ;; nearly equal
>>
>> Please let me know any tips you found.
>>
>> Cheers,
>> Takahiro.
>>  
>> -- 
>> 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
>
>
>
On Monday, August 13, 2012 2:38:23 AM UTC+9, Tamreen Khan (Scriptor) wrote:
>
> Is the last one considered generally more readable? I think the following 
> is clearer while still not having as much noise as the first filter example:
>
> (filter (partial not nil?) coll)
>
> On Sun, Aug 12, 2012 at 1:35 PM, Takahiro Hozumi 
> 
> > wrote:
>
>> Hi,
>> I would like to know common technics that make code succinct.
>>
>> For example:
>> (or (:b {:a 1}) 0)
>> (:b {:a 1} 0)
>>
>> (if-not x 1 2)
>> (if x 2 1)
>>
>> (filter #(not (nil? %)) coll)
>> (filter identity coll) ;; nearly equal
>>
>> Please let me know any tips you found.
>>
>> Cheers,
>> Takahiro.
>>  
>> -- 
>> 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
>
>
>
On Monday, August 13, 2012 2:38:23 AM UTC+9, Tamreen Khan (Scriptor) wrote:
>
> Is the last one considered generally more readable? I think the following 
> is clearer while still not having as much noise as the first filter example:
>
> (filter (partial not nil?) coll)
>
> On Sun, Aug 12, 2012 at 1:35 PM, Takahiro Hozumi 
> 
> > wrote:
>
>> Hi,
>> I would like to know common technics that make code succinct.
>>
>> For example:
>> (or (:b {:a 1}) 0)
>> (:b {:a 1} 0)
>>
>> (if-not x 1 2)
>> (if x 2 1)
>>
>> (filter #(not (nil? %)) coll)
>> (filter identity coll) ;; nearly equal
>>
>> Please let me know any tips you found.
>>
>> Cheers,
>> Takahiro.
>>  
>> -- 
>> 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
>
>
>
On Monday, August 13, 2012 2:38:23 AM UTC+9, Tamreen Khan (Scriptor) wrote:
>
> Is the last one considered generally more readable? I think the following 
> is clearer while still not having as much noise as the first filter example:
>
> (filter (partial not nil?) coll)
>
> On Sun, Aug 12, 2012 at 1:35 PM, Takahiro Hozumi 
> 
> > wrote:
>
>> Hi,
>> I would like to know common technics that make code succinct.
>>
>> For example:
>> (or (:b {:a 1}) 0)
>> (:b {:a 1} 0)
>>
>> (if-not x 1 2)
>> (if x 2 1)
>>
>> (filter #(not (nil? %)) coll)
>> (filter identity coll) ;; nearly equal
>>
>> Please let me know any tips you found.
>>
>> Cheers,
>> Takahiro.
>>  
>> -- 
>> 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 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

Re: Pattern of Succinctness

2012-08-12 Thread Robert Marianski
On Sun, Aug 12, 2012 at 11:22:55AM -0700, Takahiro Hozumi wrote:
> > (filter (partial not nil?) coll)
> You mean (filter (comp not nil?) coll).
> I'm not sure which is more readable, but thanks for Meikel and Alex, I now 
> prefer (remove nil? coll).

remove is better in this case, but for posterity (comp not nil?) can be
spelled as (complement nil?)

Robert

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


Re: Pattern of Succinctness

2012-08-12 Thread Pierre-Henry Perret
I prefer  (filter (partial not nil?) coll)  as a HOF

Le dimanche 12 août 2012 20:46:59 UTC+2, rmarianski a écrit :
>
> On Sun, Aug 12, 2012 at 11:22:55AM -0700, Takahiro Hozumi wrote: 
> > > (filter (partial not nil?) coll) 
> > You mean (filter (comp not nil?) coll). 
> > I'm not sure which is more readable, but thanks for Meikel and Alex, I 
> now 
> > prefer (remove nil? coll). 
>
> remove is better in this case, but for posterity (comp not nil?) can be 
> spelled as (complement nil?) 
>
> Robert 
>

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

Re: Ideas for interactive tasks

2012-08-12 Thread Igor Kupczyński
Hi,

For a java course at my university students had to write a railway 
simulator - the idea was more or less to write randomly generate a map with 
railways and regular roads. Some of the tracks where double (i.e. trains 
can go both directions at the same time) and the other just a single track 
(one train, one direction at a time). In the the single tracks there were 
special bays for trains to wait while a train in the opposite direction is 
running. There were passenger trains and cargo trains, but the former had a 
priority over the latter (when single tracks were considered). There were 
cars on the regular roads (all bidirectional and running at the same 
speed), the only challenge for cars was to stop when a road crossed a 
railway and there was a train running on that railway. The idea was of 
course not cause any collision. The graphics had to pretty simple, i.e. 2d 
bird perspective, rectangles representing trains and squares representing 
cars.

Of course this was quite a big end-of-semester assignment. Maybe it will 
give you some ideas.

Thanks,
Igor

On Thursday, 9 August 2012 17:21:45 UTC+2, Nikita Beloglazov wrote:
>
> Hello
> I'm going to organize little clojure course at my university this year. 
> For this I want to implement set of tasks that hopefully will help to 
> practise clojure. 
> Tasks will be animated so students can see how their solutions work. E.g. 
> one of the tasks is to hit plane by missile: there is a plane that flies 
> from left to the right with fixed speed. Player launches missile to hit the 
> plane. Task is to write a function that takes coordinates of plane and 
> player and returns angle for launching missile. Plane's and missile's 
> speeds are constant and known. This task requires math and basic clojure 
> knowledge (only perform math operations, use let, if, Math/* functions). 
> Another example is to implement a bot for snake. Bot is implemented as a 
> function that takes snakes position (sequence of cells, each cell is vector 
> of 2 values) and apple position (vector of 2 values). Function must return 
> what direction to move. This task requires using of clojure seq functions.
> Can somebody propose ideas for this kind of tasks? I'm particularly 
> interested in tasks that require different fields of clojure, e.g. I don't 
> know what to implement for learning atoms, refs and agends. 
>
> Examples of tasks (artillery and snake) can be found here: 
> https://github.com/nbeloglazov/clojure-interactive-tasks. I use quil 
> for animation. Animation is primitive in 
> the tasks (I'm not particularly good at it).
>
> Thank you,
> Nikita Beloglazov
>

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

Re: Attractive examples of function-generating functions

2012-08-12 Thread Malcolm Sparks


> On Wednesday, August 8, 2012 7:48:23 PM UTC+3, Brian Marick wrote:
>>>
>>> I'm looking for medium-scale examples of using function-generating 
>>> functions.
>>>
>>>
>>>
Brian, when I saw this I was reminded of ring middleware - eg. 
http://jgre.org/2010/10/04/ring-middleware/

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

Feature request: multi arity into

2012-08-12 Thread yongqli
Hi,

Any reason why into isn't multi arity?

(into to & froms) => (reduce into to froms)


(into #{} [3 3 4] [2 1] ["a"]) looks better than (reduce into #{} [[3 3 4] 
[2 1] ["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

Re: Pattern of Succinctness

2012-08-12 Thread Alan Malloy
This doesn't work.

On Sunday, August 12, 2012 12:44:11 PM UTC-7, Pierre-Henry Perret wrote:
>
> I prefer  (filter (partial not nil?) coll)  as a HOF
>
> Le dimanche 12 août 2012 20:46:59 UTC+2, rmarianski a écrit :
>>
>> On Sun, Aug 12, 2012 at 11:22:55AM -0700, Takahiro Hozumi wrote: 
>> > > (filter (partial not nil?) coll) 
>> > You mean (filter (comp not nil?) coll). 
>> > I'm not sure which is more readable, but thanks for Meikel and Alex, I 
>> now 
>> > prefer (remove nil? coll). 
>>
>> remove is better in this case, but for posterity (comp not nil?) can be 
>> spelled as (complement nil?) 
>>
>> Robert 
>>
>

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

Re: clojurescript and regular expr.

2012-08-12 Thread Vincent
code is below function 
args  is entry - a map entry
to-match - a string to match to one of val of key in entry

(defn matchName [ entry to-match] 
  (let [match-str (.toLowerCase to-match)
str-pattern (re-pattern (str "(" match-str ")")) 
m (re-matcher str-pattern (.toLowerCase (:name entry)))]
(when (re-find m) 
  entry)))

i have not used js much... how to use js regular expr here?

thanks


On Sunday, August 12, 2012 12:04:53 AM UTC+5:30, Maik Schünemann wrote:
>
> Could you please post the relevant code? Note that clojurescript uses 
> Javascript regular expression syntax and not javas 
> Am 11.08.2012 17:02 schrieb "Vincent" >:
>
>> dear all ,
>> i am trying a search a string in a clojure map data and then want to 
>> return the result to be viewed in webpage
>> so using clojurescript  .but regular expr. of clojure is not supported it 
>> seems as error is showing when lein cljsbuild 
>> ...how to work around thru this? any example?
>>
>>
>> thanks in advance 
>> Vincent
>>
>> -- 
>> 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 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