Mamun writes:
Hi Mamun,
> When I run the following code, I got false for (identical? 128 128).
> What is the different between = and identical?
= tests for equality (Object.equals() in Java) while identical? test for
the object identities being the same (== in Java). 128 is a
java.lang.Long, a
On 2 December 2011 05:26, liebke wrote:
> Just released Avout 0.5.2, which now includes automatic STM
> initialization (no more pesky init-stm step).
>
>
The init-stm step is still referenced in the documentation as being
required BTW.
I had a couple of questions.
I noticed that when I create a
Awesome! Ok, I've set up the google group, wordpress blog, twitter feed,
e-mail address and github for file-hosting and infra. Next step, I'll
create a google docs spreadsheet for topic and planning discussions and add
some content.
Blog: baltimorefp.wordpress.com
Twitter: twitter.com/baltimo
Overtone's 'at-at' library is a thin Clojure wrapper over
ScheduledThreadPoolExecutor with a nice interface. I think you should be
able to build a timer on top of it pretty easily.
https://github.com/overtone/at-at
On Thursday, December 1, 2011 10:17:40 AM UTC-7, Bill Caputo wrote:
>
> Hi All,
Here's the simplest way to adapt your code so that it won't blow the
stack. Just shuffle the input list first:
(defn quicksort [l]
(letfn [(qsort [[pivot & xs]]
(when pivot
(let [smaller #(< % pivot)]
(lazy-cat (qsort (filter smaller xs))
I'm in Baltimore and would definitely be interested in
participating. :)
On Nov 28, 6:38 pm, Gary Trakhman wrote:
> Any Baltimore guys around? I'm interested in starting a FP meetup where we
> can give talks and learn together and such.
--
You received this message because you are subscribed t
Reader macros are expanded by the reader, "regular" macros are
expanded by the compiler. The reader is what translates the text
strings that you have typed into Clojure data structures, the compiler
translates those data structures into executable code. Clojure does
not allow you to define custom
Are reader macros and "regular" macros handled differently by the
compiler? If possible, please give some contrasting details about what
the compiler is doing in each case.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send em
On Dec 1, 2:14 pm, Stuart Sierra wrote:
> Tree-building functions are not usually tail-recursive. I'm not even sure
> that Scheme will do tail-call elimination in that case. The Java stack can
> hold 8000 frames or so, so log base 2 is probably small enough to avoid a
> stack overflow when build
Roman wrote:
"Is there a way to replace a function only in current thread?"
Only if it's dynamic.
Consider passing the function -- or group of functions -- as an argument.
-S
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, se
As mentioned, 'identical?' tests that two objects are physically the same
in memory. `=` tests that two things are logically equal.
Specifically, all numbers in Clojure are "boxed" as objects like
java.lang.Long and java.lang.Double. For small integers like 4, the JVM
will optimize them to make
There are versions of Quicksort that don't use recursive function calls.
Instead they simulate recursion by maintaining a stack of indices. (Search
the web for "quicksort without recursion.") You could do that in Clojure
with loop/recur.
-S
--
You received this message because you are subscr
Tree-building functions are not usually tail-recursive. I'm not even sure
that Scheme will do tail-call elimination in that case. The Java stack can
hold 8000 frames or so, so log base 2 is probably small enough to avoid a
stack overflow when building a tree.
You could probably rewrite this w
identical? checks if two things are the same instances in memory.
= is a much nicer value oriented equality and idiomatic.
David
On Wed, Nov 30, 2011 at 5:23 PM, Mamun wrote:
> Hi,
>
> When I run the following code, I got false for (identical? 128 128).
> What is the different between = and id
On Thu, Dec 1, 2011 at 7:03 AM, John Holland wrote:
> I've been looking into Clojure and now Scheme for a while. Currently
> it's been SICP.
>
> I notice that SICP has examples of recursion such as a binary tree
> builder that is something like the following:
>
> (define (tree top elements split-
ScheduledThreadPoolExecutor is the way to go. But you can do it in "pure"
Clojure with Agents, send-off, and Thread/sleep.
-S
--
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 pos
Try increasing the JVM's stack size with -Xss.
--
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 u
I didn't mean the response to sound overly curt. You can set the stack size
on JVM.
But the point is, that quick sort is simply wrong if you do not want to
grow the stack, whether in Scheme or in Clojure.
On Thu, Dec 1, 2011 at 5:07 PM, David Nolen wrote:
> If you run out stack in Scheme the co
> Do I understand correct that the only way to hook
> a recursive function without affecting other
> threads is to annotate the function with
> ^{:dynamic true} and call it via #'fact?
If you want to you dynamic rebinding, yes.
There are other possibilities, however. Maybe you could pass the func
If you run out stack in Scheme the code is not properly tail recursive. Who
care when it blows?
On Thu, Dec 1, 2011 at 12:09 PM, john.holland wrote:
> I was studying clojure for a while, and took a break to work on SICP in
> scheme. I found that they do numerous things that are against advice in
I was studying clojure for a while, and took a break to work on SICP in
scheme. I found that they do numerous things that are against advice in
Clojure having to do with the tail recursion.
I got to thinking about that Clojure recur/loop stuff and wondered how you
would do a quicksort with it. S
This is fantastic, Alan; I haven't gotten around to LoL yet, but maybe
I should.
Quoth Alan Malloy on Setting Orange, the 43rd of The Aftermath:
> LoL lets you write:
>
> (with-cxrs
> (blah (foo (bar (cadddar x)
>
> ie, it looks in your source, sees what you need defined, and makes a
> let
In my mind the two biggest lessons that can be taken from previous
Lisps are that (1) the community of a language matters deeply (see
comp.lang.lisp) and (2) practical library management, build tools, and
deployment environments are essential. It simply isn't enough to have
a technically superior p
I've been looking into Clojure and now Scheme for a while. Currently
it's been SICP.
I notice that SICP has examples of recursion such as a binary tree
builder that is something like the following:
(define (tree top elements split-value)
(cons (tree (filter (< split-value) elements) )
Thanks for the reply, Nils.
2011/12/1 Nils Bertschinger
> Hi Roman,
>
> as far as I understand, the Clojure compiler is doing some
> optimizations for recursive functions to save the variable lookup.
> This means that you have to explicitly write the recursive call as
> (#'fact (dec n)) if you w
2011/12/1 Baishampayan Ghose
> > I think you should look at the binding function -
> > http://clojuredocs.org/clojure_core/clojure.core/binding
> >
> > In my tests, I am using this to run the same tests using two different
> > functions, which are supposed to do the same thing (using two differen
So, figured out my error, thanks for listening:
C:\Projects\CDT\Newton\test\Newton\test\core.clj:
(ns Newton.test.core
(:use [Newton.core])
(:use [clojure.test])
(:use [Newton.utilities]))
(deftest sum-test
(is (= (sum '(1 2 3 4 5)) 15)))
Then:
PS C:\Projects\CDT\Newton> lein test
Tes
On 30 Lis, 22:31, Kasper Galschiot Markus wrote:
> Is conf what you're looking for?
>
> http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/...
>
> ~Kasper
Of course. Thanks!
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post t
So, here's an example:
In the file C:\Projects\CDT\Newton\src\Newton.utilities.clj I have:
(ns Newton.utilities)
;; To keep same name conventions as utilities.lisp
;; In idomatic clojure, this could be replaced by the anonymous function
;; #(apply + %)
(defn sum
"sums the elements of a list"
Hello,
I'm porting a scientific application written in SBCL to Clojure. I'd like
to do the right thing by setting up tests to ensure my functions are
correct, and package up the project correctly using Leiningen.
I've read "Clojure in Action", however, the sample code from Chapter 8,
which detail
Hi,
When I run the following code, I got false for (identical? 128 128).
What is the different between = and identical?
(println (= 4 4))
true
(println (= 128 128))
true
(println (identical? 4 4))
true
(println (identical? 128 128))
false
Regards,
Mamun
--
You received this message because yo
I usually use juxt, but a more correct/robust solution is to use map,
with the lookup-map as the function:
(map {:foo 1 :bar 2 :baz 0} [:foo :bar])
On Dec 1, 12:26 pm, Ulises wrote:
> How about using juxt:
>
> sandbox> ((juxt :foo :bar) {:foo 1 :bar 2 :baz 0})
> [1 2]
> sandbox>
>
> This only wo
Not supported at present.
I'd have to think a little about it, but at first glance, it seems
doable. I've not look under the surface at how the CLR handles
PInvoke via DLLImport, so some investigation is required.
Attributes are supported on method defs in various places (but not yet
documented)
Thanks, works in my case.
On Dec 1, 3:26 pm, Ulises wrote:
> How about using juxt:
>
> sandbox> ((juxt :foo :bar) {:foo 1 :bar 2 :baz 0})
> [1 2]
> sandbox>
>
> This only works, however, if you use keywords for keys (as they are
> functions themselves).
>
> U
--
You received this message becaus
((juxt :foo :bar) {:foo 1 :bar 2 :baz 3})
juxt to the rescue
--
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
How about using juxt:
sandbox> ((juxt :foo :bar) {:foo 1 :bar 2 :baz 0})
[1 2]
sandbox>
This only works, however, if you use keywords for keys (as they are
functions themselves).
U
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this gro
Is there something build in for getting multiple vals out of the map?
{:keys [...]} woks in destructuring forms. It is quite easy to build
something with filter and map but I suspect these is a common problem
somebody solved already.
Desired
(get-vals [:a :b] {:a 1 :b 2 :c 3})
(1 2)
--
You receiv
On 1 Dec 2011, at 18:26, liebke wrote:
> Just released Avout 0.5.2, which now includes automatic STM
> initialization (no more pesky init-stm step).
Ha, throw down the gauntlet, then beat me to it ;-)
Great work,
Sam
---
http://sam.aaron.name
--
You received this message because you are sub
1) I agree this seems silly but I don't think it's ever bitten me
2) I think this has caused me problems once or twice
3) It would be nice to have Named and Namespaced, but I don't think
it's feasible to make the change now - there's too much code assuming
you can get the namespace of a Named thi
On Thu, Dec 1, 2011 at 10:00 AM, joegallo wrote:
> Here are some things I've run across in Clojure that seem asymmetric to me
> -- I looked through Jira for issues related to these, but I didn't find any
> (of course, I might have just missed them). Some of these might be valid
> enhancements tha
Just released Avout 0.5.2, which now includes automatic STM
initialization (no more pesky init-stm step).
David
On Dec 1, 12:44 pm, David Edgar Liebke wrote:
> init-stm (and reset-stm) are only used for creating an STM that will be used
> by every client. You only want to call it once, not ever
On Dec 1, 2011, at 11:45 AM, gaz jones wrote:
>Hey Bill, I would have thought you would have to have a pretty good
>reason for not using an executor for this?
Just that I really never spent much time as a Java programmer, so
evaluating the merits/tradeoffs/gotchas of using native (and 3rd
party)
Here are some things I've run across in Clojure that seem asymmetric to me
-- I looked through Jira for issues related to these, but I didn't find any
(of course, I might have just missed them). Some of these might be valid
enhancements that would make sense to add, some of them might be a case
any chance such threads could be on an avout list instead of the
general clojure list?
--
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 - pleas
You (all of you).
Make awesome things. Share. Repeat. Ignore everything else.
On Dec 1, 6:42 am, Harrison Maseko wrote:
> I though this blog post "http://www.uiandtherest.com/ui/index.php/
> 2011/11/11/a-refreshed-view-on-community-clojure-conj-2011/" would
> make a nice read for all of us who
Hey Bill, I would have thought you would have to have a pretty good
reason for not using an executor for this?
(let [executor (Executors/newSingleThreadScheduledExecutor)]
(.scheduleAtFixedRate executor your-func 0 3 TimeUnit/SECONDS))
On Thu, Dec 1, 2011 at 11:17 AM, Bill Caputo wrote:
> Hi A
init-stm (and reset-stm) are only used for creating an STM that will be used by
every client. You only want to call it once, not every time a client connects.
I could be more clever about calling it when it's clear that it hasn't been
called before though. I'll dedicate that patch to you :)
> I
Out of interest, why is #'init-stm a separate step to #'connect
I tried looking at the docstrings for each fn but they were both nil :-(
Sam
---
http://sam.aaron.name
On 1 Dec 2011, at 17:21, David Edgar Liebke wrote:
> Did you initialize the STM?
>
> (init-stm client)
>
> You only need to d
Fantastic, I've added the init-stm step to the code snippet at the top of the
Avout site, it was an accident to leave it out.
It's been great "pairing" with you two :)
David
> Works perfectly for me too. Perhaps it might help to add that to the example
> snippet to stop idiots like myself fall
On 1 Dec 2011, at 17:21, David Edgar Liebke wrote:
> Did you initialize the STM?
>
> (init-stm client)
Works perfectly for me too. Perhaps it might help to add that to the example
snippet to stop idiots like myself falling into that trap :-)
Sam
---
http://sam.aaron.name
--
You received th
That's the ticket! Thanks David, its working for me now.
On 01/12/2011 17:21, David Edgar Liebke wrote:
> (init-stm client)
--
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
Did you initialize the STM?
(init-stm client)
You only need to do it the first time, to set up the necessary zookeeper nodes,
it's described in the main tutorial but not the snippet on the top of the avout
site.
David
On Dec 1, 2011, at 12:15 PM, Sam Aaron wrote:
> Hi David,
>
> thanks for
Hi All,
I am currently considering an approach similar to the following for
periodically sending an update to an agent and I'm looking for
feedback on whether there is anything wrong with it, whether it's
idiomatic clojure (sorry I'm in the pro-that-term camp) and whether
there are other pure-cloj
Hi David,
thanks for looking into this so promptly. Sadly 0.5.1 just throws a different
exception:
user=> (def client (connect "127.0.0.1"))
#'user/c
Thanks Sam and Edmund,
The stack traces were helpful, I think I understand what the immediate problem
is. It appears that the transaction ID in these cases is not getting set, and
then Avout is trying to write data to the ZooKeeper node /stm/history/ instead
of /stm/history/txid.
Since I can'
Hi David,
I nuked all my zookeeper deps in my lib and ~/.m2 dirs, but similar to Edmund
experience it doesn't fix anything. My stacktrace is also identical:
∴ /Users/sam/tmp/avv
λ
Hey Sam & Dave,
I'm following along at home. I followed David's advice and there's
no change. FWIW here's the client datastructure and the exception
stacktrace:
#
java.lang.IllegalArgumentException: Path must not end with / character
at org.apache.zookeeper.common.PathUtils.validatePat
Hey David,
I get an identical exception here here w/ zookeeper version
3.2.2. Because I'm crazy that way I also tried to call the ref "/r0/"
(just to see) and the exception came up. However it was different in
that with "/r0/" I got the usual exception handling in emacs, whereas
with "/
Hi Sam,
> run-in-transaction exception: # java.lang.IllegalArgumentException: Path must not end with / character> nil
Very interesting, I wouldn't expect that particular exception unless you named
the zk-ref "/r0/" instead of "/r0", which you apparently didn't.
And even when I do call it "/r
Hi David,
I'm super excited by Avout. It seems *better* than magic in that it not only
appears to make complicated things possible, but also in a conceptually
transparent way. Crazy cool.
I'm about to look into this in detail, but I thought I'd just post an issue I'm
having with the basic exam
Does ClojureCLR support PInvoke and the DLLImport attribute or
something similar?
(e.g., from PInvoke.net)
DllImport("crypt32.dll", EntryPoint = "CertGetNameString", CharSet =
CharSet.Auto, SetLastError = true)]
static extern System.UInt32 CertGetNameString(IntPtr CertContext,
System.UInt32 lType,
I though this blog post "http://www.uiandtherest.com/ui/index.php/
2011/11/11/a-refreshed-view-on-community-clojure-conj-2011/" would
make a nice read for all of us who were not at the Conj this year. It
makes very positive comments about the Clojure community and augments
comments heard within the
Alan Malloy writes:
Hi Alan,
> LoL lets you write:
>
> (with-cxrs
> (blah (foo (bar (cadddar x)
>
> ie, it looks in your source, sees what you need defined, and makes a
> letfn.
Ah, even better. Or well, not better, if you have too many x-es. There
I'd prefer to give shorter names to my
Hi Roman,
as far as I understand, the Clojure compiler is doing some
optimizations for recursive functions to save the variable lookup.
This means that you have to explicitly write the recursive call as
(#'fact (dec n)) if you want to dynamically rebind the function.
Somehow this doesn't feel righ
Thanks BG. I wasn't aware of the with-redefs. Then Gaz's way is cool.
--
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
(btw I threw this together just before bed, so it's not perfect. One
thing that's wrong is it assumes (name x) can be called on any x; but
it can't be called on lots of things, like numbers. So you'd need to
filter those out, and also fix a couple other bugs.
On Dec 1, 2:12 am, Alan Malloy wrote:
LoL lets you write:
(with-cxrs
(blah (foo (bar (cadddar x)
ie, it looks in your source, sees what you need defined, and makes a
letfn.
This looked fun, so I banged out an implementation:
(defn cxr-impl [name]
(when-let [op (second (re-matches #"c([ad]+)r" name))]
`(comp ~@(map {\a `
67 matches
Mail list logo