Re: Clojure Programming is a great book

2012-09-22 Thread Ali M.
Greetings,

I also just got this book as an ebook from oreilly, they were having
50% off of everything (or at least ebooks)
Anyway, is there a dedicated mailing list to discuss this book?

I plan to read most of it in the next month or so :)
It would be nice if there is a mailing list where I can rant about
what I dont like >:)
or praise what I liked :)

Regards
Ali

On Tue, Sep 18, 2012 at 4:22 PM, Chas Emerick  wrote:
> On Sep 13, 2012, at 4:40 PM, larry google groups wrote:
>
> I want to offer a big thanks to Chas Emerick, Brian Carper and Christophe
> Grand. I just got their book "Clojure Programming" from Amazon yesterday.
> Spent the whole night reading it. This is my favorite Clojure book so far.
>
>
> Thank you (and anyone else that has said good things about the book) for the
> kind words.  I'm glad that you are enjoying it so far, and I hope it helps
> you along in your Clojure journey. :-)
>
> Cheers,
>
> - Chas
>
> --
> http://cemerick.com
> [Clojure Programming from O'Reilly](http://www.clojurebook.com)
>
> --
> 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: language shootout / the phonecode study

2012-09-22 Thread Dennis Haupt
here's my solution:
https://gist.github.com/3766508

the original (done in 2 hours) solution is commented out. i made some
improvements and solved the whole thing in 39 lines (counting only the
content of "main"). doing it in the minimal amount of lines was not my
goal. i was trying to minimize the logic. shorter code was just a side
effect.

try to beat it :). let's see how that looks in clojure.

Am 20.09.2012 19:30, schrieb David Nolen:
> On Thu, Sep 20, 2012 at 1:19 PM, Jules  > wrote:
> 
> This problem would be ideally suited for core.logic except because
> of the "hint"
> (http://page.mi.fu-berlin.de/prechelt/phonecode/hint2.html) you'd
> need to do something far more ugly.
> 
> 
> The solution I came up with doesn't attempt to encode the entire
> solution in core.logic. Also I admit the solution I came up with was a
> response to Odersky's neat version for the Scala Days 2011 Keynote and
> not the original problem.
> 
> 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


-- 

-- 
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: language shootout / the phonecode study

2012-09-22 Thread David Nolen
On Sat, Sep 22, 2012 at 11:27 AM, Dennis Haupt  wrote:

> here's my solution:
> https://gist.github.com/3766508
>
> the original (done in 2 hours) solution is commented out. i made some
> improvements and solved the whole thing in 39 lines (counting only the
> content of "main"). doing it in the minimal amount of lines was not my
> goal. i was trying to minimize the logic. shorter code was just a side
> effect.
>
> try to beat it :). let's see how that looks in clojure.


Looks pretty convoluted ;)

Here's Odersky's Scala version and mine that uses core.logic
http://gist.github.com/1107653.

I'm headed to StrangeLoop so I don't have time to verify that the Scala or
my version fully satisfies the original problem description. But my guess
is that Odersky did really solve the original problem.

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: language shootout / the phonecode study

2012-09-22 Thread Dennis Haupt
nice... he approximately does with for loops what i do without the
sugar, hence all the chained calls. i noticed i do a bit more than
necessary (the reverse thing is a remainder of an early
misinterpretation of the spec), but who cares, it works :)

however, odersky's short version doesn't solve the problem ;)
it doesn't:
* handle the - / and " chars
* handle the fallback-case (print a number if no word fits)
* format the output correctly

removing all this from my code, just 2/3 of the current implementation
remain.

i updated my solution, it's a bit more elegant now.

Am 22.09.2012 18:22, schrieb David Nolen:
> On Sat, Sep 22, 2012 at 11:27 AM, Dennis Haupt  > wrote:
> 
> here's my solution:
> https://gist.github.com/3766508
> 
> the original (done in 2 hours) solution is commented out. i made some
> improvements and solved the whole thing in 39 lines (counting only the
> content of "main"). doing it in the minimal amount of lines was not my
> goal. i was trying to minimize the logic. shorter code was just a side
> effect.
> 
> try to beat it :). let's see how that looks in clojure.
> 
> 
> Looks pretty convoluted ;)
> 
> Here's Odersky's Scala version and mine that uses
> core.logic http://gist.github.com/1107653.
> 
> I'm headed to StrangeLoop so I don't have time to verify that the Scala
> or my version fully satisfies the original problem description. But my
> guess is that Odersky did really solve the original problem.
> 
> 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


-- 

-- 
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: ANN edn-java

2012-09-22 Thread Mikera
Looks cool - going to try it out in a couple of my projects, thanks!

Question - assuming this is pretty lightweight and efficient, would it also 
make sense to use it from Clojure in circumstances where you just want edn 
and don't need the full Clojure reader?

-- 
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: Q about eval-and-print function in clojurescript's cljs.repl (repl.clj)

2012-09-22 Thread Frank Siebenlist
Thanks for investigating.

