Hi Evan,
Thanks for the reply.
I tried putting a print and it works as expected.
(let [a (atom 0)
i (take-while (fn[x] (swap! a inc)
( x 100)) [1 2 3 4 5])]
(println i)
[@a i]) ;; == [5 (1 2 3 4 5)]
But, I still cant come up with a theory of what exactly is
1) I assumed that printing out [i @a] instead of [@a i] should realize 'i'
first and @a should be correctly displayed as 5. This does not happen, it
simply prints [(1 2 3 4 5) 0] if the order is reversed.
So, this evaluates in two stages.
First the terms `i` and `@a` are evaluated to get
On Mon, Jul 30, 2012 at 11:05 PM, Vinay D.E devi...@gmail.com wrote:
I tried putting a print and it works as expected.
Because you are realizing the whole of i to print it.
1) I assumed that printing out [i @a] instead of [@a i] should realize 'i'
No, [i @a] creates a two-element vector of a
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 seancorfi...@gmail.com wrote:
On Mon, Jul 30, 2012 at 5:12 PM, Tokusei NOBORIO t.nobo...@gmail.com
wrote:
Here is a comparison of the features
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
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 (instance?
Evaluating this form:
_
(dispatch/react-to #{:dom-loaded}
(fn [t d] (do
(load-todos!) ;; init !todos OK
(log-console (str todos= @!todos)) ;; OK
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
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 mapping,
Vinay D.E devi...@gmail.com 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
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,
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.
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 to
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
Will this be the best Clojure event?
http://skillsmatter.com/event/clojure/haskell-exchange-2012
Chris
On 31 July 2012 16:15, cassiel n...@cassiel.com wrote:
Yep... my presentation proposal went in last week...
Wow, that's pretty nice.
On Tue, Jul 31, 2012 at 8:07 AM, David Nolen dnolen.li...@gmail.com 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
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 gareth.e.jo...@gmail.comwrote:
Wow, that's pretty nice.
On Tue, Jul 31, 2012 at 8:07 AM, David Nolen dnolen.li...@gmail.com
wrote:
Ever
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
(swap! *mind* (constantly :blown))
Sent from phone. Please excuse brevity.
On Jul 31, 2012 9:18 PM, David Nolen dnolen.li...@gmail.com 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
On Tue, Jul 31, 2012 at 1:30 AM, Bruce Durling b...@otfrom.com 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
Sean,
On Tue, Jul 31, 2012 at 6:56 PM, Sean Corfield seancorfi...@gmail.com wrote:
On Tue, Jul 31, 2012 at 1:30 AM, Bruce Durling b...@otfrom.com 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
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]
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 that
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)
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
25 matches
Mail list logo