Re: Enhanced Primitive Support

2010-06-20 Thread Mark Engelberg
The arguments seem to be winding down, so I thought this would be a good time to summarize my thoughts. My favorite option of those proposed is: +, *, -, inc, dec auto-promote. loop/recur is changed so that primitive bindings are boxed. +',*',-',inc',dec' give error upon overflow. A new construct,

Re: Enhanced Primitive Support

2010-06-21 Thread Mark Engelberg
On Mon, Jun 21, 2010 at 12:32 AM, Nicolas Oury wrote: > That's not true. primitive loop is one of the key of the java-like > performance of clojure, once there are a few annotations. Right, the key words here are "once there are a few annotations". Those who aren't making those annotations will s

Re: Enhanced Primitive Support

2010-06-21 Thread Mark Engelberg
The new uber-loop is fantastic. So I guess the main point still to be finalized is whether the default arithmetic ops will auto-promote or error when long addition overflows. Playing around with the latest equals branch: user=> (def n 9223372036854775810) #'user/n user=> (* (/ n 3) 3) 922337203

Re: Enhanced Primitive Support

2010-06-22 Thread Mark Engelberg
On Tue, Jun 22, 2010 at 7:46 AM, Rich Hickey wrote: > It is precisely for these reasons that the first iteration was based upon > BigInteger contagion. Yeah, I still don't like BigInteger contagion, and I believe I would vastly prefer the current equals branch, even with its idiosyncrasies, versu

Re: New Primitive data types (equal branch) - impact on optimized code.

2010-06-24 Thread Mark Engelberg
When exactly did people start expecting Clojure to be as fast as Java and/or Scala? I seem to recall in one of the original Clojure videos, Rich talked about the relationship between Clojure and Java. There's a long history of C programmers dropping down to assembly, Python programmers dropping d

Re: State of Clojure web development

2010-06-25 Thread Mark Engelberg
> On 2010-06-24, at 12:27, Daniel Gagnon wrote: > > I don't use Clojure for web development and I thought sharing why could be > useful too. > > For web development, my favourite tool is Django. It comes as a fullstack > framework which means I have everything I need out of the box. Templates, > c

Re: Enhanced primitive support - redux

2010-06-25 Thread Mark Engelberg
floats and doubles are "inexact" numbers and ratios, ints, longs, bigints, and bigdecimals are "exact" numbers. The expected behavior is that inexact things contaminate exact things, because now the result is inexact. This is what Clojure does. On Fri, Jun 25, 2010 at 1:18 PM, Garth Sheldon-Couls

Re: Enhanced primitive support - redux

2010-06-25 Thread Mark Engelberg
A couple points of clarification: On Fri, Jun 25, 2010 at 1:35 PM, Mark Engelberg wrote: > You don't want the hashCode of bigdecimal to match the corresponding > double.  They aren't equal, so they shouldn't have the same hashcode. > They aren't equal because one is

Re: Enhanced primitive support - redux

2010-06-25 Thread Mark Engelberg
On Fri, Jun 25, 2010 at 2:39 PM, Garth Sheldon-Coulson wrote: > Personally, I think (= 3 3M) => true and (= 3/10 0.3M) => true would be nice > to have, given that (= 3 3N) => true. Both are currently false in equiv. I > also think (= 3.0M 3.00M) => true would be nice. As Rich said, there's no > pa

Protocols

2010-06-26 Thread Mark Engelberg
Is there a list somewhere of all the protocols built-in to Clojure 1.2's core that are available for extension? -- 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 memb

Life on the bleeding edge

2010-06-27 Thread Mark Engelberg
I spent some time today trying unsuccessfully to get the equiv branch up and running on Windows. I'd appreciate some guidance. I downloaded git, installed git. Used git to "clone" the github repository. Used git to "checkout origin/equiv". Downloaded ant. Installed ant. Ran ant. Seemed to work. U

Re: Life on the bleeding edge

2010-06-27 Thread Mark Engelberg
On Sun, Jun 27, 2010 at 5:33 PM, Michał Marczyk wrote: > mvn package -Dclojure.jar=/absolute/path/to/clojure.jar Thanks. I had tried that, but I got further as soon as I tried: mvn package -Dclojure.jar=c:/absolute/path/to/clojure.jar I'm now getting 3 failures in clojure.contrib.test_io and 1

