Re: best way to define alias for all publics in ns?

2011-01-19 Thread Laurent PETIT
2011/1/18 Ken Wesson 

> On Tue, Jan 18, 2011 at 1:07 PM, Stuart Sierra
>  wrote:
> > You're not really aliasing the Vars, you're creating new Vars and copying
> > the root values from the originals.
> > This leads to subtle bugs when the original Vars are dynamically rebound
> or
> > redefined.  That's why Compojure dropped `immigrate`.
>
> With 1.3, one could recreate a limited 'immigrate' that only imported
> the non-dynamically-bindable Vars from the target namespace. This
> wouldn't cause subtle bugs, only obvious ones if a wanted Var was
> dynamic and thus didn't get imported.
>

No, because in 1.3 it will still (hopefully!) be possible to change the root
value of vars, be they dynamically rebindable or not.


>
> The other solution to this is for Rich to add to core a facility for
> actually aliasing Vars themselves.
>
> --
> 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: Textmash - another IDE for Clojure

2011-01-19 Thread Laurent PETIT
Hello,

2011/1/18 Olek 

> Hi,
>
> Here is a link: http://code.google.com/p/textmash/
>
> Some time ago I have written it in order to help accomplish a task of
> creating some paraller processing  system written entirely in Clojure
> (it was the map reduce framework from Google).
>
> It was also used with success in other tasks, like editing PHP pages,
> Clojure learning, writing small programs in Clojure and some simple
> text processing.
>
> Feel free to contribute in bug fixing and improving or maybe even
> rewriting it in Clojure (there are not too much lines of code).
>

There's a "task" I have in my todo list since a long time, which is to
extract more of ccw "structural editing" and "clojure source code grammar
parser" into external projects.

Currently, "structural editing" in ccw is already totally decoupled from
Eclipse, or even any graphical toolkit (Swing / SWT). The only dependencies
of the "clojure grammar definition+parsley parser+structural edition
a-la-paredit commands" are clojure and clojure-contrib.

If you're interested, I could reprioritize this task and put it near the top
of my todo list.

As an example, calling a "paredit.clj" command looks like this: call a
multimethod named paredit.core/paredit:

  * call the parser to get a parsetree. Note that the parsetree follows
clojure.xml format.
  * give the parsetree to the paredit command, along with the command name