It seems that inside evaluate-form that map returned by -evaluate, but then the 
:value's value of that map is returned to the eval-and-print function where 
that is "read-string" again… 

Anyway, got it to work now - thanks.


On Sep 19, 2012, at 6:47 AM, Hubert Iwaniuk  wrote:

> If you look at cljs counterpart of it you'll see that maps are send as 
> responses, that is why read-string is used.
> 
> HTH
> 
> Frank Siebenlist wrote:
>> 
>> Sorry - I've answered part of my own Q by reading the read-string doc… 
>> nothing is eval'ed of the result - just the first "object" is read.
>> 
>> Still unclear why read-string is used - why would a second "object" be 
>> discarded? Like:
>> 
>> user=>  (read-string "(+ 1 2) (- 3 2)")
>> (+ 1 2)
>> 
>> Still confused...
>> 
>> -FS.
>> 
>> 
>> On Sep 18, 2012, at 11:51 PM, Frank Siebenlist  
>> wrote:
>> 
>>> 
>>> I'm trying to understand the clojurescript-code of the repl functionality, 
>>> and I'm confused…
>>> 
>>> The following cljs.repl/eval-and-print function takes a cljs-form, compiles 
>>> it, sends it to the browser as javascript, and then receives the result, 
>>> and the… try's to use "read-string" on that return value:
>>> 
>>> ---
>>> (defn- eval-and-print [repl-env env form]
>>>   (let [ret (evaluate-form repl-env
>>>(assoc env :ns (ana/get-namespace ana/*cljs-ns*))
>>>""
>>>form
>>>(wrap-fn form))]
>>> (try (prn (read-string ret))
>>>  (catch Exception e
>>>(if (string? ret)
>>>  (println ret)
>>>  (prn nil))
>>> ---
>>> 
>>> Why does it call read-string on the returned result from the js-eval?
>>> 
>>> The eval'ed compiled javascript could result in a clojure-form that would 
>>> be eval'ed on the return (???), and the result of the latter is then 
>>> printed.
>>> 
>>> Confusingly yours, FrankS.
>>> 
>> 
> 
> -- 
> 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


Redirect *out* of the cljs-repl?

2012-09-22 Thread Frank Siebenlist
To be more precise, if you do a (print "something") in a cljs-script, that gets 
compiled and evaluated in the browser's js-vm, then the result is sent back 
thru a separate http-post and dispatched to the multimethod "handle-post" 
implementation for :print in clojurescript's cljs.repl.browser:

--

(defmethod handle-post :print [{:keys [content order]} conn _ ]
(do (constrain-order order (fn [] (do (print (read-string content))
 (.flush *out*
(server/send-and-close conn 200 "ignore__"

--

If you evaluate a cljs-form thru a direct call of cljs.repl/evaluate-form from 
a different thread than the cljs-repl, then any output from (print "something") 
will be printed in the cljs-repl terminal session and not the terminal where 
you invoked the cljs.repl/evaluate-form from.

That the "defmethod handle-post :print" cannot use the terminal's *out* where 
cljs.repl/evaluate-form is invoked, is understandable because it runs in a 
different thread.

The issue is that it's not just another thread, it seems a completely different 
context as the http-post handlers run asynchronous from any sent js-code.

This seems the reason that using any (binding [*out* terminal-out] 
(cljs.repl/evaluate-form …)) doesn't work - or I cannot make it work…

Right now I can make it work by saving the terminal's *out* in an atom and 
using it's value directly in the handle-post code, like:

--

(def context-out (atom nil))

(defmethod handle-post :print [{:keys [content order]} conn _ ]
  (if @context-out
(do (constrain-order order (fn [] (binding [*out* @context-out] 
(do (print (read-string content))
(.flush *out*)
(server/send-and-close conn 200 "ignore__"))

(do (constrain-order order (fn [] (do (print (read-string content))
  (.flush *out*
(server/send-and-close conn 200 "ignore__"

--

If I do (reset! cljs.repl.browser/context-out *out*) in the clj-repl, then the 
stdout of the cljs-repl gets redirected to my terminal… as I want.

However, it feels like a hack and I was hoping that I missed a better 
alternative… any suggestions or comments are most welcome.

Thanks, FrankS.




-- 
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: ANN edn-java

2012-09-22 Thread Ben Smith-Mannschott
On Sun, Sep 23, 2012 at 3:59 AM, Mikera  wrote:
> Looks cool - going to try it out in a couple of my projects, thanks!
>
> Question - assuming this is pretty lightweight and efficient, would it also
> make sense to use it from Clojure in circumstances where you just want edn
> and don't need the full Clojure reader?

I suppose it might, if you really need the performance. I've compared
the performance slurping in large (10+ MB) files containing a long
series of maps and found edn-java to be about twice as fast as
Clojure's LispReader. (I can only speculate as to why.)

On the other hand, using clojure.core/read is far more idiomatic when
calling from Clojure and doesn't require an additional dependency.

// Ben

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