Re: A ClojureScript One Question: Why is so much html created on the client side.

2012-08-11 Thread john
Hello,
thank you very much for your comments!
I didn't know before about the term SPA 
(http://en.wikipedia.org/wiki/Single-page_application)
I guess  a sign of being  too Conservative (-: !

I am trying to re-implement a swing app with clojure script.
Before seeing Clojurescriptone I was only considering clojurescript for 
creating widgets like navigation trees or content tables or wizards.

Now that you all pointed me to SPA I looked at some websites using this 
technic and can see and admire the smoothness factor.

On the other hand my users won't mind waiting a second or two for new 
content on main context switches. So maybe I can use a hybrid approach.

I just am a little afraid of depending too much on cljs . Not because of 
the language but I still think that the server is so much more predictable 
than the browser.

Many Thanx! 
John



  
  


Am Samstag, 11. August 2012 00:43:09 UTC+2 schrieb Brenton:

 Hello John,

 ClojureScript One is an example of a single-page application. This means 
 that you get one page load from the 
 server and everything else happens in the browser without any further page 
 loads. The initial page that
 is loaded is dynamically generated on the server. Any other updates to the 
 page are performed from JavaScript
 by manipulating the DOM.

 If you are making requests to the server for every new page then it makes 
 sense to dynamically generate HTML
 there. The whole point of a single-page application is to make the 
 application more responsive by reducing both the
 number of requests and the amount of data that is transferred over a 
 network.

 Imbedding HTML templates in JavaScript means that those templates are only 
 transferred over the network once.

 I hope this helps,
 Brenton

 On Friday, August 10, 2012 6:21:00 AM UTC-4, john wrote:

 Hello,
 I am just trying to understand the best practices in ClojureScript One.

 One thing that strikes me is that most html gets put (with the help of 
 macros using enlive) in the actual cljs page.

 As someone who hasn't done web-applications for years I myself would have 
 created as much dynamic html content 
 as possible on the server. But yet ClojureScript One seems to prefer to 
 have all html in maps and render it on the client?

 I also looked at Chris Granger's crate library and it seems to also 
 follow this principle.

 Since I consider Chris Granger and Brento Ashworth to be web experts I 
 would just like to know the disadvantages of having
 most html rendered on the server?

 Many Greetings 
 John
   



-- 
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: How to measure pieces of Clojure code?

2012-08-11 Thread nicolas.o...@gmail.com
Visualvm is quite nice and simple to use.
On 10 Aug 2012 23:21, Hussein B. hubaghd...@gmail.com wrote:

 Hi,
 I want to measure how much space an algorithm is taking and then trying to
 change some aspects to see how things are going to differ.
 I also want to measure how much time it takes to complete an operation.

 What tools can I use?

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

clojurescript and regular expr.

2012-08-11 Thread 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 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-11 Thread Maik Schünemann
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 vincent@gmail.com:

 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 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: Any chance for Ratio and BigInt support in ClojureScript?

2012-08-11 Thread David Nolen
On Sun, Aug 5, 2012 at 10:43 PM, Olaf Delgado-Friedrichs
olaf.delg...@googlemail.com wrote:
 Thanks for the link! I didn't know that the Closure library contained an
 arbitrary precision type, but should have expected it.

 When you speak of performance, do you mean the extra cost of checking
 argument types for the arithmetic operators? I wonder if this could be
 addressed by introducing alternate operators +', -' and *' as in Clojure,
 make these support the additional numeric types and leave the existing
 operators alone. This is certainly something that makes sense for me to do
 in a library.

 In order to support the BigInt and Ratio literals, would I have to modify
 the ClojureScript sources, or is it possible to extend emit-constant in
 user space?

 Olaf

Sorry, forgot to follow up this. I haven't put any deep thought into
it so I can offer no implementation guidance. I think it will be
pretty challenging to get full Clojure JVM numeric semantics into
ClojureScript w/o impacting performance.

It can probably be done but requires both a comprehensive design and
good implementation strategy. If someone wants to take it on ...
great!

David

-- 
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: Better ideas how to collect analytics data

2012-08-11 Thread Maik Schünemann
Using maps in clojure is very idiomatic if the structure fits to your data.
Do you experience performance problems?
Dependent on the data you are modeling you could split the master maps in
several smaller ones.
If performance gets really important you can use records instead of maps.

It would be helpful to know what data you are modeling
Am 10.08.2012 21:52 schrieb Hussein B. hubaghd...@gmail.com:

 Hi,
 I'm collecting analytics data. I used a master map that holds many other
 nested maps.
 Considering maps are immutable, many new maps are going to be allocated.
 (Yes, that is efficient in Clojure).
 Basic operation that I'm using is update-in , very convenient.
 Do you have a better idea how to collect these data more efficiently in
 Clojure?
 Thanks for help and time.

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

use pmap but ensure that original ordering is retained?

2012-08-11 Thread Jim - FooBar();

Hi all,

I was wondering what assumptions does pmap take with regards to the 
ordering of the resulting seq? Can I assume it retains the original 
ordering or does it just cons whatever future returns earlier? In other 
words can I do this and feel safe?

---

(defn min-max [root? depth dir board]
(if (zero? depth) (score b) ;reached bottom level - evaluate board
(let [mapper (if root? 'pmap 'map) ;if at root-node create futures
  team   (filter #(= dir (:direction %)) board) ;all the 
team-mates (with same direction)
  successors (concat (map #(core/getMoves %) team)) ;concat all 
potential moves

  result (- successors
 (map core/try-move)  ;try them all (producing boards)
 (mapper (partial min-max false (dec depth) (- 
dir];pass the resulting boards back to recursion with direction inverted

(get (vec successors)
  (.indexOf result (apply max result))

(def search (partial min-max true))


It seems to me like a very succinct and idiomatic way to implement the  
min-max algorithm, the only problem is this line:

(get (vec successors)  (.indexOf result (apply max result)))

It assumes that the initial ordering of moves ('successors') has been 
preserved  throughout the recursion and so I can use .indexOf to go from 
the score back to the move that started it all! Is this the case? I am 
suspecting not! any suggestions?


Thanks in advance,


Jim

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


core.logic: (run* [q] (membero :x #{:x})) - ()

2012-08-11 Thread Moritz Ulrich

Hi, fellow logic programmers!


Shouldn't `membero' work with sets?

I notice that

  (run* [q] (membero :x #{:x}))

returns no results while

  (run* [q] (membero :x (seq #{:x})))

returns the (in my opinion) correct result: (:x).


Can someone explain this behavior to me? It seems strange.

--
Moritz Ulrich

-- 
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: core.logic: (run* [q] (membero :x #{:x})) - ()

2012-08-11 Thread David Nolen
On Sat, Aug 11, 2012 at 2:14 PM, Moritz Ulrich mor...@tarn-vedra.de wrote:

 Hi, fellow logic programmers!


 Shouldn't `membero' work with sets?

 I notice that

   (run* [q] (membero :x #{:x}))

 returns no results while

   (run* [q] (membero :x (seq #{:x})))

 returns the (in my opinion) correct result: (:x).


 Can someone explain this behavior to me? It seems strange.

 --
 Moritz Ulrich

It doesn't work with sets. And it can't. If you want to understand
why: look at the implementation of membero and look at an
implementation of member in Prolog.

David

-- 
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: use pmap but ensure that original ordering is retained?

2012-08-11 Thread Ben Smith-Mannschott
Yes, pmap behaves as map with respect to the ordering of the elements
of the resulting sequence.

// ben

On Sat, Aug 11, 2012 at 9:29 PM, Jim - FooBar(); jimpil1...@gmail.com wrote:
 Hi all,

 I was wondering what assumptions does pmap take with regards to the ordering
 of the resulting seq? Can I assume it retains the original ordering or does
 it just cons whatever future returns earlier? In other words can I do this
 and feel safe?
 ---

 (defn min-max [root? depth dir board]
 (if (zero? depth) (score b) ;reached bottom level - evaluate board
 (let [mapper (if root? 'pmap 'map) ;if at root-node create futures
   team   (filter #(= dir (:direction %)) board) ;all the team-mates
 (with same direction)
   successors (concat (map #(core/getMoves %) team)) ;concat all
 potential moves
   result (- successors
  (map core/try-move)  ;try them all (producing boards)
  (mapper (partial min-max false (dec depth) (- dir];pass the
 resulting boards back to recursion with direction inverted
 (get (vec successors)
   (.indexOf result (apply max result))

 (def search (partial min-max true))
 

 It seems to me like a very succinct and idiomatic way to implement the
 min-max algorithm, the only problem is this line:
 (get (vec successors)  (.indexOf result (apply max result)))

 It assumes that the initial ordering of moves ('successors') has been
 preserved  throughout the recursion and so I can use .indexOf to go from the
 score back to the move that started it all! Is this the case? I am
 suspecting not! any suggestions?

 Thanks in advance,


 Jim

 --
 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: clojurescript and regular expr.

2012-08-11 Thread Vincent
code   entry is a map entry , to-match is string for 

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

how to incorporate js code 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 vince...@gmail.com javascript::

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