and the state of the editor (plain textual content, cursor position,
selection length). As a result you'll get a set of text changes to apply to
the source code in the form of a list of maps representing deltas: {:keys
[offset length text]} (in the original source code, replace the range
[offset (+ offset length)[ with text to effectively apply the paredit
command you invoked)

in code (pseudo-code, not my dev environment at hand), this would look like
with the current shape of the code/namespaces:

;; how would we invoke "raise over sexp" to get "(spy foo)" transformed into
"foo" with the cursor before "f" char and no current selection
(require '[paredit.parser :as p] '[paredit.core :as s])
(let [original-code "(spy foo)"
  parsetree (p/parse original-code)
  raise-over-delta (s/paredit :paredit-raise-sexp parsetree {:text
original-code :offset 5 :length 0})]
  raise-over-delta)
=> {:text "(spy foo)" :offset 5 :length 0 :modifs [ {:text "foo" :offset 0
:length 9} ]}

HTH,

-- 
Laurent



>
> The main idea is to take what is best in Eclipse, NetBeans and
> ergonomy of Mac OS and put into light tool.
> I hope you will enjoy it.
>
> Bye!
>
> --
> 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: Getting started with Counterclockwise

2011-01-19 Thread Laurent PETIT
2011/1/19 Meikel Brandmeyer 

> Hi,
>
> On 19 Jan., 00:28, Luc Prefontaine 
> wrote:
>
> > Can you provide the plugin list from Eclipse ? (About -> Installation
> > details)
>
> A while back I ran into a similar problem: a fresh install of eclipse
> + only ccw didn't work on my machine. Mysteriously using the same
> files for eclipse and ccw on a different machine worked as advertised.
> I contacted Laurent and he helped me tracking down the problem, but we
> quickly ran out of ideas and couldn't fix the issue. So maybe it's
> just bad karma...
>


Heh ;)

-- 
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: Getting started with Counterclockwise

2011-01-19 Thread Laurent PETIT
2011/1/18 Ken Wesson 

> On Tue, Jan 18, 2011 at 1:14 PM, Chas Emerick 
> wrote:
> > Any tone you might have picked up from Laurent might be a reaction to
> your ranting about how ccw is apparently rubbish rather than asking for
> help.
>
> Well, excse me for assuming,


Another day, less tired than today, another attempt.
[OT]
Ken, out of topic question: are you aware of the impact of the way you
"write things" ?
It's quite strange how you avoid the topic when people directly mention it.
And it's also strange how at the same time, you reinforce the problem by
using a writing style with emphasis on "complaining", "ranting", etc. : the
4 "u" in "excse me" being a good example of what I'm trying to explain.
[/OT]

Now back to business.

Ken, the "raw content" of your feedback report on installing and trying
Counterclockwise has been noted, and I certainly intend to pick ideas in it
for future releases of CCW.

In the mean time, there's a question you did not explicitly answer to: was
there an implicit question in your email, beyond its "informative" nature ?

Last question: would it be possible for you to try write your posts in a
less emotional/sarcastic/condescendent way ? Because it's really counter
productive and does not serve well neither the point you're trying to make,
neither the feelings of the recipient(s) of your mail.

Cheers,

-- 
Laurent


> quite reasonably, that if, after an
> install and restart during which no error messages appeared and
> subsequent to which "create new Clojure project" had appeared in the
> application menus, a feature, that if it existed should obviously be
> prominently featured in certain right-click menus, was not there, then
> it had not been implemented. :)
>
> > Tangentially, IMO it'd be nice if tooling troubleshooting discussions
> didn't hit this list at all, since there are presumably mailing lists and
> other forums specific to each toolset.
>
> Your email is the first place that I encountered the url for any forum
> specific to CCW. Notably, this means that no such url showed up at any
> point during the process of obtaining, installing, and attempting to
> use CCW. Troubleshooting discussions for CCW might show up here less
> frequently if the existence, nevermind the location, of the list you
> mentioned was more apparent to new users. :)
>
> (And, of course, let's not forget that this didn't actually start as a
> troubleshooting discussion. As far as I was aware CCW was working
> properly but simply did not have (easy access to) certain
> functionality that I had expected. So I was reviewing a
> product/starting a feature-request discussion, not starting a
> troubleshooting discussion, as far as I knew at the 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

Re: Clojure/JVM languages internal presentation

2011-01-19 Thread Robert Campbell
Hi Shantanu,

Good questions.

> Can you share some details about the language selection process? Was it based 
> on developers consensus or it was a purely management decision? Was the 
> presence or absence of enough number of Clojure/Scala experts in the team 
> influential on the eventual decision?

This was completely developer driven; management was mildly resistant
to the idea from the beginning. I made my case for Clojure to the
other tech/team leads and we all agreed to allow it on a case by case
basis. Once the development organization was in agreement, it was run
by management who pushed back due to staffing concerns. I negotiated a
compromise (Scala) which (mostly) alleviated the staffing concern, but
maintained many of the same benefits. This negotiation is partly
reflected in the language selection slides, where number of
books/training, developer acceptance/momentum, syntax were all used as
selection criteria.

> To help me understand, would you like to share how was this conclusion 
> derived ("Clojure - being a Lisp dialect - has a steeper learning curve due 
> to its syntax and more purely functional nature.")?

When I show a typical Java developer some Clojure code, they
immediately have to swim across two rivers: S expressions and
functional concepts. We can agree that taking the plunge is incredibly
rewarding, but we shouldn't deny that they present real obstacles to
many developers. In contrast, when I show them some imperative-style
Scala, they can immediately recognize syntax and patterns already
familiar to them. This allows them to get up and running quickly,
dipping their toe into functional concepts at their own rate. I do,
however, agree that Clojure is simpler to use once you've crossed
those rivers, helped deeply by its smaller, more consistent syntax.

Clojure and Scala are both great languages that provide concrete
improvements over vanilla Java. With this presentation I try to
highlight two of those improvements that I found most compelling.

Rob


On Tue, Jan 18, 2011 at 7:21 PM, Shantanu Kumar
 wrote:
> Rob, thanks for sharing this and congratulations on having IDC (your
> employer IIUC) adopting an alternate JVM language. Can you share some
> details about the language selection process? Was it based on
> developers consensus or it was a purely management decision? Was the
> presence or absence of enough number of Clojure/Scala experts in the
> team influential on the eventual decision? Finally, from your notes on
> slide #25:
>
>
> "Clojure - being a Lisp dialect - has a steeper learning curve due to
> its syntax and more purely functional nature.
> Since Scala is instead a hybrid language, both object oriented and
> functional, it’s completely possible to write imperative, Java-style
> Scala.
> This allows developers to slowly ease into the language, adding more
> powerful functional techniques as they become more comfortable.
> So when management asks, “Where am I gonna find Scala programmers?”,
> we can answer,
>   “The same places you find Java programmers: throughout IDC and the
> greater market,” almost honestly..."
>
>
> To help me understand, would you like to share how was this conclusion
> derived ("Clojure - being a Lisp dialect - has a steeper learning
> curve due to its syntax and more purely functional nature.")? Scala
> has more syntax/semantics than Clojure AFAICT. Was it familiarity with
> the Java syntax?
>
> Regards,
> Shantanu
>
> On Jan 18, 4:33 am, Robert Campbell  wrote:
>> Hey guys,
>>
>> This past summer I gave a presentation on JVM langauges at our
>> company's worldwide developer summit. I tried to get approval for
>> Clojure but had to settle for Scala because its syntax didn't frighten
>> management. I figured I'd share it in case any of the slides can be of
>> use elsewhere.
>>
>> open in browser (no 
>> notes):http://public.iwork.com/document/?d=JVM_Languages.key&a=p1045023190
>>
>> src:https://github.com/rcampbell/jvm-languages
>>
>> The talk (w/notes in github .key file) was very important and the
>> slides don't make much sense without it, but it generally went like:
>>
>> -Topic is JVM languages, what they are, why we should care about them
>> -We (as a mostly Java house) have two big problems: bloat and concurrency
>> -Show bloat with examples, try to illustrate a trend
>> -Why are these other languages so concise?
>> -Go back over the examples pulling out a single language feature from
>> each (in bold), explain how it leads to more concise code
>> -Talk a bit about concurrency, No free lunch (R), Ghz wall, cores increasing
>> -Java's answer to concurrency is difficult to work with
>> -Make a token effort to select a JVM language based on books,
>> perceived momentum/maturity/community, etc
>> -Select Clojure and Scala, end with Scala example since that's the one
>> that was approved (replace slide here :-)
>>
>> Rob
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to th

Re: Code Review of my first stab

2011-01-19 Thread Chas Emerick

On Jan 18, 2011, at 8:54 PM, Lee Spector wrote:

> Also BTW I saw no clear performance improvement (relative to the overall 
> runtime of my system); some numbers on that are also below.

A perf differential will be seen if slot access is a significant portion of the 
algorithms in question.  IIRC, the difference between struct maps and records 
is that between a map lookup + an array dereference vs. a direct field access 
(e.g. (.slotname foo)) or a function call that performs a direct field access 
(e.g. (:slotname foo)).  Irresponsible benchmarks below.  So, if your usage 
doesn't involve a ton of slot access, you won't see a big perf improvement.

- Chas

-
Irresponsible microbenchmark:

(defstruct foo [:a :b :c :d])
#'user/foo
(defrecord Bar [a b c d])
user.Bar
(time
  (let [s (struct-map foo 1 2 3 4)]
(dotimes [x 1e7]
  (:a s)
  (:b s)
  (:c s)
  (:d s
"Elapsed time: 4734.852 msecs"
nil
(time
  (let [s (Bar. 1 2 3 4)]
(dotimes [x 1e7]
  (:a s)
  (:b s)
  (:c s)
  (:d s
"Elapsed time: 721.399 msecs"

;; I've not checked this, but I suspect the differential will be even larger 
for structs/records with lots of slots

-- 
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: best way to define alias for all publics in ns?

2011-01-19 Thread Ken Wesson
On Wed, Jan 19, 2011 at 4:06 AM, Laurent PETIT  wrote:
> 2011/1/18 Ken Wesson 
>>
>> On Tue, Jan 18, 2011 at 1:07 PM, Stuart Sierra
>>  wrote:
>> > You're not really aliasing the Vars, you're creating new Vars and
>> > copying
>> > the root values from the originals.
>> > This leads to subtle bugs when the original Vars are dynamically rebound
>> > or
>> > redefined.  That's why Compojure dropped `immigrate`.
>>
>> With 1.3, one could recreate a limited 'immigrate' that only imported
>> the non-dynamically-bindable Vars from the target namespace. This
>> wouldn't cause subtle bugs, only obvious ones if a wanted Var was
>> dynamic and thus didn't get imported.
>
> No, because in 1.3 it will still (hopefully!) be possible to change the root
> value of vars, be they dynamically rebindable or not.

No, because alter-var-root! is an unsafe, mutating operation that
should not be done in production code, only at the repl during
testing.

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


Problem with garbage collection? Was Euler 14

2011-01-19 Thread Andreas Liljeqvist
Reposting this from earlier mail about Euler 14.

(defn cseq [n]
  (if (= 1 n)
[1]
(cons n (cseq (if (even? n)
(/ n 2)
(+ (* 3 n) 1 ))

(apply max-key count (map cseq (range 1 100)))

Gives a heap error.
cseq is at most 525 elements long.




2011/1/17 Mark Engelberg 

> On Mon, Jan 17, 2011 at 11:55 AM, Andreas Liljeqvist 
> wrote:
> > I don't see why the cseq's have to be lazy, they are at the most 525
> > elements long.
> > shouldn't each sequence only be produced when it is reduced in max-key
> and
> > then discarded?
>
> You're right, the chains aren't as long as I thought.  I can't think
> of any good explanation as to why max-key blows the heap when cseq is
> non-lazy and doesn't when cseq is lazy.  (I confirmed that on my
> system, I get the same behavior as you, even set to a 1600MB heap
> size).
>
> Interestingly, this:
> (apply max (map count (map cseq (range 1 100
> works just fine with non-lazy seq.
>
> The only real difference between this and the max-key version is that
> reducing the max-key requires keeping around the longest list so far,
> whereas this one just keeps around the count.  But keeping around a
> 525 element list shouldn't be enough to overflow the heap.
>
> I've tried to figure out:
> Could max-key be holding on to the heads of these lists?
> Could this be an effect of chunked sequences?
>
> The chunked sequences explanation seems almost plausible.  You could
> in theory have 32 lists realized at once, plus the biggest one you've
> seen so far.  But even in the worst-case scenario, you're talking
> about 15000 elements, and I don't see how that could overflow the
> heap.  Just out of curiosity, I tried this with an unchunked range,
> and still got the heap overflow, so I don't see how it could be a
> chunking issue.
>
> Furthermore if either of these were the problem, you'd expect to see
> the same problem with lazy cseq, because ultimately count has to
> realize the lazy cseq, so if too many heads were being retained at
> once, the lazy version would exhibit the same heap space problem.
>
> This leads to the more disturbing possibility that maybe there's a
> garbage collection flaw relating to non-lazy lists.
>
> I'd love to see some more people investigate this and see if we can
> come up with a good explanation as to why the original poster's code
> overflows the heap space.
>
> --
> 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: Code Review of my first stab

2011-01-19 Thread Tim Visher
Thanks for everyone's feedback. Sound like the code, in general, is
basically right. Probably some of the issues that I'm having with the
code comes from simply not being terribly familiar with reading
clojure code.

-- 
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: Getting started with Counterclockwise

2011-01-19 Thread Ken Wesson
On Wed, Jan 19, 2011 at 5:13 AM, Laurent PETIT  wrote:
>
>
> 2011/1/18 Ken Wesson 
>>
>> On Tue, Jan 18, 2011 at 1:14 PM, Chas Emerick 
>> wrote:
>> > Any tone you might have picked up from Laurent might be a reaction to
>> > your ranting about how ccw is apparently rubbish rather than asking for
>> > help.
>>
>> Well, excse me for assuming,
>
> Another day, less tired than today, another attempt.

?

> [OT]
> Ken, out of topic question: are you aware of the impact of the way you
> "write things" ?

?

> It's quite strange how you avoid the topic when people directly mention it.

?

> And it's also strange how at the same time, you reinforce the problem by
> using a writing style with emphasis on "complaining", "ranting", etc. : the
> 4 "u" in "excse me" being a good example of what I'm trying to explain.

Chas Emerick's post criticized me. I defended myself. The part of his
criticism that was unreasonable was the foundational assumption that I
had recognized CCW as malfunctioning rather than what actually
occurred, which was that as far as I was aware it was working properly
but simply lacking some features.

I don't think it was unreasonable for me to be a bit sarcastic in
pointing this out, since the original post makes it clear that I
interpreted what I saw as not-yet-implemented features rather than as
bugs.

Indeed, that original post was in no way deserving of criticism and
yet I've received nothing else since posting it. First from you with
your implication that I was remiss in not having read some "install
guide" that does not turn up at any point along the path to getting it
installed, and now from several people about my "writing style".

I respectfully suggest that if you don't like the slightly acerbic
style with which I respond in my own defense when unfairly criticized,
then perhaps you should simply avoid criticizing me.

> Ken, the "raw content" of your feedback report on installing and trying
> Counterclockwise has been noted, and I certainly intend to pick ideas in it
> for future releases of CCW.

You are involved in its development?

(If so, it's even more mystifying that you asked me to submit a ticket
on the problems I observed -- you would already have all the logins
and access you need to do so AND far more familiarity with the
tracker, so by the time I even got to your reply the ticket could have
already existed. And if the development team knew about these problems
before I encountered them, and even wrote some (lamentably not easily
stumbled-upon) documentation regarding work-arounds, shouldn't such a
ticket have *already* existed?)

> In the mean time, there's a question you did not explicitly answer to: was
> there an implicit question in your email, beyond its "informative" nature ?

No. Just statements of observed fact about CCW.

> Last question: would it be possible for you to try write your posts in a
> less emotional/sarcastic/condescendent way ?

I only replied in kind. The first snark was from you, if you'll recall:

> I have good news for you: ccw documentation is linked from the main
> page of the counterclockwise project, in the "Quick links" section,
> and it's neither a pdf neither a video, plain old wiki page

This is clearly not only sarcastic but an implied criticism that I
should have already seen and read this, even though nowhere is any of
it linked to during the process of getting and installing CCW.

> Because it's really counter productive and does not serve well neither
> the point you're trying to make, neither the feelings of the recipient(s)
> of your mail.

That applies double to whoever throws the first snark. Nobody should
be surprised or especially dismayed if, after someone does so, their
target responds in kind.

-- 
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: best way to define alias for all publics in ns?

2011-01-19 Thread Laurent PETIT
2011/1/19 Ken Wesson 

> On Wed, Jan 19, 2011 at 4:06 AM, Laurent PETIT 
> wrote:
> > 2011/1/18 Ken Wesson 
> >>
> >> On Tue, Jan 18, 2011 at 1:07 PM, Stuart Sierra
> >>  wrote:
> >> > You're not really aliasing the Vars, you're creating new Vars and
> >> > copying
> >> > the root values from the originals.
> >> > This leads to subtle bugs when the original Vars are dynamically
> rebound
> >> > or
> >> > redefined.  That's why Compojure dropped `immigrate`.
> >>
> >> With 1.3, one could recreate a limited 'immigrate' that only imported
> >> the non-dynamically-bindable Vars from the target namespace. This
> >> wouldn't cause subtle bugs, only obvious ones if a wanted Var was
> >> dynamic and thus didn't get imported.
> >
> > No, because in 1.3 it will still (hopefully!) be possible to change the
> root
> > value of vars, be they dynamically rebindable or not.
>
> No, because alter-var-root! is an unsafe, mutating operation that
> should not be done in production code, only at the repl during
> testing.
>

Where it would also be painful to have to drop/recreate namespaces using
this export feature, every time you would alter the root value of the var of
an exported namespace.

And of course, while we agree that this should not be done in production
code, there's by definition a difference between theory and practice, and
"should not be done" does not equate "cannot be done", how opinionated your
"should" is.

-- 
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: best way to define alias for all publics in ns?

2011-01-19 Thread Ken Wesson
On Wed, Jan 19, 2011 at 8:49 AM, Laurent PETIT  wrote:
> 2011/1/19 Ken Wesson 
>> On Wed, Jan 19, 2011 at 4:06 AM, Laurent PETIT 
>> wrote:
>> > 2011/1/18 Ken Wesson 
>> >> On Tue, Jan 18, 2011 at 1:07 PM, Stuart Sierra
>> >>  wrote:
>> >> > You're not really aliasing the Vars, you're creating new Vars and
>> >> > copying
>> >> > the root values from the originals.
>> >> > This leads to subtle bugs when the original Vars are dynamically
>> >> > rebound
>> >> > or
>> >> > redefined.  That's why Compojure dropped `immigrate`.
>> >>
>> >> With 1.3, one could recreate a limited 'immigrate' that only imported
>> >> the non-dynamically-bindable Vars from the target namespace. This
>> >> wouldn't cause subtle bugs, only obvious ones if a wanted Var was
>> >> dynamic and thus didn't get imported.
>> >
>> > No, because in 1.3 it will still (hopefully!) be possible to change the
>> > root
>> > value of vars, be they dynamically rebindable or not.
>>
>> No, because alter-var-root! is an unsafe, mutating operation that
>> should not be done in production code, only at the repl during
>> testing.
>
> Where it would also be painful to have to drop/recreate namespaces using
> this export feature, every time you would alter the root value of the var of
> an exported namespace.

I can count on zero fingers the number of times that I, personally,
have had occasion to use alter-var-root!

> And of course, while we agree that this should not be done in production
> code, there's by definition a difference between theory and practice, and
> "should not be done" does not equate "cannot be done", how opinionated your
> "should" is.

But it does mean that it's less important to avoid possibly creating
additional caveats to using something that is already best-avoided,
such as alter-var-root!.

However, as my earlier post noted a fully general solution would be to
have a means of aliasing Vars, so that multiple symbols in possibly
multiple namespaces referenced the same Var object. In theory it's not
difficult: somewhere for each namespace is a map of symbols to Var
objects, and no inherent reason the same Var couldn't be the value for
multiple keys or a value in multiple such maps.

In fact, only one single new function would need to be in core: one to
intern a symbol in a namespace that takes an existing Var object
rather than creating a new one. (intern 'ns 'name
#'other-ns/other-name) creates a new Var whose root binding is the
existing Var object, but it shouldn't be hard in principle for core to
add an (intern-var 'ns 'name #'existing-var) function that aliases an
existing var in ns under name.

Whether there are other reasons to avoid adding such a feature, I'm
unsure. But it would make the kind of importing discussed in this
thread work without any difficulties with alter-var-root! or with
dynamic Vars.

Now, poking at the clojure.lang.Var methods I don't see any
.getNamespace or similar that would mean that Vars have an enforced
one-to-one relationship with host namespaces, or any .getSymbol or
.getName or similar that would mean that Vars cannot be aliased under
multiple names in a single namespace. So there's no *technical*
obstacle that I can detect to doing this.

The clojure.lang.Namespace class does not, unfortunately, provide any
method to intern a symbol with a preexisting var; it would be simple
enough to wrap such in a Clojure function that interned a preexisting
var into the current namespace with a given symbol name. It has an
intern method that creates a new Var and a refer method that accepts a
symbol and a Var and returns a Var, but the latter does not work if
passed a symbol not currently interned in the namespace and a
preexisting Var. It also has a method to return the namespace's
contents as an IPersistentMap, but this obviously is not usable for
modifying those contents.

So it looks like clojure.lang.Namespace must be modified for such a
feature to be born. It can't be done from inside of Clojure.

-- 
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: best way to define alias for all publics in ns?

2011-01-19 Thread Laurent PETIT
2011/1/19 Ken Wesson 

> On Wed, Jan 19, 2011 at 8:49 AM, Laurent PETIT 
> wrote:
> > 2011/1/19 Ken Wesson 
> >> On Wed, Jan 19, 2011 at 4:06 AM, Laurent PETIT  >
> >> wrote:
> >> > 2011/1/18 Ken Wesson 
> >> >> On Tue, Jan 18, 2011 at 1:07 PM, Stuart Sierra
> >> >>  wrote:
> >> >> > You're not really aliasing the Vars, you're creating new Vars and
> >> >> > copying
> >> >> > the root values from the originals.
> >> >> > This leads to subtle bugs when the original Vars are dynamically
> >> >> > rebound
> >> >> > or
> >> >> > redefined.  That's why Compojure dropped `immigrate`.
> >> >>
> >> >> With 1.3, one could recreate a limited 'immigrate' that only imported
> >> >> the non-dynamically-bindable Vars from the target namespace. This
> >> >> wouldn't cause subtle bugs, only obvious ones if a wanted Var was
> >> >> dynamic and thus didn't get imported.
> >> >
> >> > No, because in 1.3 it will still (hopefully!) be possible to change
> the
> >> > root
> >> > value of vars, be they dynamically rebindable or not.
> >>
> >> No, because alter-var-root! is an unsafe, mutating operation that
> >> should not be done in production code, only at the repl during
> >> testing.
> >
> > Where it would also be painful to have to drop/recreate namespaces using
> > this export feature, every time you would alter the root value of the var
> of
> > an exported namespace.
>
> I can count on zero fingers the number of times that I, personally,
> have had occasion to use alter-var-root!
>

redefinition of var's root value will happen everytime you reemit defs for
the same var.
So unless you're using the REPL to just query the environment or start from
a new REPL everytime you want to redef (eg call def again) a var, ...


>
> > And of course, while we agree that this should not be done in production
> > code, there's by definition a difference between theory and practice, and
> > "should not be done" does not equate "cannot be done", how opinionated
> your
> > "should" is.
>
> But it does mean that it's less important to avoid possibly creating
> additional caveats to using something that is already best-avoided,
> such as alter-var-root!.
>
> However, as my earlier post noted a fully general solution would be to
> have a means of aliasing Vars


This would certainly be a solution to the problem of the OP.

-- 
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] fs - file system utilities for Clojure

2011-01-19 Thread Rayne
It isn't nearly as big a deal as you think it is. I'm guessing you have a 
single file called 'fs.clj' with the namespace 'fs', right?

mkdir src/fs/
mv src/fs.clj src/fs/core.clj

 
and then edit the file and change the namespace to fs.core. Why is that such 
a big deal? I understand that you're coming from Python, but Clojure isn't, 
and never will be Python. If you came from COBOL would you want to write 
your code in all caps? Nobody is asking you to do this for fun. This is a 
Clojure idiom that *everybody* uses, and it isn't only for you but for users 
of your code. 

-- 
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: Getting started with Counterclockwise

2011-01-19 Thread Rayne
Aren't you a developer? I am. I think everybody else here is as well.
If a code.google link is the top of google results, that's what I'm
going to click and check out first. code.google is a project hosting
site, not just a place to throw up code and developer discussion. It
offers wiki services, downloads, and various other things that are
useful to users and developers alike. Most importantly, you're looking
for an Clojure plugin for Eclipse, Touch Type Like Pros v2.0. Wouldn't
a developer looking for developer tools be apt to check out a
developer site of which they are likely already familiar with anyway?

And would you consider Github results as unintuitive and 'developer-
centric' as Google Code? If so, good luck finding libraries and other
Clojure projects, because 98% of them are hosted on Github, and not
many see necessity in a whole website dedicated to them.

> Ah. That would be the site that most prospective users will assume is
> a developer-centric site.

-- 
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: Getting started with Counterclockwise

2011-01-19 Thread Luc Prefontaine
Ken,

It's always easy to complain and you seem excellent at it.
However, to investigate any problem, hard facts are needed to
support the fixing process.

There are little facts reported in your emails about the problems you
experienced according to you regarding ccw.

Not reading wiki pages available, not investigating available links
about ccw are more a sign of mental laziness than anything else or
some form of disdain.

It's clear that you are not familiar with Eclipse and this is a
sinequanone condition to use an IDE. Either read Eclipse
documentation or develop knowledge to extensive use
before ranting about it. Whatever is efficient for you.

If these mundane activities are not important to you then maybe you
should balance your post contents a bit and change the ranting/facts
ratio. You cannot hold others responsible for your lack of knowledge
in some areas.

I see the same pattern with your ranting against the numeric
optimizations in 1.3. All of these discussions are available in the
google group mailing list but it seems you did not read them to fully
understand the pros and cons of each approach that where evaluated.

Too bad you joined the group after these decisions where made.
It's up to you to live with it and catch up. That's your problem,
not ours.

You have been asked kindly to change your tone.

Lucky for you, I do not use white gloves most of the time so you get my
appreciation of your contribution straight here.

As nice as some of your previous posts:

It's easy to write things like you do when you do not have any face to
face contact with the recipients of your diatribes. I'm big, mean and
I hate prima donnas. You would not even try to use that tone with a guy
like me. You did not even rant at me and I cannot stand your posts
anymore.

You should change career, maybe the Hollywood star system would be
an alternative.
 
To prevent myself from throwing-up daily, I added a rule to my email
client so emails having your name in it ends up in the junk folder.
I regularly empty it without reading its content.

I invite others that find your tone inconvenient to do the same.

You can still rant in the desert, at least I will not spend anymore time
reading your unconstructive complaints.

Have a nice day,

Luc P.

On Wed, 19 Jan 2011 08:49:35 -0500
Ken Wesson  wrote:

> On Wed, Jan 19, 2011 at 5:13 AM, Laurent PETIT
>  wrote:
> >
> >
> > 2011/1/18 Ken Wesson 
> >>
> >> On Tue, Jan 18, 2011 at 1:14 PM, Chas Emerick
> >>  wrote:
> >> > Any tone you might have picked up from Laurent might be a
> >> > reaction to your ranting about how ccw is apparently rubbish
> >> > rather than asking for help.
> >>
> >> Well, excse me for assuming,
> >
> > Another day, less tired than today, another attempt.
> 
> ?
> 
> > [OT]
> > Ken, out of topic question: are you aware of the impact of the way
> > you "write things" ?
> 
> ?
> 
> > It's quite strange how you avoid the topic when people directly
> > mention it.
> 
> ?
> 
> > And it's also strange how at the same time, you reinforce the
> > problem by using a writing style with emphasis on "complaining",
> > "ranting", etc. : the 4 "u" in "excse me" being a good example
> > of what I'm trying to explain.
> 
> Chas Emerick's post criticized me. I defended myself. The part of his
> criticism that was unreasonable was the foundational assumption that I
> had recognized CCW as malfunctioning rather than what actually
> occurred, which was that as far as I was aware it was working properly
> but simply lacking some features.
> 
> I don't think it was unreasonable for me to be a bit sarcastic in
> pointing this out, since the original post makes it clear that I
> interpreted what I saw as not-yet-implemented features rather than as
> bugs.
> 
> Indeed, that original post was in no way deserving of criticism and
> yet I've received nothing else since posting it. First from you with
> your implication that I was remiss in not having read some "install
> guide" that does not turn up at any point along the path to getting it
> installed, and now from several people about my "writing style".
> 
> I respectfully suggest that if you don't like the slightly acerbic
> style with which I respond in my own defense when unfairly criticized,
> then perhaps you should simply avoid criticizing me.
> 
> > Ken, the "raw content" of your feedback report on installing and
> > trying Counterclockwise has been noted, and I certainly intend to
> > pick ideas in it for future releases of CCW.
> 
> You are involved in its development?
> 
> (If so, it's even more mystifying that you asked me to submit a ticket
> on the problems I observed -- you would already have all the logins
> and access you need to do so AND far more familiarity with the
> tracker, so by the time I even got to your reply the ticket could have
> already existed. And if the development team knew about these problems
> before I encountered them, and even wrote some (lamentably not easily
> stumbled-upon) docume

Re: Getting started with Counterclockwise

2011-01-19 Thread Baishampayan Ghose
> I'm big, mean and I hate prima donnas. You would not even try to use that
> tone with a guy like me.

I can vouch for that!

Regards,
BG

-- 
Baishampayan Ghose
b.ghose at gmail.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


Re: slow mysql inserts

2011-01-19 Thread Christian Vest Hansen
I suspect that ClojureQL and with-connection are opening and closing
the connection for every query, whereas the Java and Perl versions are
reusing their connections.

Try adding a connection pool to the mix.

On Tue, Jan 18, 2011 at 19:32, rygorr  wrote:
> I'm currently doing some preliminary performance testing of db inserts
> with various technologies.  The db server itself is nothing special
> but what surprised me was the difference in INSERT speeds between
> Clojure and the other solutions I've tried.  Clearly there is
> something I'm missing so perhaps I can get some insight.
>
> Java code INSERT was about 500 rows/sec.  The Clojure code was about
> 30 rows/sec (both ClojureQL and with-connection versions).  Perl DBI
> and ObjC were both around 500 rows/sec.  I'm comparing relative speed
> -- the 'mysql server' is just a mac-mini running Mysql 5.0.  While I
> recognize this is a pretty simplistic seat-of-the-pants test I wasn't
> expecting 16x slower.
>
> ClojureQL code:
> (def test (sql/table db :test))
> (doseq [x (range 2000)]
>    @(sql/conj! test [{:value x}]))
>
> Vanilla clojure code I tried as well.
> (doseq [x (range 2000)]
>    (with-connection db
>       (insert-values :test
>                      [:value] [x])))
> db is the com.mysql.jdbc.Driver connection string.
>
> Pure Java:
>        for(int i = 2000 ;  i>0 ; i--){
>            try {
>                java.sql.Statement s = conn.createStatement();
>                s.executeUpdate("insert into test (value) values(" + i + ")");
>            }
>            catch (Exception e) {
>                System.out.println(e);
>                System.exit(0);
>            }
>        }
> where conn here is again my com.mysql.jdbc.Driver connection string.
>
> I used the same mysql-connector-java jar for all tests on the JVM.
> Initially my tests were run in the cake-swank JVM.  To try to
> eliminate any variables I also created a jar with lein and tested
> that.  The pure java code was compiled and run command line.
>
> I don't believe for a second this is an issue with clojure, but to be
> honest I'm not clear where to start troubleshooting.
>
> What sort of things can I play with to figure out where the bottleneck
> is?
>
> 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



-- 
Venlig hilsen / Kind regards,
Christian Vest Hansen.

-- 
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: slow mysql inserts

2011-01-19 Thread Meikel Brandmeyer
Hi,

On 18 Jan., 19:32, rygorr  wrote:

> (doseq [x (range 2000)]
>     (with-connection db
>        (insert-values :test
>                       [:value] [x])))
> db is the com.mysql.jdbc.Driver connection string.

Move the with-connection outside the doseq.

(with-connection db
  (doseq [x (range 2000)]
(insert-values :test [:value] [x])))

Sincerely
Meikel

-- 
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: Getting started with Counterclockwise

2011-01-19 Thread Laurent PETIT
2011/1/19 Luc Prefontaine 

> Ken,
>
> It's always easy to complain and you seem excellent at it.
> However, to investigate any problem, hard facts are needed to
> support the fixing process.
>
> There are little facts reported in your emails about the problems you
> experienced according to you regarding ccw.
>
> Not reading wiki pages available, not investigating available links
> about ccw are more a sign of mental laziness than anything else or
> some form of disdain.
>
> It's clear that you are not familiar with Eclipse and this is a
> sinequanone condition to use an IDE. Either read Eclipse
> documentation or develop knowledge to extensive use
> before ranting about it. Whatever is efficient for you.
>
> If these mundane activities are not important to you then maybe you
> should balance your post contents a bit and change the ranting/facts
> ratio. You cannot hold others responsible for your lack of knowledge
> in some areas.
>
> I see the same pattern with your ranting against the numeric
> optimizations in 1.3. All of these discussions are available in the
> google group mailing list but it seems you did not read them to fully
> understand the pros and cons of each approach that where evaluated.
>
> Too bad you joined the group after these decisions where made.
> It's up to you to live with it and catch up. That's your problem,
> not ours.
>
> You have been asked kindly to change your tone.
>
> Lucky for you, I do not use white gloves most of the time so you get my
> appreciation of your contribution straight here.
>
> As nice as some of your previous posts:
>
> It's easy to write things like you do when you do not have any face to
> face contact with the recipients of your diatribes. I'm big, mean and
> I hate prima donnas. You would not even try to use that tone with a guy
> like me. You did not even rant at me and I cannot stand your posts
> anymore.
>
> You should change career, maybe the Hollywood star system would be
> an alternative.
>
> To prevent myself from throwing-up daily, I added a rule to my email
> client so emails having your name in it ends up in the junk folder.
> I regularly empty it without reading its content.
>
> I invite others that find your tone inconvenient to do the same.
>

I really tried not to come to such extremes, but I'll too follow this
advice. The filter rule will help me resist the temptation of doing more
harm than good by continuing to participate to ruining Clojure's mailing
list good reputation.
Too bad I'll certainly miss some interesting content in the process, but I
can live with that.

-- 
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: Problem with garbage collection? Was Euler 14

2011-01-19 Thread Miki


> (defn cseq [n]
>   (if (= 1 n)
> [1]
> (cons n (cseq (if (even? n)
> (/ n 2)
> (+ (* 3 n) 1 ))
>
> (apply max-key count (map cseq (range 1 100)))
>
> Gives a heap error.
> cseq is at most 525 elements long.
>
The solution is much more than 525 (> 80). Note that you're probably 
computing the same thing over and over again so "memoize" 
can come very handy here. 

-- 
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] fs - file system utilities for Clojure

2011-01-19 Thread Miki


> It isn't nearly as big a deal as you think it is. I'm guessing you have a 
> single file called 'fs.clj' with the namespace 'fs', right?
>
> mkdir src/fs/
> mv src/fs.clj src/fs/core.clj
>
and then edit the file and change the namespace to fs.core. 
>
I know it's easy to do, I just don't think I should do it.
 
 

> Why is that such a big deal? 
>
It's not a big deal. I don't get what's the big deal of doing
(require 'fs)
(fs/copy "/some/file" "/some/other/file")

 

> I understand that you're coming from Python, but Clojure isn't, and never 
> will be Python. If you came from COBOL would you want to write your code in 
> all caps? Nobody is asking you to do this for fun. This is a Clojure idiom 
> that *everybody* uses, and it isn't only for you but for users of your 
> code. 
>
 
Somebody needs to be the anarchist in the group :) 
I don't believe in doing things just because everybody else is doing them. 
And I haven't heard a compelling
reason (IMO) so far to change. When there are logical namespaces, I'll 
gladly add them. But this is just a bunch of file system
functions. Also I don't see how users of the code suffer from having one 
short namespace.

I'd appreciate some comments about need functionality, bugs, code reviews 
and such.

All the best,
--
Miki
 

-- 
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: Testing if a sequence is lazy

2011-01-19 Thread Chouser
On Tue, Jan 18, 2011 at 12:22 AM, Nick Brown  wrote:
> Hi, I'm wondering if there is a good way to test if a given sequence
> is lazy, and if so, how much of it has been evaluated.  I know the
> fact that it is lazy should be transparent, but I'm thinking in the
> context of unit testing knowing that could be valuable.  For instance
> if you know a particular sequence could be particularly large or
> expensive in certain situations, you may want your tests to assert
> that it is not getting evaluated prematurely.
>
> I suppose I could hack the generator function to cause a side effect
> that I could test for, but is there an easier way?

I've got some code that changes the way the REPL prints lazy seqs so
that it never forces the realization of anything.  It prints anything
that's already been forced, but then prints "...unrealized..." for the
rest.  I don't know if this is useful for unit testing, but I've found
it helpful at the REPL.

Also note that it's a complete hack -- includes big chunks of code
copied from clojure.core (hence the copyright notice), makes use of
internal clojure details that could change at any time, probably fails
in various spectacular ways.  Use at your own risk. :-)

http://gist.github.com/589694

--Chouser
http://joyofclojure.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


Re: [ANN] fs - file system utilities for Clojure

2011-01-19 Thread Eric Schulte
Miki  writes:

>> It isn't nearly as big a deal as you think it is. I'm guessing you have a 
>> single file called 'fs.clj' with the namespace 'fs', right?
>>
>> mkdir src/fs/
>> mv src/fs.clj src/fs/core.clj
>>
> and then edit the file and change the namespace to fs.core. 
>
> I know it's easy to do, I just don't think I should do it.
>  

More power to you, I personally don't particularly care about Java
interop (pretty sure Java has enough file system utilities) and I'd
rather not type ".core" all over the place.  If it wasn't for the soft
paternalism of lein I wouldn't user .core at all.

>
> I'd appreciate some comments about need functionality, bugs, code reviews 
> and such.
>

I have one question, is there any documentation available for the
functions provided by fs?  I would love a place where I could go to scan
the available functions, other than the source code.

Thanks -- Eric

-- 
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] fs - file system utilities for Clojure

2011-01-19 Thread B Smith-Mannschott
On Wed, Jan 19, 2011 at 15:30, Rayne  wrote:
> It isn't nearly as big a deal as you think it is. I'm guessing you have a
> single file called 'fs.clj' with the namespace 'fs', right?
> mkdir src/fs/
> mv src/fs.clj src/fs/core.clj
>
> and then edit the file and change the namespace to fs.core. Why is that such
> a big deal? I understand that you're coming from Python, but Clojure isn't,
> and never will be Python. If you came from COBOL would you want to write
> your code in all caps? Nobody is asking you to do this for fun. This is a
> Clojure idiom that everybody uses, and it isn't only for you but for users
> of your code.

This is a retarded 'convention', and it isn't really much of a
convention at that. Just because Clojure itself has a 'core.clj',
doesn't mean everyone else needs one now too. I blame Leiningen's
defaults. For counter-examples, take a look at clojure-contrib. The
only core.clj in there is for proposed additions to clojure.core
itself.

If I were writing a library 'flub', I'd expected the main file the
user is expected to :use to be named flub.clj and supporting files to
be flub/SOMETHING.clj.  If I wanted to make sure it was disambiguated,
say if I intended it as a library and not a stand-alone application, I
might call the namespace PREFIX.flub and PREFIX.flub.something, where
PREFIX is something one might reasonably expect to be unique, e.g.
bpsmithmannschott.flub.

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


Re: [ANN] fs - file system utilities for Clojure

2011-01-19 Thread Meikel Brandmeyer
Hi,

Am 19.01.2011 um 21:24 schrieb B Smith-Mannschott:

> This is a retarded 'convention', and it isn't really much of a
> convention at that. Just because Clojure itself has a 'core.clj',
> doesn't mean everyone else needs one now too. I blame Leiningen's
> defaults. For counter-examples, take a look at clojure-contrib. The
> only core.clj in there is for proposed additions to clojure.core
> itself.

Hmm… Wasn't the „main“ reason of technical nature? Namely classes in the 
default package? Which cause problems in Java world?

Sincerely
Meikel

-- 
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] fs - file system utilities for Clojure

2011-01-19 Thread Miki

>
> I have one question, is there any documentation available for the
> functions provided by fs?  I would love a place where I could go to scan
> the available functions, other than the source code.
>
https://bitbucket.org/tebeka/fs/src 

-- 
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: Problem with garbage collection? Was Euler 14

2011-01-19 Thread Andreas Liljeqvist
user> (defn cseq [n]
  (if (= 1 n)
[1]
(lazy-seq (cons n (cseq (if (even? n)
  (/ n 2)
  (+ (* 3 n) 1 )))
#'user/cseq
user> (count (apply max-key count (map cseq (range 1 100
525

user> (first (apply max-key count (map cseq (range 1 100
837799

The solution is 837799, but the longest sequence is 525.
My primary question remain (towards the non-lazy version).

Why does this fail btw?
(def a (apply max-key count (map cseq (range 1 100
*Heap error*

Thanks.

2011/1/19 Miki 

>
> (defn cseq [n]
>>   (if (= 1 n)
>> [1]
>> (cons n (cseq (if (even? n)
>> (/ n 2)
>> (+ (* 3 n) 1 ))
>>
>> (apply max-key count (map cseq (range 1 100)))
>>
>> Gives a heap error.
>> cseq is at most 525 elements long.
>>
> The solution is much more than 525 (> 80). Note that you're probably
> computing the same thing over and over again so "memoize"
> can come very handy here.
>
> --
> 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] fs - file system utilities for Clojure

2011-01-19 Thread Adam
There appears to be a bug in "walk" when there is an empty folder somewhere
beneath the specified directory.  I've only tested this on Win XP but this
triggers a NullPointerException on fs 0.4.0:

(walk "c:/empty" (fn [& a] true))

No message.
  [Thrown class java.lang.NullPointerException]

Restarts:
 0: [QUIT] Quit to the SLIME top level

Backtrace:
  0: clojure.lang.Reflector.invokeNoArgInstanceMember(Reflector.java:263)
  1: fs$w_file_QMARK_.invoke(fs.clj:192)
  2: fs$walk.invoke(fs.clj:204)
  3: t$eval2410.invoke(NO_SOURCE_FILE:1)
  4: clojure.lang.Compiler.eval(Compiler.java:5424)
  5: clojure.lang.Compiler.eval(Compiler.java:5391)
  6: clojure.core$eval.invoke(core.clj:2382)
  7: swank.commands.basic$eval_region.invoke(basic.clj:47)
  [No Locals]
  8: swank.commands.basic$eval_region.invoke(basic.clj:37)
  9: swank.commands.basic$eval807$listener_eval__808.invoke(basic.clj:71)
 10: clojure.lang.Var.invoke(Var.java:365)
 11: t$eval2408.invoke(NO_SOURCE_FILE)
 12: clojure.lang.Compiler.eval(Compiler.java:5424)
 13: clojure.lang.Compiler.eval(Compiler.java:5391)
 14: clojure.core$eval.invoke(core.clj:2382)
 15: swank.core$eval_in_emacs_package.invoke(core.clj:94)
 16: swank.core$eval_for_emacs.invoke(core.clj:241)
 17: clojure.lang.Var.invoke(Var.java:373)
 18: clojure.lang.AFn.applyToHelper(AFn.java:169)
 19: clojure.lang.Var.applyTo(Var.java:482)
 20: clojure.core$apply.invoke(core.clj:540)
 21: swank.core$eval_from_control.invoke(core.clj:101)
 22: swank.core$eval_loop.invoke(core.clj:106)
 23: swank.core$spawn_repl_thread$fn__489$fn__490.invoke(core.clj:311)
 24: clojure.lang.AFn.applyToHelper(AFn.java:159)
 25: clojure.lang.AFn.applyTo(AFn.java:151)
 26: clojure.core$apply.invoke(core.clj:540)
 27: swank.core$spawn_repl_thread$fn__489.doInvoke(core.clj:308)
 28: clojure.lang.RestFn.invoke(RestFn.java:398)
 29: clojure.lang.AFn.run(AFn.java:24)
 30: java.lang.Thread.run(Unknown Source)

~Adam~

-- 
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: slow mysql inserts

2011-01-19 Thread rygorr
This was it.  The overhead was in creating the handle.  

When I moved the doseq inside the with-connection it solved the problem.

Thanks

On Jan 19, 2011, at 7:24 AM, Meikel Brandmeyer wrote:

> Hi,
> 
> On 18 Jan., 19:32, rygorr  wrote:
> 
>> (doseq [x (range 2000)]
>> (with-connection db
>>(insert-values :test
>>   [:value] [x])))
>> db is the com.mysql.jdbc.Driver connection string.
> 
> Move the with-connection outside the doseq.
> 
> (with-connection db
>  (doseq [x (range 2000)]
>(insert-values :test [:value] [x])))
> 
> Sincerely
> Meikel
> 
> -- 
> 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: slow mysql inserts

2011-01-19 Thread Michael Ossareh
On Wed, Jan 19, 2011 at 09:15, rygorr  wrote:

> This was it.  The overhead was in creating the handle.
>
>
I can't remember who told me this: "Always blame the network".

In finer detail, the conversation was about things that use the network and
are so very much slower than you anticipate.

-- 
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: Textmash - another IDE for Clojure

2011-01-19 Thread Nathan Sorenson
I've always wanted to have an in-game scripting console that has
access to some of the functionality I'm used to in emacs, like
paredit. This would actually be really useful in achieving this, I
think!

On Jan 19, 1:44 am, Laurent PETIT  wrote:
> Hello,
>
> 2011/1/18 Olek 
>
> > Hi,
>
> > Here is a link:http://code.google.com/p/textmash/
>
> > Some time ago I have written it in order to help accomplish a task of
> > creating some paraller processing  system written entirely in Clojure
> > (it was the map reduce framework from Google).
>
> > It was also used with success in other tasks, like editing PHP pages,
> > Clojure learning, writing small programs in Clojure and some simple
> > text processing.
>
> > Feel free to contribute in bug fixing and improving or maybe even
> > rewriting it in Clojure (there are not too much lines of code).
>
> There's a "task" I have in my todo list since a long time, which is to
> extract more of ccw "structural editing" and "clojure source code grammar
> parser" into external projects.
>
> Currently, "structural editing" in ccw is already totally decoupled from
> Eclipse, or even any graphical toolkit (Swing / SWT). The only dependencies
> of the "clojure grammar definition+parsley parser+structural edition
> a-la-paredit commands" are clojure and clojure-contrib.
>
> If you're interested, I could reprioritize this task and put it near the top
> of my todo list.
>
> As an example, calling a "paredit.clj" command looks like this: call a
> multimethod named paredit.core/paredit:
>
>   * call the parser to get a parsetree. Note that the parsetree follows
> clojure.xml format.
>   * give the parsetree to the paredit command, along with the command name
> and the state of the editor (plain textual content, cursor position,
> selection length). As a result you'll get a set of text changes to apply to
> the source code in the form of a list of maps representing deltas: {:keys
> [offset length text]} (in the original source code, replace the range
> [offset (+ offset length)[ with text to effectively apply the paredit
> command you invoked)
>
> in code (pseudo-code, not my dev environment at hand), this would look like
> with the current shape of the code/namespaces:
>
> ;; how would we invoke "raise over sexp" to get "(spy foo)" transformed into
> "foo" with the cursor before "f" char and no current selection
> (require '[paredit.parser :as p] '[paredit.core :as s])
> (let [original-code "(spy foo)"
>       parsetree (p/parse original-code)
>       raise-over-delta (s/paredit :paredit-raise-sexp parsetree {:text
> original-code :offset 5 :length 0})]
>   raise-over-delta)
> => {:text "(spy foo)" :offset 5 :length 0 :modifs [ {:text "foo" :offset 0
> :length 9} ]}
>
> HTH,
>
> --
> Laurent
>
>
>
>
>
>
>
>
>
> > The main idea is to take what is best in Eclipse, NetBeans and
> > ergonomy of Mac OS and put into light tool.
> > I hope you will enjoy it.
>
> > Bye!
>
> > --
> > 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: Grabbing Rotten Tomatoes movie ratings in clojure

2011-01-19 Thread Mark Nutter
Let me also recommend swannodette's excellent Enlive tutorial:

https://github.com/swannodette/enlive-tutorial

It's a great way to jump into the meat and potatoes.

m

On Tue, Jan 18, 2011 at 7:05 PM, justinhj  wrote:
> Thanks for the feedback Stuart
>
> I'll check out Enliven. I'm currently writing an app using Compojure,
> Ring and Hiccup, so it would fit nicely with that too by the sound of
> it.
>
>
> On Jan 16, 7:25 pm, Stuart Campbell  wrote:
>> Hi,
>>
>> Have you used Enlive[1]? It's a nice tool for HTML scraping and templating -
>> it might be more robust than your regexp-based solution. It takes a bit of
>> learning, though.
>>
>> Regards,
>> Stuart
>>
>> [1]https://github.com/cgrand/enlive
>>
>> On 16 January 2011 05:57, justinhj  wrote:
>>
>>
>>
>>
>>
>>
>>
>> > Sharing my first useful Clojure program. Feedback welcome.
>>
>> >http://bit.ly/clojure-rotten-tomatoes
>>
>> >  --
>> > 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

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


Leiningen and apache commons

2011-01-19 Thread Andreas Kostler
Hi All,
Can someone please tell me how to import the Apache commons net
library? I'm using leiningen. The project.clj looks like this:
(defproject clojure-scheme "1.0.0-SNAPSHOT"
  :description "FIXME: write"
  :dependencies [[org.clojure/clojure "1.2.0"]
 [org.clojure/clojure-contrib "1.2.0"]
 [commons-net/commons-net "2.2"]]
  :dev-dependencies [[swank-clojure "1.2.2"]]
  :main clojure-scheme.core)

Which puts commons-net-2.2.jar in the lib directory of my project.
How can I import and use functionality in clojure? I want to do
something like
(def telnet (new TelnetClient)) ... but all attempts failed so far.

Kind Regards
Andreas

-- 
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: best way to define alias for all publics in ns?

2011-01-19 Thread Seth
The core actually wouldn't have to be modified, as it already does
something similar. After all, the function 'use' already does it - if
we 'use' error-kit, it adds to the symbol map (seen by (ns-refers
*ns*)) a map from the symbol to the actual var in error-kit. Thus, in
ns A where we have used error kit, evaluating #'handle  will actually
give us as a return value of #'clojure.contrib.error-kit/handle
because the symbol handle refers to the other ns's var.

The only problem is the import one - 'use' only imports vars which
actually belong to the ns you are using. We want it to not only import
public vars, but also to 'refer' certain vars which we also want to
export. So, the simple solution would be to tag the symbol in our ns
with special metadata, maybe an 'export' key, and then write another
function which does what 'use' does but also refers vars which have
the 'export' metadata.

Personally, i think the use function in the core should be rewritten
to consider two things when importing vars:
(1) if the symbol belongs to the ns you are using, then refer it
(2) if the symbol has  :export in the symbols metadata, then also
refer it.

-- 
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: Leiningen and apache commons

2011-01-19 Thread Luc Prefontaine
You need to import the classes from that library and then wrap them up
with some Clojure code.

Here a snippet:

(ns myname.space
  (:import (org.apache.commons.logging LogFactory Log)) ;; Import from 
commons-logging the LogFactory and Log classes

)
...

;;
;;  Get a logger for the current namespace
;;
(defn get-logger [] (LogFactory/getLog (str
*ns*)))

I do not used common-net yet so I do not know the API and how it
should be used. You will have to look at the JavaDoc and figure this
out.

If you want you can spare the imports but then you will need to refer
to the classes with their full name:

(defn get-logger [] (org.apache.commons.logging.LogFactory/getLog (str
*ns*)))

Luc P.

On Wed, 19 Jan 2011 16:49:11 -0800 (PST)
Andreas Kostler  wrote:

> Hi All,
> Can someone please tell me how to import the Apache commons net
> library? I'm using leiningen. The project.clj looks like this:
> (defproject clojure-scheme "1.0.0-SNAPSHOT"
>   :description "FIXME: write"
>   :dependencies [[org.clojure/clojure "1.2.0"]
>  [org.clojure/clojure-contrib "1.2.0"]
>  [commons-net/commons-net "2.2"]]
>   :dev-dependencies [[swank-clojure "1.2.2"]]
>   :main clojure-scheme.core)
> 
> Which puts commons-net-2.2.jar in the lib directory of my project.
> How can I import and use functionality in clojure? I want to do
> something like
> (def telnet (new TelnetClient)) ... but all attempts failed so far.
> 
> Kind Regards
> Andreas
> 



-- 
Luc P.


The rabid Muppet

-- 
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: Leiningen and apache commons

2011-01-19 Thread Andreas Kostler
Hi, thanks for your reply. 
I was missing a .telnet in my import :( 
Noobness struck again!
Andreas

On 20/01/2011, at 11:06 AM, Luc Prefontaine wrote:

> You need to import the classes from that library and then wrap them up
> with some Clojure code.
> 
> Here a snippet:
> 
> (ns myname.space
>  (:import (org.apache.commons.logging LogFactory Log)) ;; Import from 
> commons-logging the LogFactory and Log classes
> 
> )
> ...
> 
> ;;
> ;;Get a logger for the current namespace
> ;;
> (defn get-logger [] (LogFactory/getLog (str
> *ns*)))
> 
> I do not used common-net yet so I do not know the API and how it
> should be used. You will have to look at the JavaDoc and figure this
> out.
> 
> If you want you can spare the imports but then you will need to refer
> to the classes with their full name:
> 
> (defn get-logger [] (org.apache.commons.logging.LogFactory/getLog (str
> *ns*)))
> 
> Luc P.
> 
> On Wed, 19 Jan 2011 16:49:11 -0800 (PST)
> Andreas Kostler  wrote:
> 
>> Hi All,
>> Can someone please tell me how to import the Apache commons net
>> library? I'm using leiningen. The project.clj looks like this:
>> (defproject clojure-scheme "1.0.0-SNAPSHOT"
>>  :description "FIXME: write"
>>  :dependencies [[org.clojure/clojure "1.2.0"]
>> [org.clojure/clojure-contrib "1.2.0"]
>> [commons-net/commons-net "2.2"]]
>>  :dev-dependencies [[swank-clojure "1.2.2"]]
>>  :main clojure-scheme.core)
>> 
>> Which puts commons-net-2.2.jar in the lib directory of my project.
>> How can I import and use functionality in clojure? I want to do
>> something like
>> (def telnet (new TelnetClient)) ... but all attempts failed so far.
>> 
>> Kind Regards
>> Andreas
>> 
> 
> 
> 
> -- 
> Luc P.
> 
> 
> The rabid Muppet
> 
> -- 
> 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

--
 “There is a strong correlation between being smart and being a nerd, and an 
even stronger inverse correlation between being a nerd and being popular”
(Paul Graham)
-- 
**
Andreas Koestler, Software Engineer
Leica Geosystems Pty Ltd
270 Gladstone Road, Dutton Park QLD 4102
Main: +61 7 3891 9772 Direct: +61 7 3117 8808
Fax: +61 7 3891 9336
Email: andreas.koest...@leica-geosystems.com

www.leica-geosystems.com*

when it has to be right, Leica Geosystems

Please  consider the environment before printing this email.





-- 
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: Problem with garbage collection? Was Euler 14

2011-01-19 Thread Paul Mooser
That completes without giving me any error.

I'm using clojure 1.2.0 on OS X 10.6.6, and the JVM is 1.6.0_22.

On Jan 19, 1:42 am, Andreas Liljeqvist  wrote:
> Reposting this from earlier mail about Euler 14.
>
> (defn cseq [n]
>   (if (= 1 n)
>     [1]
>     (cons n (cseq (if (even? n)
>             (/ n 2)
>             (+ (* 3 n) 1 ))
>
> (apply max-key count (map cseq (range 1 100)))
>
> Gives a heap error.
> cseq is at most 525 elements long.

-- 
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: Euler 14

2011-01-19 Thread ka
To me this looks totally fine, max-key should keep at most two
sequences in memory. I don't think there should be any difference
between the non-lazy and lazy versions as the depth of cseq is ~500.

The non-lazy version works for me (no heap error) for inputs 1M, 2M,
4M, but for 4M the java process did start to consume very large amount
of memory.

I did some tests with the original non-lazy cseq and (apply max-key
count (map cseq (take 400 (iterate inc 1 [Free of chunking I
think]

Running in VisualVM suggests that % of Used Heap is actually very
less. So the problem is that GC isn't running often enough, so the JVM
has to keep allocating more memory.

Running with -Xmx200M -XX:+UseParallelGC, did keep heap upto 200MB and
produces results for 4M, 10M (ans=686) w/o any problems. It will
consume much CPU and time though.



-- 
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: Euler 14

2011-01-19 Thread Mark Engelberg
On Wed, Jan 19, 2011 at 6:48 PM, ka  wrote:
> Running in VisualVM suggests that % of Used Heap is actually very
> less. So the problem is that GC isn't running often enough, so the JVM
> has to keep allocating more memory.

Odd.  I'd expect the JVM to run a GC immediately before reporting that
the heap has been exhausted.

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


Vararg in protocol methods

2011-01-19 Thread dennis
I have defined a protocol with  overload methods,and one has varargs:

(ns test)
(defprotocol Say
  (say [this a] [this a & b] "say hello"))
(defrecord Robot []
  Say
  (say [this a] (println (str "hello," a)))
  (say [this a & b] (println b)))

Then ,i new a robot and say something:
(let [ r (Robot.)]
  (say r "dennis"))

It worked and print "hello,dennis",but if i passed more than one
arguments,it failed:

(let [ r (Robot.)]
  (say r "dennis" "zhuang"))

and threw exception

java.lang.IllegalArgumentException: No single method: say of
interface: test.Say found for function: say of protocol: Say (test.clj:
9)

It seems that clojure find methods in protocol both by name and
arity,and in this situation it found more than one methods named
"say".

I don't know how to solve this problem,any suggestion? thanks a lot.

-- 
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: Regarding The Implementation of 'merge-with'

2011-01-19 Thread Stefan Rohlfing
Hi all,

I tried another implementation of 'merge-with' using nested calls to
'reduce'. However,
I just cannot get it to work correctly:

(defn my-merge-with [f & maps]
  (when (some identity
maps)
(reduce
 (fn [acc m]
   (reduce
(fn [_ [key val]]
  (assoc acc key (if-let [old-val (get acc key)]
 (f old-val val)
  val)))
{} m))
 {} maps)))

(my-merge-with +  {:a 1  :b 2} {:a 9  :b 98 :c 0})
;; --> {:c 0, :b 2}

The problem most probably has to to with 'assoc' but I don't now how
to test this code.

I hope someone can me point to my error.

Best regards,

Stefan





On Nov 26 2010, 8:42 pm, Stefan Rohlfing 
wrote:
> Dear Clojure Group,
>
> Today I took a closer look at the 'merge-with' function of Clojure
> Core and changed some parts to better understand its implementation.
>
> Now I still have two questions regarding the following code:
>
> (defn my-merge-with [f & maps]
>   (when (some identity
> maps)                                                ;; question 1
>     (reduce (fn [acc m]
>                      (let [key (key (first  m)) val (val (first
> m))]          ;; question 2
>                        (assoc acc key (if-let [old-val (get acc key)]
>                                                      (f old-val val)
>                                                       val
>      {} maps)))
>
>  (my-merge-with + {"t" 1} {"a" 1} {"c" 1} {"g" 1} {"g" 1} {"g" 1} {"a"
> 1} {"c" 1} )
> ;; {"g" 3, "c" 2, "a" 2, "t" 1}
>
> Question 1:
> (when (some identity maps)
>
> This expression from the original implementation checks if the
> provided coll is empty.
> However, why not just use (when (empty? maps) or (when (seq maps)
> instead?
>
> Question 2:
> In order to return the key of a map consisting of one key/value pair I
> have to use the 'first' function, otherwise an exception will be
> thrown:
>
> (key {:a "a"})
> ;; clojure.lang.PersistentArrayMap cannot be cast to java.util.Map
> $Entry
> ;;  [Thrown class java.lang.ClassCastException]
>
> (key (first {:a "a"}))
> ;; :a
>
> I understand that 'key' expects a java.util.Map$Entry object, but how
> exactly does using 'first' accomplish this?
>
> (first {:a "a"})
> ;; [:a "a"]
>
> [:a "a"] is not a vector because the 'key' function does not work on a
> vector:
>
> (key [:a "a"])
> ;; clojure.lang.PersistentVector cannot be cast to java.util.Map$Entry
> ;;   [Thrown class java.lang.ClassCastException]
>
> Any suggestions are very welcome!
>
> Stefan

-- 
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: Metadata on symbols differ with caret reader

2011-01-19 Thread Tim Robinson
I upgraded lein from 1.3.1 to 1.4.2, which fixed the problem.
:)

On Jan 10, 6:47 am, Stefan Kamphausen  wrote:
> Hi,
>
> I can't verify that a REPL created by lein behaves differently.  Did you
> perhaps update an old project.el without running lein deps?
>
> In addition to that: your defproject has too many ]'s
>
> Regards,
> Stefan

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


just an observation about doseq...

2011-01-19 Thread Sunil S Nandihalli
Hello everybody,

when we give an empty vector of seq-exprs to doseq it returns the value of
the last s-expression.. but returns nil when the
vector-of-seq-exprs is not empty.. may be this is the expected behaviour ..
but the documentation states otherwise ..

Sunil.

-- 
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: Vararg in protocol methods

2011-01-19 Thread Alan
Protocols don't support varargs. You've defined a protocol with two
methods named say: one takes one argument named a, the other takes
three arguments named a, &, and b.

Protocols are for describing a very minimal set of functionality
needed to implement some richer feature set; the idea is that you
define a Say protocol that is capable of saying things in some basic
sense, and then build a library of functions that operate on Sayable
objects, providing the nice syntactical sugar in the library of real
functions, not in the protocol itself. If you want a say function that
behaves totally differently depending on how many arguments it's
passed (which seems kinda silly, but I'll assume that it's a contrived
example), you could do something more like this:

(defprotocol Say
  (say [this args]))

(defrecord Robot []
  Say
  (say [this args]
(let [[a & [b]] args]
  (println (or b (str "hello, " a))

(defn make-something-talk [obj & args]
  (say obj args))

On Jan 19, 8:02 pm, dennis  wrote:
> I have defined a protocol with  overload methods,and one has varargs:
>
> (ns test)
> (defprotocol Say
>   (say [this a] [this a & b] "say hello"))
> (defrecord Robot []
>   Say
>   (say [this a] (println (str "hello," a)))
>   (say [this a & b] (println b)))
>
> Then ,i new a robot and say something:
> (let [ r (Robot.)]
>   (say r "dennis"))
>
> It worked and print "hello,dennis",but if i passed more than one
> arguments,it failed:
>
> (let [ r (Robot.)]
>   (say r "dennis" "zhuang"))
>
> and threw exception
>
> java.lang.IllegalArgumentException: No single method: say of
> interface: test.Say found for function: say of protocol: Say (test.clj:
> 9)
>
> It seems that clojure find methods in protocol both by name and
> arity,and in this situation it found more than one methods named
> "say".
>
> I don't know how to solve this problem,any suggestion? thanks a lot.

-- 
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: Enclojure requires editor when installing plugin

2011-01-19 Thread Sergey Didenko
I use it with Netbeans 6.9.1 . Usually it takes some time for Enclojure to
be adapted to the latest Netbeans.

-- 
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: which IDEs are you all using?

2011-01-19 Thread Sergey Didenko
"lein": I just use "lein new MyProject" then "lein pom" and open the pom in
Netbeans. Thus I have both lein and Enclojure. The drawback is that you have
to run "lein pom" every time you change the project dependencies (in the
lein project.clj).

"Loosing settings": I observed that too in rare circumstances in the old
versions, but it was enough for me to just check if the settings are changed
after I closed the options window.

On Wed, Jan 12, 2011 at 5:40 AM, Mark Engelberg wrote:

> Netbeans/Enclojure:  Lots of nice stuff here.  The REPL works very
> well, and is easy to restart.  I found Netbeans' source control
> integration to be easy to use.  You can build a standalone app which
> places the dependencies in a folder, but I don't know of a way to
> build an uberjar using Netbeans/Enclojure.   If you know what jars you
> want, it's easy enough to add them to the project and get a custom
> REPL that sees those jars.  Unfortunately, many Clojure libraries
> assume you are using lein to automatically download chains of
> dependencies; it can be hard to find all the relevant jars and add
> them manually to the project.   For me, the #1 showstopper is that
> Enclojure becomes unreliable after about an hour of use, and any
> customized settings are repeatedly lost.
>

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