Re:

2012-07-31 Thread Yoshinori Kohyama
Hi Nicolas, Thank you for teaching! I often use very long sequences and often want to terminate in middle of folding operations of them. With reduce, code come to be simple and abstract, but I couldn't terminate them. So I used to use loops or wrapping functions using loop. Throwing a throwable

Re: (let [a 0] (eval 'a)))

2012-07-31 Thread Lee Spector
An approach that doesn't involve dynamic variables is to build, evaluate, and then call a function that's made out of the given code and takes an argument for the variable. Assuming for the moment that the code is in symbolic form (rather than string form) like this: => (def exp 'a) # Then y

Re: (let [a 0] (eval 'a)))

2012-07-31 Thread Evan Mezeske
This thread on SO might be helpful: http://stackoverflow.com/questions/6221716/variable-scope-eval-in-clojure . On Tuesday, July 31, 2012 2:02:30 PM UTC-7, Andrew wrote: > > I have a value and a string. The string contains valid Clojure code and it > mentions a variable. I'd like to let-bind tha

(let [a 0] (eval 'a)))

2012-07-31 Thread Andrew
I have a value and a string. The string contains valid Clojure code and it mentions a variable. I'd like to let-bind that variable to the value and then evaluate the string. Can this be done? As a small example, I thought this would work: (let [a 0] (eval 'a))) Or maybe this: user> (let [a 0]

Re: ANN: Mongoika, a new Clojure MongoDB library

2012-07-31 Thread Bruce Durling
Sean, On Tue, Jul 31, 2012 at 6:56 PM, Sean Corfield wrote: > On Tue, Jul 31, 2012 at 1:30 AM, Bruce Durling wrote: >> Congomongo works fine on heroku. You do have to parse the connection url >> yourself though (or at least you did) > > 0.1.10 was just released to Clojars and includes support fo

Re: ANN: Mongoika, a new Clojure MongoDB library

2012-07-31 Thread Sean Corfield
On Tue, Jul 31, 2012 at 1:30 AM, Bruce Durling wrote: > Congomongo works fine on heroku. You do have to parse the connection url > yourself though (or at least you did) 0.1.10 was just released to Clojars and includes support for standard MongoDB URIs which should address that I believe? -- Sean

Re: A succinct & reasonably fast sudoku solver in core.logic

2012-07-31 Thread Baishampayan Ghose
(swap! *mind* (constantly :blown)) Sent from phone. Please excuse brevity. On Jul 31, 2012 9:18 PM, "David Nolen" wrote: > A much shorter version using an everyo goal I just landed in master: > > http://gist.github.com/3217582 > > David > > On Tue, Jul 31, 2012 at 11:36 AM, gaz jones wrote: > >>

Re: A succinct & reasonably fast sudoku solver in core.logic

2012-07-31 Thread Paul deGrandis
On Tuesday, July 31, 2012 11:48:14 AM UTC-4, David Nolen wrote: > > A much shorter version using an everyo goal I just landed in master: > > http://gist.github.com/3217582 > That is easily the clearest sudoku solver I have ever seen. It reads *exactly* like the rules of the game. Great stuff

Re: A succinct & reasonably fast sudoku solver in core.logic

2012-07-31 Thread David Nolen
A much shorter version using an everyo goal I just landed in master: http://gist.github.com/3217582 David On Tue, Jul 31, 2012 at 11:36 AM, gaz jones wrote: > Wow, that's pretty nice. > > On Tue, Jul 31, 2012 at 8:07 AM, David Nolen > wrote: > > Ever since I read Norvig's cool Python solution,

Re: A succinct & reasonably fast sudoku solver in core.logic

2012-07-31 Thread gaz jones
Wow, that's pretty nice. On Tue, Jul 31, 2012 at 8:07 AM, David Nolen wrote: > Ever since I read Norvig's cool Python solution, > http://norvig.com/sudoku.html, I've been wanting to see if this could be > done in core.logic without sacrificing generality. Now that we have cKanren > extensions in

Re: [ldnclj] Re: 6 December 2012 - London - Clojure eXchange - Call for Presentations

2012-07-31 Thread Chris Ford
Will this be the best Clojure event? http://skillsmatter.com/event/clojure/haskell-exchange-2012 Chris On 31 July 2012 16:15, cassiel wrote: > Yep... my presentation proposal went in last week... > > > http://skillsmatter.com/event/**scala/clojure-exchange

Re: 6 December 2012 - London - Clojure eXchange - Call for Presentations

2012-07-31 Thread cassiel
Yep... my presentation proposal went in last week... http://skillsmatter.com/event/scala/clojure-exchange and > http://skillsmatter.com/event/scala/clojure-exchange-2012 > Indeed; sign up now for what promises to be the best Scala event of 2012. -- N. -- You received this message because y

Re: Alternative to (or (:k1 m) (:k2 m))

2012-07-31 Thread Michael Gardner
On Jul 31, 2012, at 12:00 AM, Ben Smith-Mannschott wrote: > ((some-fn :k1 :k2) m) Ah, excellent. Yet another hidden gem in clojure I'd somehow overlooked until now! -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email t

A succinct & reasonably fast sudoku solver in core.logic

2012-07-31 Thread David Nolen
Ever since I read Norvig's cool Python solution, http://norvig.com/sudoku.html, I've been wanting to see if this could be done in core.logic without sacrificing generality. Now that we have cKanren extensions in master I gave it a shot (thanks to Martin Trojer) and I'm happy with the results. http

Re: ClojureScript reactor

2012-07-31 Thread Baishampayan Ghose
Since the REPL tries to print out the lazy sequence it ends up forcing evaluation as well. If you do something like (def foo (some-lazy-seq)) in the repl it won't get forcibly realized as before. This is a very common source of misconception, you're not alone :) Regards, BG On Tue, Jul 31, 2012

Re: atom / swap! question

2012-07-31 Thread Marshall T. Vandegrift
"Vinay D.E" writes: > I am a newbie and was doing some exercises when I ran across something that > I don't understand. > I am trying to count the number of elements in an array less than 100. > > My first attempt didn't work. The counter returns 0 > > (let [a (atom 0) > i (take-while (fn[

Re: ClojureScript reactor

2012-07-31 Thread Pierre-Henry Perret
mapv do the eval. Should be a reflex: when something works in the repl, but not in the code...it's lazy ! Thanks Le mardi 31 juillet 2012 14:07:17 UTC+2, Baishampayan Ghose a écrit : > > Hi, > > map in Clojure (and ClojureScript) is lazy. Since you are not using > the return value of the mapp

Re: ClojureScript reactor

2012-07-31 Thread Baishampayan Ghose
Hi, map in Clojure (and ClojureScript) is lazy. Since you are not using the return value of the mapping, it's not doing much at all. You can force realization of a lazy sequence by putting a (doall... around the map call. You can also use mapv (in Clojure 1.4 at least) which will return a vector

ClojureScript reactor

2012-07-31 Thread Pierre-Henry Perret
Evaluating this form: _ (dispatch/react-to #{:dom-loaded} (fn [t d] (do (load-todos!) ;; init !todos OK (log-console (str "todos=" @!todos)) ;; OK

Re:

2012-07-31 Thread nicolas.o...@gmail.com
> The technique, using throw an Exception when succeeded in searching, strikes > me! You can make it less ugly with a bit of library: user> (deftype EarlyExit [result]) user.EarlyExit user> (defn early-exit [x] (EarlyExit. x)) user> (defn reduce-with-early-exit [f acc coll] (if (insta

Re: atom / swap! question

2012-07-31 Thread Dimitrios Jim Piliouras
If I understand correctly you don't need an atom to count the elements in a seqall you need is 'count' (let [s [1 2 3 4 5] n (count s)] (vector n s)) => [5 [1 2 3 4 5]] If you want to count only the first 100 you can first "take" as many as you need and then count them...you can also

Re: ANN: Mongoika, a new Clojure MongoDB library

2012-07-31 Thread Bruce Durling
Congomongo works fine on heroku. You do have to parse the connection url yourself though (or at least you did) On Jul 31, 2012 2:49 AM, "Sean Corfield" wrote: > On Mon, Jul 30, 2012 at 5:12 PM, Tokusei NOBORIO > wrote: > > Here is a comparison of the features of the three libraries. > > I hope p