Re: Life on the bleeding edge

2010-06-27 Thread Mark Engelberg
OK, I just tried building clojure-contrib pointing at a clojure.jar built from the current master branch. I get the same errors (on Windows). Here are more details: Testing clojure.contrib.test-io FAIL in (test-as-url) (run-test9074812622524104689.clj:45) expected: (= (URL. "file:/foo") (as-url

Re: Life on the bleeding edge

2010-06-27 Thread Mark Engelberg
I ran mvn clean first. -- 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 gro

Re: Life on the bleeding edge

2010-06-28 Thread Mark Engelberg
Yes, that is disconcerting that clojure-contrib produces errors on Windows (sigh, it often feels like Windows is a second-class citizen when it comes to clojure), but that did the trick and allowed the build to complete. Thanks for the tip. So now, finally, I've had the chance to run my regular c

Re: Protocols

2010-06-29 Thread Mark Engelberg
On Sun, Jun 27, 2010 at 7:18 AM, Rich Hickey wrote: > There are no extension points built on protocols in Clojure yet. Delivering > protocols is step one, re-architecting the core abstractions in terms of > protocols is still to come. > > Rich So how hard it would it be right now, for example, to

Re: Life on the bleeding edge

2010-06-29 Thread Mark Engelberg
On Tue, Jun 29, 2010 at 12:30 AM, Paul Moore wrote: > Is there anything a clojure newbie with little JVM development > experience (but a willingness to learn) can do to help with the > Windows situation? From what I understand, Java itself is fine on > Windows, so I assume this is a clojure-specif

Re: Protocols

2010-06-29 Thread Mark Engelberg
Thanks. Your advice to look at the ancestors and emit-defrecord was exactly what I needed to get started. It was still a hassle going through all those files and trying to figure out what interfaces I needed to implement, but most of my problems had to do with lack of documentation (e.g., figurin

Re: Compile multiple files in Emacs (interactive development)

2010-06-30 Thread Mark Engelberg
Try making a file that uses or requires all your other files. Then just ctrl-c ctrl-k in that file. -- 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 mod

Re: Bug in 1-arg max/min implementation? (Was: Should max and min have 0-arg implementations?)

2010-07-09 Thread Mark Engelberg
> Given that max only works on numbers, then why doesn't (max []) throw > the same exception as (max [] [])? Or, for that matter, (max \a) throw > the same exception as (max \a \b \c)? Clojure tends not to guarantee any particular behavior for invalid inputs. It might return an error, or it might

Congomongo question - how to update all records?

2010-07-10 Thread Mark Engelberg
Let's say I have a table called :table, and a column called :col, and I want to go through all the records in the table and set the :col value to 0. I had been doing it like this: (defn update-db! [] (doseq [entry (fetch :table)] (update! :table entry (assoc entry :col 0 but the other d

Re: faster flatten?

2010-07-12 Thread Mark Engelberg
Unless you wrap a "doall" around the calls to flatten and my-flatten, you're not really timing anything relevant. -- 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 me

Re: Typed Racket

2010-07-14 Thread Mark Engelberg
The nice thing about Racket is the way you can write different parts of your program in different Racket languages. So you can write some pieces in Typed Racket, and others in Lazy Racket, and others in standard Racket. It is my understanding that Typed Racket programs do not run any faster than

Re: A functional, efficient, convolution function. Is imperitive-style the answer?

2010-07-18 Thread Mark Engelberg
I have found Clojure to be consistently faster than Python, so I thought it would be instructive to compare the Python code to the closest Clojure equivalent. Here's the originally posted Python code: from itertools import repeat def convolve(ns, ms): y = [i for i in repeat(0, len(ns)+len(ms)

Re: Haskell?

2010-07-19 Thread Mark Engelberg
On Mon, Jul 19, 2010 at 4:34 PM, Jared wrote: > I am curious; for the people with Haskell experience why did you > decide to use Clojure? I am asking this because Haskell and Clojure > seem to solve similar types of problems. When would you want to use > Haskell instead of Clojure and visa-versa?

Re: Literate Clojure - a good lead ...

2010-07-20 Thread Mark Engelberg
I would definitely welcome a literate Clojure tool. -- 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.

Re: Congomongo question - how to update all records?

2010-07-21 Thread Mark Engelberg
So does no one here use congomongo? On Sat, Jul 10, 2010 at 1:17 PM, Mark Engelberg wrote: > Let's say I have a table called :table, and a column called :col, and > I want to go through all the records in the table and set the :col > value to 0.  I had been doing it like this: >

Re: Literate Clojure - a good lead ...

2010-07-21 Thread Mark Engelberg
I'd be perfectly happy with a LaTeX-based solution, although I understand the appeal of something more "within Clojure". As a first approximation, literate programming needs to make it easy to enter English text with code snippets that run. Haskell does this by assuming that in a file ending in .

Re: Literate Clojure - a good lead ...

2010-07-21 Thread Mark Engelberg
On Wed, Jul 21, 2010 at 3:10 PM, Mark Fredrickson wrote: > I've been playing around with a Emacs mode (more properly looking at > existing multi-major-mode work). I'm open to ideas on how to make it > play better with a REPL. As always, any form can be sent via C-C C-C. > What more did you have in

Re: Remove-first function

2010-07-24 Thread Mark Engelberg
The simplest translation is to wrap a lazy-seq around the last line to avoid the stack overflows. On Sat, Jul 24, 2010 at 8:41 AM, nickikt wrote: > (defn scheme-remove-first [syb lst] >  (if (empty? lst) >    '() >    (if (= (first lst) syb) >      (rest lst) >      (cons (first lst) (scheme-remo

Re: Remove-first function

2010-07-24 Thread Mark Engelberg
On Sat, Jul 24, 2010 at 11:45 AM, Mark Engelberg wrote: > The simplest translation is to wrap a lazy-seq around the last line to > avoid the stack overflows. Just to clarify, there are at least three reasonable places to place the call to lazy-seq. You can put lazy-seq around the full b

Re: Remove-first function

2010-07-25 Thread Mark Engelberg
On Sat, Jul 24, 2010 at 9:07 AM, Gary Fredericks wrote: > (defn remove-first >   [syb lst] >   (let [[before after] >   (loop [b [] a lst] >     (if (empty? lst) >   [b a] >   (if (= syb (first a)) >     [b (rest a)] >     (recur (con

Re: Remove-first function

2010-07-26 Thread Mark Engelberg
I expanded on this theme in a blog post: http://programming-puzzler.blogspot.com/2010/07/translating-code-from-python-and-scheme.html -- 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 th

Re: Idea for personal Clojure project

2010-07-28 Thread Mark Engelberg
Wordnet is the main existing thing that comes to mind as related to your idea. -- 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 pat

Re: Today is "Get Your App on Clojure 1.2" Day

2010-07-30 Thread Mark Engelberg
On Fri, Jul 30, 2010 at 8:05 AM, Stuart Halloway wrote: > So what are you waiting for? :-) > > Mostly, I'm waiting for performance reports on 1.1 vs 1.2. Last time I ran some tests against the beta, 1.2 seemed a bit slower. Also, can you provide a pointer in this thread to the list of changes f

Re: Today is "Get Your App on Clojure 1.2" Day

2010-08-01 Thread Mark Engelberg
On Fri, Jul 30, 2010 at 8:52 AM, Stuart Halloway wrote: > > Also, while > microbenchmarks are often misleading, if you have some that seem to show 1.2 > issues I would be happy to run them and take a look. > > Stu > > Yeah, I'm not talking

Re: Clojure 1.2 RC1

2010-08-01 Thread Mark Engelberg
On Fri, Jul 30, 2010 at 8:00 AM, Stuart Halloway wrote: > Clojure 1.2 RC 1 is now available, along with a corresponding Clojure > Contrib, at: > > http://clojure.org/downloads > > Is there any particular reason the contrib release candidate zip have a compiled jar inside it? -- You received this

Re: Clojure 1.2 RC1

2010-08-01 Thread Mark Engelberg
Meant to say, "...zip doesn't have a compiled jar..." On Sun, Aug 1, 2010 at 1:36 AM, Mark Engelberg wrote: > On Fri, Jul 30, 2010 at 8:00 AM, Stuart Halloway < > stuart.hallo...@gmail.com> wrote: > >> Clojure 1.2 RC 1 is now available, along with a

Re: Clojure 1.2 RC1

2010-08-01 Thread Mark Engelberg
Aha, so it 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 gr

Re: Bug: contains? doesn't work on transient maps or sets

2010-08-01 Thread Mark Engelberg
I just tested this in Clojure 1.2, and the bug is still there: (contains? (transient #{1 2}) 1) -> false ;should return true On Mon, Mar 22, 2010 at 5:46 PM, Mark Engelberg wrote: > Disturbingly, it doesn't error, it just always returns false. > This is in version 1.1

Re: bugs in with-local-vars and lexically-nested-function access to outer function parameters

2010-08-02 Thread Mark Engelberg
Can you distill this down to the smallest possible example that demonstrates the error? -- 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 - plea

Re: bugs in with-local-vars and lexically-nested-function access to outer function parameters

2010-08-03 Thread Mark Engelberg
On Tue, Aug 3, 2010 at 1:06 PM, Dale wrote: > This statement is ironic, considering the definition of a functional > closure, after which Clojure is presumably named. > > You're missing the point. A defn inside another defn doesn't do what you think it does. defn always creates a global variabl

Re: bugs in with-local-vars and lexically-nested-function access to outer function parameters

2010-08-03 Thread Mark Engelberg
On Tue, Aug 3, 2010 at 1:00 PM, Dale wrote: > On Aug 2, 11:07 pm, Mark Engelberg wrote: > > Can you distill this down to the smallest possible example that > demonstrates > > the error? > > Nope. Just spent some time trying to duplicate the nested function bug > in

Re: bugs in with-local-vars and lexically-nested-function access to outer function parameters

2010-08-03 Thread Mark Engelberg
Similarly, don't use def inside of a defn. Use let. On Tue, Aug 3, 2010 at 9:10 PM, Mark Engelberg wrote: > On Tue, Aug 3, 2010 at 1:06 PM, Dale wrote: > >> This statement is ironic, considering the definition of a functional >> closure, after which Clojure is presumabl

Re: Why no tail call optimization

2010-08-03 Thread Mark Engelberg
> Some people even prefer 'recur' to the redundant restatement of the >> function name. In addition, recur can enforce tail-call position. >> >> Rich >> >> Because recur only takes you back to the innermost loop, sometimes I miss the ability to jump back to some outer loop (or the overall function

Re: starting and getting the most out of concurrent processes

2010-08-04 Thread Mark Engelberg
I agree that the burn-with-futures code looks not right: (defn burn-via-futures [n] (print n " burns via futures: ") (time (doall (pmap deref (map (fn [_] (future (burn))) (range n)) should probably be something like: (defn burn-via-futures [

Re: Please help! Really simple function not working.

2010-08-09 Thread Mark Engelberg
On Mon, Aug 9, 2010 at 6:00 PM, Phil Hagelberg wrote: > Just remove the call to recur and it will work, albeit only for lists > small enough to not blow the stack. I'm assuming from the tone of the original post that the author is trying to generally understand how to write recursive functions in

Re: Please help! Really simple function not working.

2010-08-10 Thread Mark Engelberg
On Tue, Aug 10, 2010 at 1:15 AM, Nicolas Oury wrote: >  So, in this particular case, Scheme does not warranty no exhaustion > of resources. Yes, but your recursion depth is limited to the length of the list you are processing. So if you have enough resources to comfortably hold and manipulate th

Re: Please help! Really simple function not working.

2010-08-10 Thread Mark Engelberg
On Tue, Aug 10, 2010 at 2:21 AM, Nicolas Oury wrote: > It would probably be up to twice as slow, I would say. > For a list that is continuous in memory and continuations that are > allocated perfectly in memory, > you would need to go through twice the same amount of memory. > (I assume that the m

Re: How to construct Set

2010-08-10 Thread Mark Engelberg
BTW, when you're done, it would be great if you could post a report about your experience using JGraphT from Clojure. I've been thinking a lot lately about what an ideal graph library would look like in pure Clojure, and it would be interesting to hear how easy/hard it already is to use an existin

Re: Game development in Clojure

2010-08-14 Thread Mark Engelberg
On Fri, Aug 13, 2010 at 9:39 PM, Eric Lavigne wrote: > This is not a rare problem for me. Like Mike Anderson, I work around > it by putting extra thought into which package-level dependencies I > will allow, which sometimes necessitates creating more or fewer > packages than I otherwise would have

Re: Game development in Clojure

2010-08-15 Thread Mark Engelberg
On Sun, Aug 15, 2010 at 7:45 AM, Brian Hurt wrote: > Circular dependencies are then the canary in the coal mine, warning you that > your code is trending (hard) towards unmaintainability, You ignore the > warning at your peril. Avoiding circular dependencies can result in either: a) Everything en

Re: Program design

2010-08-18 Thread Mark Engelberg
I think the easiest way to port OO code would be to use Clojure's multimethods, dispatching on the type of the first argument. -- 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 post

Re: Program design

2010-08-19 Thread Mark Engelberg
On Wed, Aug 18, 2010 at 5:20 PM, Patrick Moriarty wrote: > You should look at Clojure 1.2 protocols and records which provides an easy > way to do polymorphism on types. > See http://clojure.org/protocols. Protocols don't offer inheritance. The original poster specifically mentioned porting code

Re: JavaFX and Clojure

2010-08-23 Thread Mark Engelberg
> Rather than > creating the JavaFX language they would have done so much more for the > community to just focus on this scenegraph library, animation, etc... I agree. I'm not interested in the JavaFX language, but am interested in doing Flash-like user interfaces and animations from Clojure. --

Re: JavaFX and Clojure

2010-08-28 Thread Mark Engelberg
On Fri, Aug 27, 2010 at 11:00 AM, Emeka wrote: > Mark, > Can JavaFX do that? > Regards, > Emeka I don't know that much about JavaFX, but my understanding is that it was born out of Sun's desire to compete with Adobe's Flash/Flex/AIR. Similarly, Silverlight is Microsoft's effort to compete in that

Re: Lisp/Scheme Style Guide

2010-08-31 Thread Mark Engelberg
Speaking of style conventions, am I the only one who finds it mildly irksome that in any Clojure code, half the identifiers are lisp-style-multiword-names while the other half are javaCamlCaseMethodNames. It feels so inconsistent. I'd be happier if Clojure just moved completely to caml case (take

Re: Lisp/Scheme Style Guide

2010-09-01 Thread Mark Engelberg
On Tue, Aug 31, 2010 at 3:38 PM, Cyrus Harmon wrote: > XMLHttpRequest vs. xml-http-request. I rest my case. I'm not even sure what case you're making, let alone what side you're "resting" for. :-/ -- You received this message because you are subscribed to the Google Groups "Clojure" group. To

Re: Lisp/Scheme Style Guide

2010-09-05 Thread Mark Engelberg
On Sun, Sep 5, 2010 at 1:08 PM, Daniel Gagnon wrote: > I'd be all for having clojure-fmt that would format clojure code in the way > Rich prefers it so that when I get random code I could convert it to a nice > and predictable format. It should be even simpler to write for a lisp than > other lang

Documentation tools

2010-09-05 Thread Mark Engelberg
I spent some time recently documenting a large clojure project. The approach I used was a combination of doc-strings, comments throughout my code, and a project-wide emacs-org-mode file summarizing the point of each file, the important functions in each file categorized by purpose, and an overview

Re: Documentation tools

2010-09-06 Thread Mark Engelberg
On Mon, Sep 6, 2010 at 2:51 AM, Tim Daly wrote: > The literate programming discussion centered around the question > "what should be the state of the art in clojure documentation", > not "what is the state of the art in clojure documentation". I brought up literate programming as an example of a

Re: Documentation tools

2010-09-07 Thread Mark Engelberg
Docstrings seem designed for fairly terse comments about the nature of the function. It's great for providing little hints about how the function works to jog one's memory by typing (doc ...) in the REPL, or for searching with find-doc. But I just don't think I can fit the kind of full documentat

Re: Documentation tools

2010-09-07 Thread Mark Engelberg
On Tue, Sep 7, 2010 at 10:23 PM, Sean Corfield wrote: > I'm watching this thread and I'm wondering what kind of documentation > people are talking about here. I've always been used to using > self-documenting function / variable names and short comments for > documenting everything. Clearly you gu

Re: Documentation tools

2010-09-08 Thread Mark Engelberg
On Wed, Sep 8, 2010 at 12:05 AM, Sean Corfield wrote: > Most people who read my code have said it reads like poetry... Poetry takes a complex message and packs it into as few words as possible, resulting in something so cryptic and enigmatic that people bicker endlessly about what subtle meanings

Re: Documentation tools

2010-09-08 Thread Mark Engelberg
On Wed, Sep 8, 2010 at 11:56 PM, Laurent PETIT wrote: >> Full ack here. > > For the non english speaker I am : is this a pun/playword ? (full ack > <-> f..ck all) ? I assume he meant "full acknowledgment" -- an expression of agreement. -- You received this message because you are subscribed to

Re: Some code dramatically slower in Clojure 1.3 Alpha 1?

2010-09-25 Thread Mark Engelberg
>> http://code.google.com/p/clojure/issues/detail?id=95 I just looked over this code. You can speed it up even more by manually encoding the loop, rather than using reduce. (defn faster-max-key ([k x] x) ([k x & more] (loop [x x, kx (k x) s more] (if-not s

Re: Some code dramatically slower in Clojure 1.3 Alpha 1?

2010-09-25 Thread Mark Engelberg
On Sat, Sep 25, 2010 at 7:02 PM, Btsai wrote: > I went through the rest of my Project Euler code.  In addition to > even?, there are some functions in clojure.contrib that are also much > slower in 1.3 Alpha 1. > > clojure.contrib.math -> expt > >  (Clojure 1.2) >  user=> (time (doseq [x (range 10

Re: Some code dramatically slower in Clojure 1.3 Alpha 1?

2010-09-27 Thread Mark Engelberg
Thanks for the info. I'd need to research how clojure.lang.BigInt differs from java.math.BigInteger, but I'm sure that adding the extra case for BigInt in the multimethods wouldn't be too hard. I'm still stumped as to why expt and sqrt would be 100x slower. My first thought is that the loop/recu

Re: Idiomatic Way to Build String or Simply Use StringBuilder

2010-09-29 Thread Mark Engelberg
Start with an empty vector, say v. conj your strings to the vector at the various points in your code, so at the end v will be something like ["this" "is" "a" "string"] Then, when you're done, apply str to the vector, i.e., (apply str v) to get "thisisastring" str uses a string builder behind the

Re: Some code dramatically slower in Clojure 1.3 Alpha 1?

2010-09-29 Thread Mark Engelberg
I believe the performance problems boil down to the abysmal performance of bit-shift-right and bit-and in Clojure 1.3 alpha 1. I'll post this in a separate thread to make sure it gets read. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to th

Clojure 1.3 alpha 1 report - bitwise operations extremely slow

2010-09-29 Thread Mark Engelberg
bitwise-and and bitwise-shift-right and bitwise-shift-left run more than 50 times slower in clojure 1.3 alpha 1 versus clojure 1.2. Could the 1.3 gurus please investigate this? Try something like this to see the difference: (time (doseq [x (range 10)] (bit-shift-left x 1))) This points to an

Re: Changing keys in a map

2010-09-30 Thread Mark Engelberg
On Thu, Sep 30, 2010 at 12:24 AM, Baishampayan Ghose wrote: > clojure.contrib.string/upper-case is a trivial wrapper over > .toUpperCase. In my humble opinion it's perfectly OK to use such > static Java methods directly instead of writing trivial wrappers > around them. Except that if you use .to

Re: Clojure 1.3 alpha 1 report - bitwise operations extremely slow

2010-09-30 Thread Mark Engelberg
Did some more testing, and I'm now convinced that the slow performance of the bitwise operators in clojure 1.3 alpha 1 is due to the inline declaration in the definition of the bitwise ops. If you remove the inline declaration, performance is as it should be. So something about the way inline wor

Re: Some code dramatically slower in Clojure 1.3 Alpha 1?

2010-09-30 Thread Mark Engelberg
As a side note, I notice that in clojure 1.3, bit-shift-left now provides wraparound logic with no warning if the first input is a long (as opposed to a bigint). Wouldn't it be more consistent if bit-shift-left provided an overflow error for long inputs that shift so much they overflow? Should th

Re: Any clean way to avoid explicit recursion when creating nested loops?

2010-09-30 Thread Mark Engelberg
clojure.contrib.cartesian-product does what your nested function does, but more efficiently, using iteration rather than recursion. -- 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

Re: Clojure 1.3 alpha 1 report - bitwise operations extremely slow

2010-09-30 Thread Mark Engelberg
On Thu, Sep 30, 2010 at 9:13 PM, ataggart wrote: > As with most microbenchmarks you're measuring the test more than the > subject.  In the above case the seq generation dominates. > > Compare the following on my machine: > user=> (time (doseq [x (range 10)] (bit-shift-left x 1))) > "Elapsed ti

Clojure Database experience reports wanted

2010-10-02 Thread Mark Engelberg
I've been using clojure with mongodb for a while now. I found that using a nosql database system was very freeing and pleasurable, compared to the python/sqlite combination I'd used before. However, I'm starting to bump up against some limitations: 1. On my 32-bit Windows machine, mongodb is qui

Re: Clojure Database experience reports wanted

2010-10-02 Thread Mark Engelberg
I should add that my needs are fairly simple as databases go. This is not for a webserver. I just need to locally store data which is too big to fit in memory, and store it in a durable fashion. Typically, my data is a uniquely identifying string combined with a number of numeric attributes. I

Re: OO design in clojure

2010-10-03 Thread Mark Engelberg
The real challenge is to reconceptualize your problem domain into a non-destructive framework. In other words, you need to transform your way of thinking from: move function (or method) takes a Shape and destructively updates the shape's x and y, returning void to move function takes a Shape and re

Re: Project Euler problem 14: Maybe it's me but hash maps don't seem to work

2010-10-07 Thread Mark Engelberg
On Thu, Oct 7, 2010 at 4:21 AM, Stuart Halloway wrote: > Which version of Clojure are you running? > > The most likely cause of this problem is having a mix of numeric types (e.g. > longs and ints) as keys/key lookups in a hash map. This is broken as required > (sigh) by Java collections. I thi

Re: Project Euler problem 14: Maybe it's me but hash maps don't seem to work

2010-10-07 Thread Mark Engelberg
On Thu, Oct 7, 2010 at 12:29 PM, Jarl Haggerty wrote: > I'm using clojure 1.2 OK, I stand corrected. Stuart's right. The problem is that you're getting mixed numeric types. When you do (collatz 113383) the sequence eventually hits 2482111348 which is a Long, not an Integer. When you divide by 2

resultset-seq

2010-10-10 Thread Mark Engelberg
Why does resultset-seq convert column names to all lower case? This behavior is screwing me up (my column names are intentionally mixed case) and I don't understand the reasoning. Thanks, Mark -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post

Problems with clojure couchdb

2010-10-11 Thread Mark Engelberg
I'm playing around with couchdb. I'm using the version that lein gets with the following command: [clojure-couchdb "0.4.4"] which as far as I can tell is the most recently maintained version. When I do a bunch of rapid calls to document-create in a tight loop, after about 3000 or so documents ha

Re: Polymorphic functions in Clojure (or how to stop thinking in objects)...

2011-03-15 Thread Mark Engelberg
On Tue, Mar 15, 2011 at 10:40 AM, Alan wrote: > Seconded. I often know ahead of time I'll want to extend to > multimethods eventually, but sometimes I don't. Because multimethods, > protocols, and plain-old-functions look the same to the caller, you > can write your code whatever way is most stra

Re: Software Engineering Practices for Marking Algorithms?

2011-03-15 Thread Mark Engelberg
Using the traditional visited flag approach, your program will fail if two threads try to print the same tree structure at the same time. I personally have found the hash table approach to be very effective. It uses space, but the space can be garbage collected as soon as you're finished with the

Re: Software Engineering Practices for Marking Algorithms?

2011-03-15 Thread Mark Engelberg
On Tue, Mar 15, 2011 at 11:12 PM, Shantanu Kumar wrote: > Use the node's metadata to annotate :visited as true and re-associate, > and do it recursively (likely with loop recur)? > > Regards, > Shantanu > > Altering metadata is generally a non-destructive operation (with-meta), and alter-meta! onl

Re: Software Engineering Practices for Marking Algorithms?

2011-03-16 Thread Mark Engelberg
One thing that many algorithm books overlook is the cost of setting the markers back to false/nil when done. One nice aspect of a hashset/vector approach is that you can just throw it away when done, and use a fresh one each time. If you want to learn a whole bunch of low-level tricks for handlin

Re: Software Engineering Practices for Marking Algorithms?

2011-03-16 Thread Mark Engelberg
On Wed, Mar 16, 2011 at 4:35 PM, CuppoJava wrote: > The problem arises after the program as been running for a long time > and the value of the counter is very high. There might be only two > Nodes in use, but one Node might have an id = 1 (because it was one of > the first ones created), and the

Re: Deep recursion, continuation passing style, trampolining and memoization

2011-03-22 Thread Mark Engelberg
I don't believe Tim's comments are correct. Since there are three recursive calls, I don't think there is a straightforward transformation to tail position using an accumulator. Also, due to the interleaved nature of the recursive calls, I would expect memoization to be essential. So, I think th

Re: A newbie's summary - what worked, what didn't

2011-03-26 Thread Mark Engelberg
On Sat, Mar 26, 2011 at 10:24 AM, ultranewb wrote: > Clojure Box - > Could get a REPL, couldn't figure out how to do anything else (i.e. > Leinegen blah blah).  Result - kept the install, as this was the 2nd > most promising solution tried thus far. If you don't care about building projects into

Re: A newbie's summary - what worked, what didn't

2011-03-26 Thread Mark Engelberg
On Sat, Mar 26, 2011 at 4:29 PM, ultranewb wrote: > On Mar 27, 12:35 am, Mark Engelberg wrote: >> Type some Clojure code into the file you created.  Save periodically >> with "Ctrl-x Ctrl-s".  When you want to try out your code, type >> "Ctrl-c ctrl-k"

Re: A newbie's summary - what worked, what didn't

2011-03-27 Thread Mark Engelberg
On Sun, Mar 27, 2011 at 11:15 PM, Mike Meyer wrote: > So, assuming you found a library you really needed that wasn't already > locally installed, how did you deal with that? If you could add a > "require library" to your source and your language would go find it, > download it and install it, I'd

Re: clojure.contrib.priority-map issue

2011-05-20 Thread Mark Engelberg
Fixed. Thanks for the bug report. -- 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 f

Re: clojure.contrib.math's Docstring Seems Broken

2011-05-22 Thread Mark Engelberg
The doc string was copied by an automated process (or maybe manually by Tom) from the comments at the top of the document. I just escaped the quotations in the latest version. On Sat, May 21, 2011 at 9:45 PM, OGINO Masanori wrote: > Hello. > > I found that the namespace docstring of clojure.cont

Re: Contagious BigDecimals?

2011-05-23 Thread Mark Engelberg
doubles are inherently inexact; they are approximations of a real number. If you add an inexact number and an exact number, the only thing that makes sense is to return something that is inexact. BigInt contagion is different, because you are adding two exact things, it's just a question of intern

Re: List comprehension and sets

2011-05-24 Thread Mark Engelberg
Scala's approach to comprehensions is to automatically produce the same type of collection that is used first in your comprehension. Clojure's approach is to always produce a lazy sequence which can then be "poured" into the collection of your choice using "into". Both approaches have their merits

Re: Radically simplified Emacs and SLIME setup

2011-05-29 Thread Mark Engelberg
I need more details about how to install the current version of clojure-mode. When I do alt-x package-install and type clojure-mode I get a bunch of messages that it is compiling clojure-mode 1.7.1. The website said to install clojure-mode via marmalade, but it's not at all clear to me what marma

Re: Radically simplified Emacs and SLIME setup

2011-05-29 Thread Mark Engelberg
On Sun, May 29, 2011 at 10:06 PM, László Török wrote: > Heh, yeah that marmelade was a funny one, I spent a few hours figuring what > goes where. > > I suggest you download emacs-starter-kit from Phil's github repo, that has > the necessary configuration for marmelade too. > > Then proceed wit

Re: Radically simplified Emacs and SLIME setup

2011-05-30 Thread Mark Engelberg
Has anyone tried this on Windows? I reinstalled emacs-starter-kit, then reinstalled clojure-mode. I downloaded the latest version of lein, and created a completely fresh new project. Then, I did lein plugin install swank-clojure 1.3.1. I opened up the core.clj from the newly created project in e

Re: Radically simplified Emacs and SLIME setup

2011-05-30 Thread Mark Engelberg
The package installer saw the 1.9.2 release, which I installed. I'm still getting the "cannot find the path specified" error though. Thanks for all the help you all have provided so far; let me know if you have any other ideas for me to try. Thanks, Mark -- You received this message because y

<    4   5   6   7   8   9   10   11   12   13   >