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

Re: Documentation tools

2010-09-06 Thread Mark Engelberg
On Mon, Sep 6, 2010 at 2:51 AM, Tim Daly d...@axiom-developer.org 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

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

Re: Documentation tools

2010-09-08 Thread Mark Engelberg
On Tue, Sep 7, 2010 at 10:23 PM, Sean Corfield seancorfi...@gmail.com 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

Re: Documentation tools

2010-09-08 Thread Mark Engelberg
On Wed, Sep 8, 2010 at 12:05 AM, Sean Corfield seancorfi...@gmail.com 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

Re: Documentation tools

2010-09-09 Thread Mark Engelberg
On Wed, Sep 8, 2010 at 11:56 PM, Laurent PETIT laurent.pe...@gmail.com 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

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 x

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 benny.t...@gmail.com 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

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

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

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

2010-09-30 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

Clojure 1.3 alpha 1 report - bitwise operations extremely slow

2010-09-30 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

Re: Changing keys in a map

2010-09-30 Thread Mark Engelberg
On Thu, Sep 30, 2010 at 12:24 AM, Baishampayan Ghose b.gh...@gmail.com 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

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

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

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 alex.tagg...@gmail.com 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

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

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: 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 stuart.hallo...@gmail.com 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

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

Re: Problems with clojure couchdb

2010-10-12 Thread Mark Engelberg
On Tue, Oct 12, 2010 at 6:41 AM, Moritz Ulrich ulrich.mor...@googlemail.com wrote: Regarding your error: Maybe you open too many sockets which don't get closed and your process runs out of file descriptors. Yes, I think that's the problem. I found a blurb on the net about how to expand the

Re: resultset-seq

2010-10-14 Thread Mark Engelberg
Since no one chimed in with support or reasoning for resultset-seq's current lower-casing behavior, can we discuss changing it to case-maintaining behavior, or at least make it something you can set with an optional flag? On Sun, Oct 10, 2010 at 8:41 PM, Mark Engelberg mark.engelb...@gmail.com

Re: CongoMongo - which version/fork is most uptodate

2010-10-14 Thread Mark Engelberg
I've been having trouble with congomongo for the reasons you specified, and a few more (doesn't sort, ran into a bug where limit was working properly with large datasets). I recently switched to the karras clojure wrapper for mongodb (http://github.com/wilkes/karras), and found it to be much more

Re: resultset-seq

2010-10-15 Thread Mark Engelberg
On Fri, Oct 15, 2010 at 1:49 AM, David Powell djpow...@djpowell.net wrote: I'm in favour of down-casing - at least by default.  Some processing is going to happen anyway, as column names might contain spaces, which wouldn't be allowed in keywords. -- Dave One of the more significant

Re: Question about lein swank and emacs

2010-10-25 Thread Mark Engelberg
When I do restart-inferior-lisp, it says, no inferior lisp process. On Mon, Oct 25, 2010 at 1:31 PM, Drew Raines aarai...@gmail.com wrote: Mark Engelberg wrote: When you start a swank server with lein swank, and then connect to it via slime-connect in emacs, is there any way from within emacs

Re: Question about lein swank and emacs

2010-10-26 Thread Mark Engelberg
I'm confused. Is there a better way to get a REPL going in Emacs other than lein swank from a command line combined with M-x slime-connect in Emacs? On Tue, Oct 26, 2010 at 10:28 AM, Drew Raines aarai...@gmail.com wrote: For some reason I missed the original slime-connect mention.  In that

Re: Question about lein swank and emacs

2010-10-26 Thread Mark Engelberg
So what steps do you need to go through so that M-x lein-swank works? (When I type that, nothing happens). On Tue, Oct 26, 2010 at 1:17 PM, Drew Raines aarai...@gmail.com wrote: It's subjective.  I like M-x lein-swank because it retains control of the swank process as an inferior-lisp, which

Re: Some questions about Clojure Protocols

2010-11-03 Thread Mark Engelberg
On Wed, Nov 3, 2010 at 5:37 AM, Stuart Sierra the.stuart.sie...@gmail.com wrote: Protocols provide just one thing: polymorphic functions. They are not intended to provide type or hierarchy like Java classes / interfaces. Well, they also provide a second thing -- a way to bundle multiple

Re: Resources on optimizing Clojure code

2010-11-03 Thread Mark Engelberg
Your Clojure implementation of your particular approach is reasonable, but you need a cleverer approach. I'll send you a hint offline. -- 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

Re: Resources on optimizing Clojure code

2010-11-03 Thread Mark Engelberg
All the time spent factoring is wasted. You can *construct* and/or count the semiprimes far more efficiently than your method of factoring each number one a time in order to filter the semiprimes from the entire range of numbers up to 10^8. Your approach is fundamentally slow; this has nothing

Re: The Genuine Sieve of Eratosthenes

2010-11-06 Thread Mark Engelberg
I like tinkering with prime sieve algorithms. Here's the fastest one I've come up with: (defn bit-sieve [n] (let [n (int n)] Returns a vector of all primes from 2 to n (not including n) (let [root (int (Math/round (Math/floor (Math/sqrt n] (loop [i (int 3) a

Re: Generating random regular graphs

2010-11-16 Thread Mark Engelberg
I think the simplest and most efficient way to simulate the random connection process in a functional manner is to start by generating a shuffled list of d copies of each vertices (this represents the d legs for each vertex), and then pair them up using partition. At this point you have a list of

Re: fastest way to remove nils

2010-11-16 Thread Mark Engelberg
(keep identity l) is preferable to (filter identity l) -- 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

Re: bimaps in clojure

2010-11-16 Thread Mark Engelberg
On Tue, Nov 16, 2010 at 7:18 PM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Thanks Christopher Grand. I really like your scaffold .. would be extremely handy .. Like david suggested .. it would be a perfect candidate for inclusion in the clojure.repl Regarding your bimap

Re: ANN: ClojureQL 1.0.0 finally released as public beta

2010-11-21 Thread Mark Engelberg
ClojureQL is all about queries, right? As far as I can tell, it provides no abstraction for creating tables, specifying indices, etc., correct? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: Clojure vs F# performance

2010-11-22 Thread Mark Engelberg
I doubt that F# Mono benchmarks are representative of F#'s performance on Windows. -- 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

Re: priority queue for scheduling events in the future

2010-11-23 Thread Mark Engelberg
In 1.3, you can use clojure.contrib.priority-map. Documentation found in comment at top of source: https://github.com/clojure/clojure-contrib/blob/master/modules/priority-map/src/main/clojure/clojure/contrib/priority_map.clj -- You received this message because you are subscribed to the Google

Re: priority queue for scheduling events in the future

2010-11-24 Thread Mark Engelberg
No reason other than my lack of knowledge that ns doc strings are picked up by autodoc and comments are not. :) On Wed, Nov 24, 2010 at 12:36 AM, Tom Faulhaber tomfaulha...@gmail.comwrote: Mark, Is there a reason that you put the documentation in a comment rather than as the ns doc string so

Re: priority queue for scheduling events in the future

2010-11-24 Thread Mark Engelberg
Thanks! On Wed, Nov 24, 2010 at 8:30 AM, Tom Faulhaber tomfaulha...@gmail.comwrote: OK, I'm doing stuff there now. I'll move the comment to the ns doc string, then. There are still issues with autodoc and protocols/types, but priority queues look like they'll be a good sandbox for

Re: [ANN] Instaparse 1.1.0

2013-06-11 Thread Mark Engelberg
Honestly I hadn't yet given it any thought. Thanks for the interest in having it on Clojurescript. Here are a few issues that come to mind: 1. To achieve performance, I've spent time coding custom data structures that implement various Clojure and Java interfaces. I haven't done much with

Re: [ANN] Instaparse 1.1.0

2013-06-11 Thread Mark Engelberg
Here's another link: http://java-performance.info/changes-to-string-java-1-7-0_06/ -- -- 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

Re: [ANN] Instaparse 1.1.0

2013-06-11 Thread Mark Engelberg
On Tue, Jun 11, 2013 at 3:33 PM, Andy Fingerhut andy.finger...@gmail.comwrote: I haven't done anything but think about it during commute time yet, but I had been wondering in how many situations it might be useful to have a string type that was something like Relaxed Radix Binary trees, in

Re: [ANN] Instaparse 1.1.0

2013-06-15 Thread Mark Engelberg
On Sat, Jun 15, 2013 at 7:21 PM, Zack Maril thewitzb...@gmail.com wrote: Why does instaparse not throw errors? Curious about the reasoning behind this design. -Zack I'm not sure what you mean. It does throw errors for certain kinds of invalid grammars and other fatal problems. Perhaps what

Re: A* Graphe implementation

2013-06-16 Thread Mark Engelberg
http://clj-me.cgrand.net/2010/09/04/a-in-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

Re: Offline Clojure docs

2013-06-30 Thread Mark Engelberg
Download here: https://github.com/clojure/clojure/tree/gh-pages -- -- 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

core.async - question about close!

2013-07-01 Thread Mark Engelberg
Is close! merely a convenience function to ensure that future puts to a channel will not be permitted, or is it essential to close! a channel so that it will be garbage collected? -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this

Re: core.async implemented on top of Pulsar

2013-07-01 Thread Mark Engelberg
I'd love to try this out, but when I follow the getting started directions and add [co.paralleluniverse/pulsar 0.1.1] to my dependencies, I seem to get a completely different API and namespace layout than what is given in the documentation. Is there a snapshot release that contains the latest

Re: clojure.set/union bug?

2013-07-01 Thread Mark Engelberg
Expanding on what Jim said, you don't usually need to convert the keys of a map into a set, because the map pretty much acts like a set of its keys if you use contains? For example, (contains? {:a 1, :b 2} :a) tests whether :a is among the set of keys in the map. I believe that clojure.set's

[ANN] Instaparse 1.2.0

2013-07-07 Thread Mark Engelberg
Instaparse https://github.com/Engelberg/instaparse/ is an easy-to-use, feature-rich parser library. The big idea behind instaparse is to make it simple to convert grammars to parsers without needing to know the idiosyncrasies of LL1, LALR, and other esoteric grammar restrictions imposed by most

Re: [ANN] Instaparse 1.2.0

2013-07-08 Thread Mark Engelberg
FYI, there was a dependency problem with 1.2.0, and I've pushed a version 1.2.1 fixing the issue out to clojars. If any further bugs are reported, I will provide further bugfixes under the 1.2 numbering series (1.2.2, etc.), so I encourage you to check back at the github site

Re: Clojure: Elegance vs. Performance?

2013-07-09 Thread Mark Engelberg
On Tue, Jul 9, 2013 at 9:14 AM, Ray Miller r...@1729.org.uk wrote: Pure. Simple. Beautiful. (Not that I'm the best Scheme programmer ever, but to me it looks beautiful, and it conforms well to the base of the problem. You get the point.) This is not implementing expt as it is usually

Re: Clojure: Elegance vs. Performance?

2013-07-09 Thread Mark Engelberg
On Tue, Jul 9, 2013 at 8:11 AM, Alexander Gunnarson alexandergunnar...@gmail.com wrote: My idea, which is probably very naive, but one which I'm curious about, is: *Is it possible to have some sort of set of automatic-optimizing macros that work on Clojure code to preserve elegance while

Re: Clojure: Elegance vs. Performance?

2013-07-09 Thread Mark Engelberg
On Tue, Jul 9, 2013 at 9:29 AM, Alexander Gunnarson alexandergunnar...@gmail.com wrote: This is not implementing expt as it is usually known, it looks more like repeated squaring to me. Agreed. There's a certain irony that the OP declares the code pure, simple, and beautiful, when it

Re: Is this idiomatic for a recurring function?

2013-07-09 Thread Mark Engelberg
On Tue, Jul 9, 2013 at 1:22 PM, Denis Papathanasiou denis.papathanas...@gmail.com wrote: (defn get-length-match [my-list target-length counted-length ind] (let [current-len (count (first my-list))] (if (= counted-length target-length) ind (recur (rest my-list)

Re: lein injections across namespace changes

2013-07-09 Thread Mark Engelberg
I agree, this has also bothered me for a while. It would be really nice if the injections would repeat whenever you change namespace. On Tue, Jul 9, 2013 at 10:41 PM, Russell Mull russell.m...@gmail.comwrote: I have a profiles.clj that looks like this: {:user {:dependencies

Re: Clojure: Elegance vs. Performance?

2013-07-10 Thread Mark Engelberg
On Tue, Jul 9, 2013 at 11:39 PM, Mats Rauhala mats.rauh...@gmail.comwrote: Clojure people say that jvm doesn't support tco, which it doesn't. So they implemented a recur macro that turns the function into an explicitly tcoable function. But, take a look at scala. It can do (naive) tco

Re: Things get slow if hashmap has 1000 Elements

2013-07-17 Thread Mark Engelberg
This might help: http://clojuredocs.org/clojure_core/clojure.core/*print-length* -- -- 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

Re: Status of Generic Functions (a la lisp)

2013-08-03 Thread Mark Engelberg
What's wrong with the built-in multimethods? -- -- 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

Re: Status of Generic Functions (a la lisp)

2013-08-04 Thread Mark Engelberg
The word fast is relative, of course. I've been happily using Clojure's multimethods for a long time. They are certainly fast enough for a wide range of uses. I've seen a couple instances where people used a couple levels of protocols (e.g., one function dispatching on the type of the first

Re: [Proposal] Simplified 'ns' declaration

2013-08-05 Thread Mark Engelberg
On Mon, Aug 5, 2013 at 9:32 AM, Lee Spector lspec...@hampshire.edu wrote: Can you build in a way to get :require :refer :all to work on a bunch of sub-namespaces together on one line, as one currently can with :use, without listing each namespace completely on a separate line with a separate

Re: [Proposal] Simplified 'ns' declaration

2013-08-05 Thread Mark Engelberg
On Mon, Aug 5, 2013 at 11:14 AM, Timothy Baldridge tbaldri...@gmail.comwrote: On that subject when last discussed, it was mentioned that Clojure doesn't have a import * method because it's basically impossible to implement. Well, surely the word impossible is inaccurate, since other languages

Re: [Proposal] Simplified 'ns' declaration

2013-08-05 Thread Mark Engelberg
On Mon, Aug 5, 2013 at 11:31 AM, Jonathan Fischer Friberg odysso...@gmail.com wrote: I think it's java that is at fault here. I think wildcards should never have been part of java to begin with. The argument here is basically exactly the same as why :use shouldn't be used, so I wont explain it

Re: IDE feature

2013-08-07 Thread Mark Engelberg
I don't think there's any IDE that does this out of the box, although I'm certain that if you're an elisp hacker, you could easily add this to emacs' clojure mode. I, too, miss that feature from DrRacket. -- -- You received this message because you are subscribed to the Google Groups Clojure

Story

2013-08-07 Thread Mark Engelberg
Recently, I discovered the story literate programming tool for Clojure, which I prefer to marginalia: https://github.com/jedahu/story I had tried marginalia, but ran into the following problems: 1. Didn't really handle all markdown notations properly, so I had a lot of trouble getting the

Re: IDE feature

2013-08-08 Thread Mark Engelberg
I've tried paredit several times and dislike it. I found that while editing the code, I spent a lot of mental energy trying to figure out how to edit the code within the constraints of the structure-preserving transformation key combos, which took away from my ability to concentrate on the

Re: Story

2013-08-08 Thread Mark Engelberg
I started the post primarily to see if anyone else was using story, and if anyone knew the status of that application, and this has turned more into a discussion about literate programming. That's okay though. I'm very interested in literate programming, and am always looking for a viable

Re: IDE feature

2013-08-08 Thread Mark Engelberg
On Thu, Aug 8, 2013 at 4:50 PM, Norman Richards o...@nostacktrace.comwrote: I do stand by comment. You are free to disagree. It's so painful to watch people (experienced LISPers and newbies alike) manually balancing parenthesis and spending inordinate amounts of time to do the simplest

Re: tools for minimizing forward declaration

2013-08-19 Thread Mark Engelberg
I agree this is a huge pain, although I don't know if I'd call it a forward declaration issue as much as it is an issue with Clojure not allowing circular dependencies among modules. Potemkin seems to be the best way to deal with this particular scenario, but I personally think that this is an

Re: Building Trees

2013-09-08 Thread Mark Engelberg
Rather than describing it in terms of how you'd implement it, can you be clearer about the shape of the data and what specific sorts of operations and queries you need to perform quickly on the data? That would make it easier to brainstorm another way to implement it. -- -- You received this

Re: Building Trees

2013-09-09 Thread Mark Engelberg
OK, I'm starting to understand the shape of the data better. However, you say, the ability to arbitrarily look into any node on the tree and then walk up it getting all of the parents until root. What does the query for this look like and specifically what information do you want returned? What

Re: Building Trees

2013-09-09 Thread Mark Engelberg
Let's assume for the moment that you do in fact absolutely need some sort of bidirectional querying of the data. In other words, from a parent you need to get to the child, and from the child you need to get to the parent. There's no way to accomplish this with immutable data structures without

Re: Building Trees

2013-09-09 Thread Mark Engelberg
There's one other big downside to the mapping-from-names-to-nodes technique that I forgot to mention. If you plan to delete connections between nodes, and the structure is intricate enough that you don't know whether you can safely delete the node itself, then you can potentially end up with

Re: Building Trees

2013-09-16 Thread Mark Engelberg
Offhand, I'd say this sounds like you need to build a Bayesian network. I'd recommend taking this course: https://www.coursera.org/course/pgm which uses this book: http://www.amazon.com/Probabilistic-Graphical-Models-Principles-Computation/dp/0262013193 -- -- You received this message because

Re: much lower recursion depth with memoization

2013-09-22 Thread Mark Engelberg
Check out my blog article from last year and search for the spot where I describe the priming the pump trick: http://programming-puzzler.blogspot.com/2012/11/coin-change-kata-in-racket-and-clojure.html If the simplest way to write the solution to your problem is to use a top-down form of

Re: much lower recursion depth with memoization

2013-09-22 Thread Mark Engelberg
James: It's extremely difficult to overflow the stack in Racket, because the stack isn't arbitrarily limited to some small value -- it does some tricks so that the stack is only limited by your total available memory. For me, having to worry about stack overflows is definitely one of the biggest

Re: much lower recursion depth with memoization

2013-09-22 Thread Mark Engelberg
On Sun, Sep 22, 2013 at 8:54 PM, Mark Engelberg mark.engelb...@gmail.comwrote: When you're doing memoization and you have a lot of holes in the inputs, one option is to have two phases to your function. The first phase takes the initial input and then computes a collection of all the inputs

Re: much lower recursion depth with memoization

2013-09-23 Thread Mark Engelberg
Sorry, I wrote that implementation off-the-cuff and then realized that breadth-first search doesn't actually give you an appropriate dependency ordering. In the above examples I gave, I had: = (all-dependencies 30) (0 1 3 2 5 6 7 10 12 20 15 25 30) which isn't right because 20 depends on 15 which

Re: much lower recursion depth with memoization

2013-09-24 Thread Mark Engelberg
I posted an article detailing the approaches I outlined earlier in this thread: http://programming-puzzler.blogspot.com/2013/09/defeating-stack-overflows.html -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: [ANN] clara-rules 0.1.0 released -- rules as a control structure

2013-09-24 Thread Mark Engelberg
I used CLIPS (another forward-chaining rule system) for several years, and the way I tend to explain it to people is that it is the best tool for the job when your code would look like an enormous cond with thousands of cases, executed over and over, because: 1. The Rete algorithm can jump to

[ANN] Instaparse 1.2.3

2013-10-08 Thread Mark Engelberg
Instaparse https://github.com/Engelberg/instaparse/ is an easy-to-use, feature-rich parser library. The big idea behind instaparse is to make it simple to convert grammars to parsers without needing to know the idiosyncrasies of LL1, LALR, and other esoteric grammar restrictions imposed by most

Re: Regarding http://clojuredocs.org

2013-10-09 Thread Mark Engelberg
On Tue, Oct 8, 2013 at 9:55 PM, Bruce Wang br...@brucewang.net wrote: The official docs is at http://clojure.org/documentation, http://clojure.github.io/clojure/ Sure, but the nice thing about clojuredocs is that it includes examples for most of the functions and for a while, it was updated

Question about vector-of

2013-10-09 Thread Mark Engelberg
(def a (conj (vector-of :long) 1 2 3) (inc (a 1)) Is Clojure smart enough to figure out that (a 1) is a primitive long and call the fast primitive version of inc? -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: Regarding http://clojuredocs.org

2013-10-09 Thread Mark Engelberg
Sometimes, it's also useful to be able to take things out. I keep seeing people get confused by clojuredocs references to contrib libraries that have completely different names now. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this

Re: Question about vector-of

2013-10-10 Thread Mark Engelberg
. Is that correct? Thanks, Mark On Thu, Oct 10, 2013 at 5:09 AM, David Nolen dnolen.li...@gmail.com wrote: Not that I'm aware of. On Thursday, October 10, 2013, Mark Engelberg wrote: (def a (conj (vector-of :long) 1 2 3) (inc (a 1)) Is Clojure smart enough to figure out that (a 1

Re: Too big for the 'mod' britches?

2013-10-11 Thread Mark Engelberg
The pow function returns a double, which doesn't work properly with mod. Use expt from clojure.math.numeric-tower. -- -- 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

Reflecting on Arity

2013-10-13 Thread Mark Engelberg
Is there a handy way to discover the valid arities for an arbitrary Clojure function? -- -- 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 -

Re: Request for help optimising a Clojure program

2013-10-22 Thread Mark Engelberg
I looked briefly at the code and can confirm that to my eye, the two implementations appear to be implementing the same algorithm. My first guess would be that the performance difference comes from Clojure's use of boxed numbers for all the positions. Possibly you could get better performance by

[ANN] clojure.data.priority-map 0.0.3

2013-10-23 Thread Mark Engelberg
https://github.com/clojure/data.priority-map/ A priority map is similar to a sorted map, but sorts the entries by the values rather than the keys in the map. Think of it as a kind of priority queue with a full map-like API to query, add, adjust, and remove items and their priorities. The new

Re: Request for help optimising a Clojure program

2013-10-23 Thread Mark Engelberg
For those of you playing along at home, I also ran Paul's chess program in YourKit with the sampling profiler. Here are all the calls that appear in the HotSpots view, along with time spent in those methods. java.io.PushbackInputStream.read() 422977

Re: Request for help optimising a Clojure program

2013-10-23 Thread Mark Engelberg
On Wed, Oct 23, 2013 at 10:39 AM, Pablo Nussembaum bau...@gmail.com wrote: What do you think of adding odd elements and substract even ones? [1 2] = 1 - 2 = -1 [2 1] = 2 - 1 = 1 Wouldn't multiplying the hash values of the items in a set (rather than adding) result in far fewer accidental

Re: Request for help optimising a Clojure program

2013-10-23 Thread Mark Engelberg
Another example of why this has more to do with the hashing of sets, than underlying elements: = (hash #{#{1 2} 3}) 6 = (hash #{#{1 3} 2}) 6 -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: Request for help optimising a Clojure program

2013-10-23 Thread Mark Engelberg
It is true that it must be commutative, but not true that it must be non-associative. Here is a sample implementation of a hash function for sets that is commutative and associative but doesn't collide for these sorts of common rearrangements. The idea of this proof of concept is that the hash

Re: Request for help optimising a Clojure program

2013-10-23 Thread Mark Engelberg
OK, here is a more serious proposal, comprised of simple, fast operations: To hash a set, you take each of the items in the set, compute the hash value, xor it with the golden number, and square it. Add these results together. Essentially, it's the sum of the squares of the hashes, the xor is

Re: Request for help optimising a Clojure program

2013-10-23 Thread Mark Engelberg
I'd like to point out that my proposed hash function lends itself nicely to incremental hashing for sets. Furthermore, maps also have very weak hashing, and would benefit from a similar change. Right now: = (hash {1 1}) 0 = (hash {1 1 2 2}) 0 = (hash {1 1 2 2 3 3}) 0 = (hash {1 2 2 3 3 1}) 6 =

Re: Request for help optimising a Clojure program

2013-10-23 Thread Mark Engelberg
Perhaps I don't understand your point, but vector hashing is not currently the sum of hashes. It's a more complex computation. = (hash [0 2]) 963 = (hash [2 0]) 1023 = (hash [2]) 33 The fact that numbers hash to themselves means that the resulting hashes are not hugely spread apart, but

Re: Request for help optimising a Clojure program

2013-10-23 Thread Mark Engelberg
Even though vectors aren't as prone to collision between similar-looking vectors, I think you are right that the smallness of the numbers is a problem: Consider the following: = (count (set (for [x (range 200) y (range 200)] (hash [x y] 6369 This means that out of 40,000 common ordered

Re: Request for help optimising a Clojure program

2013-10-23 Thread Mark Engelberg
OK, I get that if lists have to match the Java hash code, then it's a nonstarter to try to improve it. However, Clojure makes a distinction between hasheq and hashCode, one of which is used within Clojure and one of which is used for Java interop, and I don't think they necessarily need to match.

Re: Request for help optimising a Clojure program

2013-10-24 Thread Mark Engelberg
BTW, in the sample set hashing function I provided, the `reduce +` should have been `reduce unchecked-add-int` I've done some timing tests (on a loop/recur version that leverages primitive math better) and it looks like the strategy I proposed has a negligible impact on the current hashing

<    4   5   6   7   8   9   10   11   12   >