Re: Zipper Local Context?
Hi Randall, Am 05.12.2008 um 23:54 schrieb Randall R Schulz: However, I would like to be able to examine the tree in the locality of the current traversal point through path or position specifications. This approach is commonly used in describing algorithms about logical formulas (which are inherently tree-structured). If you're not familiar with the notion, these paths / positions are directly analogous to file system path names, except that one uses integers to label the arcs, said integers being ordinals in the child sequence of a given node. I had the same problem some weeks ago and posted a half-baked solution to the list. http://groups.google.com/group/clojure/browse_thread/thread/bfd6539ec367a95b/51e28ee607790496?lnk=gstq=goto-by#51e28ee607790496 However the interest was very low. So I worked on the issue and the attached patch is what I came up with. For my purposes it works pretty well. Although I'm not sure it does what you need. Hope this helps. Sincerely Meikel walk-along.clj Description: Binary data smime.p7s Description: S/MIME cryptographic signature
Re: reduction
Chouser a écrit : How about this one? Same results as in my previous post. Still as lazy as possible. Plus it's so cute! (defn reduction Returns a lazy seq of the intermediate values of the reduction (as per reduce) of coll by f, starting with init. ([f coll] (if (seq coll) (lazy-cons (first coll) (map f (reduction f coll) (rest coll))) (cons (f) nil))) ([f init coll] (lazy-cons init (map f (reduction f init coll) coll But I don't think it's still O(n). I searched for a way to define recursively such lists but the only way I found involves using mutation. Now with an atom it must be cleaner. Christophe --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Running clojure-contrib.jar
I got Failed to load Main-Class manifest attribute from C;/clojure/ clojure/clojure when I tried to run clojure. Could someone assist me in getting this solved. Emeka --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Math as multimethods
Hello, Clojure newbie here. I'm porting a small Scheme matrix/linear algebra library over to Clojure as a way to get familiar. In my scheme lib, I have a (matrix-mult A B) function, but it would be nice to have the more standard notation (* A B) or (* 3 A) for scalar multiplication. I see *, /, +, - are standard functions. Would a patch to add multimethod-icity to math be accepted? What kind of performance numbers would be acceptable? Alternatively, could I provide a multi- math lib to redefine the core math functions? Thanks for your feedback, -Mark --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: reduction
On Sat, Dec 6, 2008 at 4:27 AM, Christophe Grand [EMAIL PROTECTED] wrote: But I don't think it's still O(n). I searched for a way to define recursively such lists but the only way I found involves using mutation. Now with an atom it must be cleaner. Your comprehension of such things is clearly deeper than mine. Testing just now on large collections, the version using 'map' is indeed not only slower, but also overflows the stack. Hm... and perhaps I see why now. Is it computing the entire chain up to each result -- O(n^2), demanding n stack frames for the nth result? Anyway, either of the definitions presented together work fine for large collections and appear to operate in O(n) as you'd expect. --Chouser --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Running out of memory when using filter?
On Sat, Dec 6, 2008 at 4:52 AM, Paul Mooser [EMAIL PROTECTED] wrote: Ok, even after the change precisely as you described, I still get the same result. The following object is a GC root of a graph worth several hundreds of megabytes of memory, consisting basically of a giant chain of lazy-conses: clojure.core$filter__3364$fn__3367 This may not be worth much, but can you see the data members of that object? It's not itself the head of a cons chain, presumably, so I'm wondering if the data member that *is* at the head has a useful name. --Chouser --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Elegant but very slow
Thanks for all the suggestions! This modified version is very close to that in the thread: http://groups.google.com/group/clojure/browse_thread/thread/f0303a9e00b38529/99f02fef21721a2f?lnk=gstq=alioth+tree#99f02fef21721a2f (Thanks for pointing that out Meikel. I should have searched old threads before posting.) (defn make-tree [item depth] (if (zero? depth) [item nil nil] (let [item2 (* 2 item) depth-1 (dec depth)] [item (make-tree (dec item2) depth-1) (make-tree item2 depth-1)]))) ; Note: (+ (tree 0) (check-tree (tree 1)) (- (check-tree (tree 2 seems to require ; the creation of an intermediate list and runs twice as slow (defn check-tree [tree] (if tree (- (+ (tree 0) (check-tree (tree 1))) (check-tree (tree 2))) 0)) (defn sum-trees [iterations depth] (let [sum #(+ (check-tree (make-tree % depth)) (check-tree (make-tree (- %) depth)))] (reduce + (map sum (range 1 (inc iterations)) (time (println result: (sum-trees 1 10))) Running in Clojure REPL for java 1.6.0_11 with -server option: result: -2 Elapsed time: 6080.294283 msecs Wow! Elegant and fast! --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Zipper Local Context?
On Saturday 06 December 2008 01:00, Meikel Brandmeyer wrote: Hi Randall, Am 05.12.2008 um 23:54 schrieb Randall R Schulz: However, I would like to be able to examine the tree in the locality of the current traversal point through path or position specifications. This approach is commonly used in describing algorithms about logical formulas (which are inherently tree-structured). If you're not familiar with the notion, these paths / positions are directly analogous to file system path names, except that one uses integers to label the arcs, said integers being ordinals in the child sequence of a given node. I had the same problem some weeks ago and posted a half-baked solution to the list. http://groups.google.com/group/clojure/browse_thread/thread/bfd6539ec 367a95b/51e28ee607790496?lnk=gstq=goto-by#51e28ee607790496 OK. I reviewed that thread. It seems to me you had another posting, more recent, in which you talked about some other aspect of tree processing. I'll have to find and read that one, too. However the interest was very low. So I worked on the issue and the attached patch is what I came up with. For my purposes it works pretty well. Although I'm not sure it does what you need. One thing I noticed from the discussion in mid October was an apparent failure to distinguish arc labels from node labels. People don't often think of it, but in the Unix file system, each element of a path name is an _arc_ label, not a node label. Node labels are uninteresting low-level identifiers (technically referred to as inode numbers). Now the file system example is just one of many that arise in computing, obviously, but you did use a file system example and it's something concrete that everyone recognizes. But those details are not critical, only the general fact that you must always remain clear about when you care about node labels and when you care about arc labels. So my recent question related to arc labels specifically in the form of ordinals of child elements. In my logical formula case using this as an example: (forall ?X (and (P ?X) (Q ?X))) there are these distinct paths / positions: - epsilon (empty path, always refers to the root / entire formula) - 0 = forall ?X (the quantifier and the variable it binds are a single entity) - 1 = (and ...) - 1.0 = and - 1.1 = (P ?X) - 1.1.0 = P - 1.1.1 = ?X - 1.2 = (Q ?X) - 1.2.0 = Q - 1.2.1 = ?X Now if I want to process an arbitrary formula looking for, say, either conjunctions or disjunctions of atoms (in the terminology of mathematical logic, (P ?X) is an atomic formula or atom), I need to ensure, using traversal-point-relative path names, that all these are true (assume for this example that and is strictly binary): - epsilon = AND or OR - 1 = instanceof ATOM - 2 = instanceof ATOM When all those obtain, I have the pattern I seek, wherever it may lie within an arbitrary formula. In practice, there are often non-structural criteria that require further examination of the elements of the formula, but that's not a big deal in a functional language where once can easily specify arbitrary functions to serve as predicates. I'll also suggest that navigation within a tree based solely on up / down and left / right steps is probably going to make programming tedious if its the only way one has to move about the target tree or to access its contents. It's vaguely like having to use successor notation for integers instead of radix-encoded (decimal, e.g.) numerals. Hope this helps. Sincerely Meikel Randall Schulz --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Running clojure-contrib.jar
On Saturday 06 December 2008 03:18, janus wrote: I got Failed to load Main-Class manifest attribute from C;/clojure/ clojure/clojure when I tried to run clojure. Could someone assist me in getting this solved. Start by telling us precisely what you did to run clojure. Also, your Subject: mentions clojure-contrib.jar, which contains only libraries and not an entry point. Also: Sometimes for things like this asking on the #clojure IRC channel is more expedient, assuming it's a time of day when many people are around. Emeka Randall Schulz --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Math as multimethods
On 6 déc, 05:09, Mark Fredrickson [EMAIL PROTECTED] wrote: Alternatively, could I provide a multi- math lib to redefine the core math functions? Type classes would be king. But at least you can use your definition : (ns test.test (:refer-clojure :exclude [+ -])) (defn + [a b] 33) (+ 1 2) ;= 33 pierre --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Running clojure-contrib.jar
On Saturday 06 December 2008 08:10, janus wrote: Start by telling us precisely what you did to run clojure. I have the below in my batch file SET CLASSPATH=/clojure/clojure/clojure.jar ;\ /clojure/clojure/clojure-contrib.jar;\ java clojure.lang.Repl The instructions are these: SET CLASSPATH=/jars/clojure.jar;\ /jars/clojure-contrib.jar;\ /path/to/book/code java clojure.lang.Repl Since you omitted the line with /path/to/book/code you must also remove the second backslash. Also, it looks like you have a space before the semicolon. If so, remove it. Lastly, you omitted one line from his sample, which means you must also remove the second backslash. To run means clicking batch file. I followed the instructiom from Clojure Programming Book. I got a message box with the Failed to load Main-Class manifest attribute from C;/clojure/clojure/clojure. On click ok, it opened the Repl. As Dave said, the semicolon there seems misplaced. Should it not be a colon? Did you transcribe the error message by hand? Or did you copy and paste it into your email? Emeka Randall Schulz --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Elegant but very slow
Has anyone been able to use type hints to successfully close the last bit of difference between the Clojure and Java version on this benchmark? On Sat, Dec 6, 2008 at 6:14 AM, PeterB [EMAIL PROTECTED] wrote: Running in Clojure REPL for java 1.6.0_11 with -server option: result: -2 Elapsed time: 6080.294283 msecs Wow! Elegant and fast! --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Running out of memory when using filter?
A while back I posted an experimental patch to capture each form that is compiled into a fn. This might be useful in your case, where you have identified a function but don't have details on it. Here's the thread: http://groups.google.com/group/clojure/browse_frm/thread/e63e48a71935e31a?q= Also, you can name your anonymous fn's to help track a problem back to your source (Clojure will include your fn name in the class name). --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Zipper Local Context?
On Friday 05 December 2008 14:54, Randall R Schulz wrote: Hi, I looked at the Clojure implementation of Huet's Zipper and it looks great. I like how it delegates construction and dissection of the tree structure to client-supplied functions so that it is generic w.r.t. to any types (especially for me, pre-existing, non-Clojure Java types) that can be deemed to encode a tree structure. ... Now that I've worked around the fact that it's not possible to (use 'clojure.zip) and started playing with this implementation, I finally understand what (- ...) is for. My next minor stumbling point is another (to me) inexplicable error. Here's what I did: - Made a copy of clojure/zip.clj - Changed the (ns ...) form to (ns rrs.zipper) - Renamed the conflicting (defn replace ...) and (defn remove ...) - Moved the (comment ...) -ed samples to a separate file. I can now evaluate all the forms in the sample code by pasting them into the REPL. However, if I (load-file ...) the source in which those same forms are found, I get this: user= (use 'rrs.zipper) nil user= (load-file /dar/clojure/zipper-test.clj) java.lang.ClassCastException: clojure.lang.LazyCons cannot be cast to clojure.lang.IFn (zipper-test.clj:35) What might explain this? Randall Schulz --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Running out of memory when using filter?
I can, and what it has is the elements you might expect for something defined in the context of filter: coll pred coll is a lazy-cons, and is the start of a chain of a larger number of lazy conses. One thing that is interesting is that it does not appear to be the head of the sequence - it's near the head, but not the head, as far as I can tell. pred is the predicate I passed in, and I can see that it definitely does not itself maintain a reference to the sequence, at least according to the heap profiler. --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Running out of memory when using filter?
On Dec 6, 5:45 am, Chouser [EMAIL PROTECTED] wrote: This may not be worth much, but can you see the data members of that object? It's not itself the head of a cons chain, presumably, so I'm wondering if the data member that *is* at the head has a useful name. I can, and it has the elements you might expect for something defined in the context of filter: coll pred coll is a lazy-cons, and is the start of a chain of a larger number of lazy conses. One thing that is interesting is that it does not appear to be the head of the sequence - it's near the head, but not the head, as far as I can tell. pred is the predicate I passed in, and I can see that it definitely does not itself maintain a reference to the sequence, at least according to the heap profiler. --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Running out of memory when using filter?
On Dec 6, 9:37 am, MikeM [EMAIL PROTECTED] wrote: A while back I posted an experimental patch to capture each form that is compiled into a fn. This might be useful in your case, where you have identified a function but don't have details on it. Here's the thread:http://groups.google.com/group/clojure/browse_frm/thread/e63e48a71935... Thanks Mike, this sounds like a possible avenue for me to explore. At this point I'm not even introducing any anonymous functions of my own anymore, as far as I know - maybe I can use your patch to help debug what is really going on. Thanks for the help. --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Running clojure-contrib.jar
If you have a space between jar and ; that is a problem. Stuart Start by telling us precisely what you did to run clojure. I have the below in my batch file SET CLASSPATH=/clojure/clojure/clojure.jar ;\ /clojure/clojure/clojure-contrib.jar;\ java clojure.lang.Repl To run means clicking batch file. I followed the instructiom from Clojure Programming Book. I got a message box with the Failed to load Main-Class manifest attribute from C;/clojure/ clojure/clojure. On click ok, it opened the Repl. Emeka Also: Sometimes for things like this asking on the #clojure IRC channel is more expedient, assuming it's a time of day when many people are around. Emeka Randall Schulz --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
re-gsub improvement
Hi List, a little thing I have grown quite fond of: (re-gsub #\b(?:word|expr|whatever)\b {word A WORD expr An Expression whatever WHATEVER!} welcome to the united states of whatever) Patch at http://groups.google.at/group/clojure/web/re-gsub.patch For completeness, I also implemented re-sub with a function as replacement. Never needed it though. Cheers, Juergen --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Zipper Local Context?
On Sat, Dec 6, 2008 at 12:52 PM, Randall R Schulz [EMAIL PROTECTED] wrote: - Renamed the conflicting (defn replace ...) and (defn remove ...) But 'remove' is also defined by clojure.core user= (load-file /dar/clojure/zipper-test.clj) java.lang.ClassCastException: clojure.lang.LazyCons cannot be cast to clojure.lang.IFn (zipper-test.clj:35) What might explain this? Hard to guess with just a single line from a stack trace on an unknown .clj file, but I wouldn't be shocked if it was related to the 'remove' name confusion. --Chouser --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
neo4j-clojure
A wrapper for neo4j, which is a non-relational database using a network of nodes with properties and traversable relationships. This is my first Clojure wrapper library, I've tried to keep the spirit of Clojure by only wrapping things that were verbose or un- lispy. Please comment and critique. Patches welcome. http://github.com/JulianMorrison/neo4j-clojure/tree/master --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Clojure Blogs | Yahoo Pipes | Clojure Pipe
Hi all, A lot of people are writing Clojure-related blog posts; however, I am often only interested in the Clojure posts they do and not the other posts. Therefore, I've created a mashup of clojure-related blog posts using Yahoo Pipes. The description is here: http://bc.tech.coop/blog/081206.html If you want to view the blogs or subscribe to the feeds, the url is: feed://pipes.yahoo.com/pipes/pipe.run?_id=4cc8ebb9ae0b852d6ab7d94956ce2638_render=rss -- Bill Clementson --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: neo4j-clojure
--- On Sat, 12/6/08, Julian Morrison wrote: A wrapper for neo4j, which is a non-relational database using [...] traversable relationships. Hey, wait... Dave --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure Blogs | Yahoo Pipes | Clojure Pipe
On Sat, 6 Dec 2008 13:24:52 -0800 (PST) bc [EMAIL PROTECTED] wrote: Hi all, A lot of people are writing Clojure-related blog posts; however, I am often only interested in the Clojure posts they do and not the other posts. Therefore, I've created a mashup of clojure-related blog posts using Yahoo Pipes. The description is here: http://bc.tech.coop/blog/081206.html If you want to view the blogs or subscribe to the feeds, the url is: feed://pipes.yahoo.com/pipes/pipe.run?_id=4cc8ebb9ae0b852d6ab7d94956ce2638_render=rss -- Bill Clementson Thanks, that's really useful. bd -- None are more hopelessly enslaved than those who falsely believe they are free — Goethe --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: neo4j-clojure
On Saturday 06 December 2008 13:43, Dave Newton wrote: --- On Sat, 12/6/08, Julian Morrison wrote: A wrapper for neo4j, which is a non-relational database using [...] traversable relationships. Hey, wait... OK. But I can't hold my breath forever... Dave RRS --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: neo4j-clojure
Hey, I was just looking at neo4j last night. Can you point me to any papers about the theory behind those kinds of a databases? Thanks, Jim On Dec 6, 3:15 pm, Julian Morrison [EMAIL PROTECTED] wrote: A wrapper for neo4j, which is a non-relational database using a network of nodes with properties and traversable relationships. This is my first Clojure wrapper library, I've tried to keep the spirit of Clojure by only wrapping things that were verbose or un- lispy. Please comment and critique. Patches welcome. http://github.com/JulianMorrison/neo4j-clojure/tree/master --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure Blogs | Yahoo Pipes | Clojure Pipe
On Saturday 06 December 2008 13:24, bc wrote: Hi all, A lot of people are writing Clojure-related blog posts; however, I am often only interested in the Clojure posts they do and not the other posts. Therefore, I've created a mashup of clojure-related blog posts using Yahoo Pipes. The description is here: http://bc.tech.coop/blog/081206.html If you want to view the blogs or subscribe to the feeds, the url is: feed://pipes.yahoo.com/pipes/pipe.run?_id=4cc8ebb9ae0b852d6ab7d94956c e2638_render=rss Fascinating. Is that diagram generated by Yahoo! Pipes itself, or did you draw it? Also, what is the feed: scheme? When I click those links (in Firefox on my Linux system), nothing happens. What sort of application supports it? For whatever reason, Akregator (KDE-based RSS feed aggregator) does not like that URL. -- Bill Clementson Randall Schulz --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: neo4j-clojure
Not papers, but... http://en.wikipedia.org/wiki/Network_database http://en.wikipedia.org/wiki/Navigational_database Neo4j is basically a really old design refreshed. The advantages are that it's fast, dynamic, and schema-free, and fairly lispy in its inherently recursive structure. The disadvantages are that it's messy, can't be joined but only traversed (this is bad especially for data mining and reporting), is hard to data dump, and at the moment neo4j runs in-process with no multi-user access. On Dec 6, 10:09 pm, jim [EMAIL PROTECTED] wrote: Hey, I was just looking at neo4j last night. Can you point me to any papers about the theory behind those kinds of a databases? Thanks, Jim On Dec 6, 3:15 pm, Julian Morrison [EMAIL PROTECTED] wrote: A wrapper for neo4j, which is a non-relational database using a network of nodes with properties and traversable relationships. This is my first Clojure wrapper library, I've tried to keep the spirit of Clojure by only wrapping things that were verbose or un- lispy. Please comment and critique. Patches welcome. http://github.com/JulianMorrison/neo4j-clojure/tree/master --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure Blogs | Yahoo Pipes | Clojure Pipe
On Sat, Dec 6, 2008 at 4:24 PM, bc [EMAIL PROTECTED] wrote: A lot of people are writing Clojure-related blog posts; however, I am often only interested in the Clojure posts they do and not the other posts. Thanks, this is a great idea. At the risk of sounding self-absorbed, though, I noticed that although my blog appears to be included in that diagram, none of my blog posts appear in the feed. I couldn't figure out how to examine the pipe to see the source of the problem. --Chouser --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Running clojure-contrib.jar
All, It is my mistake, this is the error once again. Failed to load Main- Class manifest attribute from C:\clojure\clojure\clojure-contrib.jar. I did what Shulz said , however , I still have the same problem. Emeka On Dec 6, 7:17 pm, Stuart Halloway [EMAIL PROTECTED] wrote: If you have a space between jar and ; that is a problem. Stuart Start by telling us precisely what you did to run clojure. I have the below in my batch file SET CLASSPATH=/clojure/clojure/clojure.jar /clojure/clojure/clojure-contrib.jar;\ java clojure.lang.Repl To run means clicking batch file. I followed the instructiom from Clojure Programming Book. I got a message box with the Failed to load Main-Class manifest attribute from C;/clojure/ clojure/clojure. On click ok, it opened the Repl. Emeka Also: Sometimes for things like this asking on the #clojure IRC channel is more expedient, assuming it's a time of day when many people are around. Emeka Randall Schulz- Hide quoted text - - Show quoted text - --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Running clojure-contrib.jar
--- On Sat, 12/6/08, janus wrote: It is my mistake, this is the error once again. Failed to load Main-Class manifest attribute from C:\clojure\clojure\clojure-contrib.jar. I did what Shulz said, however, I still have the same problem. Can you post the *exact* classpath and/or files and/or commands you're using? Like get the classpath via: echo %CLASSPATH% I'm reasonably sure it shouldn't be trying to load a Main-Class from the contrib jar, so I suspect the classpath is not being set properly. Dave --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Running clojure-contrib.jar
On Saturday 06 December 2008 14:51, janus wrote: All, It is my mistake, this is the error once again. Failed to load Main- Class manifest attribute from C:\clojure\clojure\clojure-contrib.jar. I did what Shulz said , however , I still have the same problem. Two things: 1) My name is Schulz. 2) The Clojure contrib JAR file is not executable. The main entry point is in the Clojure core JAR file. If you're getting a diagnostic about a failure to load a main class manifest entry from clojre-contrib.jar, you're trying to run the wrong JAR file. Furthermore, this makes me think you've not told us what's actually in your batch script, since what you posted previously should not cause the diagnostic you're getting. That diagnostic suggests you're using the -jar option. Emeka Randall Schulz --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Running out of memory when using filter?
On Dec 6, 2008, at 6:21 PM, Paul Mooser wrote: (defn splode [index-path] (with-local-vars [doc-count 0] (doseq [document (filter my-filter-pred (document-seq index- path))] (var-set doc-count (inc @doc-count))) 'done)) The fn in question is likely the one in the macro expansion of the lazy-cons inside filter. As a next step, I would try replacing the call to doseq with the equivalent loop/recur: (loop [document (filter my-filter-pred (document-seq index-path))] (var-set doc-count (inc !doc-count)) (recur (filter my-filter-pred (document-seq index-path This will rule in our out a problem with doseq. --Steve smime.p7s Description: S/MIME cryptographic signature
List comprehension: :when AND :while for the same binding?
(for [x (range 1 20) :when ( x 8) :while ( 0 (rem x 13))] x) == java.lang.Exception: Unsupported binding form: :while But: (for [x (range 1 20) :when ( x 8)] x) == (9 10 11 12 13 14 15 16 17 18 19) And: (for [x (range 1 20) :while ( 0 (rem x 13))] x) == (1 2 3 4 5 6 7 8 9 10 11 12) Is it intended that there can be at most one condition per binding? --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: memory issue with nth
On Saturday 06 December 2008 17:11, Christian Vest Hansen wrote: I played around with some code, trying to explore the memory problems with 'filter' that is discussed in another thread, when I noticed an unexpected behavior from 'nth'. Behold: user= (nth (repeatedly (fn [] 0)) 1000) java.lang.OutOfMemoryError: Java heap space (NO_SOURCE_FILE:0) user= (defn xth [coll i] (if (zero? i) (first coll) (recur (rest coll) (dec i #'user/xth user= (xth (repeatedly (fn [] 0)) 1000) 0 I could be wrong, but I don't think 'nth' should blow the heap here. I cannot reproduce this while invoking Java with the default heap allocation. Also: user= (time (nth (repeatedly (fn [] 0)) 1000)) Elapsed time: 7572.222 msecs 0 user= (time (nth (repeatedly (fn [] 0)) 1000)) Elapsed time: 7632.135 msecs 0 user= (time (nth (repeatedly (fn [] 0)) 1000)) Elapsed time: 7675.07 msecs 0 user= (time (nth (repeatedly (fn [] 0)) 1000)) Elapsed time: 2236.852 msecs 0 user= (time (nth (repeatedly (fn [] 0)) 1000)) Elapsed time: 2166.64 msecs 0 user= (time (nth (repeatedly (fn [] 0)) 1000)) Elapsed time: 2270.884 msecs 0 user= (time (xth (repeatedly (fn [] 0)) 1000)) Elapsed time: 3264.81 msecs 0 user= (time (xth (repeatedly (fn [] 0)) 1000)) Elapsed time: 3257.63 msecs 0 user= (time (xth (repeatedly (fn [] 0)) 1000)) Elapsed time: 3361.943 msecs 0 user= (time (xth (repeatedly (fn [] 0)) 1000)) Elapsed time: 3245.313 msecs 0 user= (time (xth (repeatedly (fn [] 0)) 1000)) Elapsed time: 3290.656 msecs 0 user= (time (xth (repeatedly (fn [] 0)) 1000)) Elapsed time: 3264.101 msecs 0 These results were for a newly launched instance. I submitted the definition of (xth ...) between the two sequences of invocations shown above. Randall Schulz --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure Blogs | Yahoo Pipes | Clojure Pipe
On Sat, Dec 6, 2008 at 11:11 PM, Randall R Schulz [EMAIL PROTECTED] wrote: On Saturday 06 December 2008 13:24, bc wrote: Also, what is the feed: scheme? When I click those links (in Firefox on my Linux system), nothing happens. What sort of application supports it? For whatever reason, Akregator (KDE-based RSS feed aggregator) does not like that URL. s/feed/http/ seems to do the trick, for some reason. Randall Schulz -- 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Running out of memory when using filter?
On Dec 6, 4:35 pm, Stephen C. Gilardi [EMAIL PROTECTED] wrote: The fn in question is likely the one in the macro expansion of the lazy-cons inside filter. As a next step, I would try replacing the call to doseq with the equivalent loop/recur: That's a good idea, Steve - I didn't totally understand the code you included, but I do always forget that clojure has destructuring in its binding forms, so I rewrote it like this, which I believe should be fine (correct me if I am wrong): (defn splode2 [index-path] (with-local-vars [doc-count 0] (loop [[document rest-documents] (filter my-filter-pred (document-seq index-path))] (when document (var-set doc-count (inc @doc-count)) (recur rest-documents))) 'done)) This blows up exactly the same, with exactly the same object (clojure.core$filter__3364$fn__3367) referencing the big chain of lazy- conses. --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: memory issue with nth
On Sun, Dec 7, 2008 at 2:22 AM, Randall R Schulz [EMAIL PROTECTED] wrote: On Saturday 06 December 2008 17:11, Christian Vest Hansen wrote: I played around with some code, trying to explore the memory problems with 'filter' that is discussed in another thread, when I noticed an unexpected behavior from 'nth'. Behold: user= (nth (repeatedly (fn [] 0)) 1000) java.lang.OutOfMemoryError: Java heap space (NO_SOURCE_FILE:0) user= (defn xth [coll i] (if (zero? i) (first coll) (recur (rest coll) (dec i #'user/xth user= (xth (repeatedly (fn [] 0)) 1000) 0 I could be wrong, but I don't think 'nth' should blow the heap here. I cannot reproduce this while invoking Java with the default heap allocation. Try adding another zero, then. Could be down to a difference between our JVMs. My point is that I think that 'nth' itself should be O(1) in memory usage (and I present 'xth' as an example of a similar function that is, though it's not a complete replacement for 'nth'), but it appears to me that 'nth's memory usage is dependent on the size of the collection it searches. Also: user= (time (nth (repeatedly (fn [] 0)) 1000)) Elapsed time: 7572.222 msecs 0 user= (time (nth (repeatedly (fn [] 0)) 1000)) Elapsed time: 7632.135 msecs 0 user= (time (nth (repeatedly (fn [] 0)) 1000)) Elapsed time: 7675.07 msecs 0 user= (time (nth (repeatedly (fn [] 0)) 1000)) Elapsed time: 2236.852 msecs 0 user= (time (nth (repeatedly (fn [] 0)) 1000)) Elapsed time: 2166.64 msecs 0 user= (time (nth (repeatedly (fn [] 0)) 1000)) Elapsed time: 2270.884 msecs 0 user= (time (xth (repeatedly (fn [] 0)) 1000)) Elapsed time: 3264.81 msecs 0 user= (time (xth (repeatedly (fn [] 0)) 1000)) Elapsed time: 3257.63 msecs 0 user= (time (xth (repeatedly (fn [] 0)) 1000)) Elapsed time: 3361.943 msecs 0 user= (time (xth (repeatedly (fn [] 0)) 1000)) Elapsed time: 3245.313 msecs 0 user= (time (xth (repeatedly (fn [] 0)) 1000)) Elapsed time: 3290.656 msecs 0 user= (time (xth (repeatedly (fn [] 0)) 1000)) Elapsed time: 3264.101 msecs 0 These results were for a newly launched instance. I submitted the definition of (xth ...) between the two sequences of invocations shown above. Randall Schulz -- 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Running out of memory when using filter?
On Dec 6, 2008, at 8:28 PM, Paul Mooser wrote: That's a good idea, Steve - I didn't totally understand the code you included, but I do always forget that clojure has destructuring in its binding forms, so I rewrote it like this, which I believe should be fine (correct me if I am wrong): Thanks for the polite correction to my incorrect code. :) What you have looks correct to me. (defn splode2 [index-path] (with-local-vars [doc-count 0] (loop [[document rest-documents] (filter my-filter-pred (document-seq index-path))] (when document (var-set doc-count (inc @doc-count)) (recur rest-documents))) 'done)) For more simplifications with nearly equivalent effect: (defn splode3 [index-path] (loop [[document rest-documents] (filter my-filter-pred (document- seq index-path))] (when document (recur rest-documents (defn splode4 [index-path] (loop [myseq (filter my-filter-pred (document-seq index-path))] (when (first myseq) (recur (rest myseq) (defn splode5 [index-path] (dorun (filter my-filter-pred (document-seq index-path --Steve smime.p7s Description: S/MIME cryptographic signature
Re: Running out of memory when using filter?
I think I've been able to duplicate your results with a simpler example. I first tried this: (defn splode [n] (with-local-vars [doc-count 0] (doseq [document (filter #(= % 1) (range n))] (var-set doc-count (inc @doc-count))) 'done)) and it doesn't blow up with (splode 10). Next, I tried this (since your app filters the seq from a map): (defn splode2 [n] (with-local-vars [doc-count 0] (doseq [document (filter #(= % 1) (map inc (range n)))] (var-set doc-count (inc @doc-count))) 'done)) and it blows up (out of memory) with (splode2 1000) So it seems that (filter pred (map ...)) is the issue. --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: DISCUSS: replace (rand)
On Dec 2, 10:42 am, bOR_ [EMAIL PROTECTED] wrote: I'll compare it later on to the one ruby is using (Mersenne Twister Algorithm, which is excellent for monte carlo-like simulations), just to get my own bearings. An alternative to MT that is as good, according to RNG expert George Marsaglia, but simpler and faster is Marsaglias multiply-with-carry (MWC). There are of course plenty of MT implementations in Java out there that you could reuse but if you need a pure clojure PRNG the simplest MWC1 below might fit the bill. I have not tested this extensively but I implemented his simplest MWC PRNG (interface is not so nice maybe but I was playing with multimethods and STMs ;)), FWIW: (defstruct *mwc-rng* :rng-type :seed1 :seed2 :z :w :constz :constw) (defn make-rng-mwc1 [seed1 seed2] (struct *mwc-rng* :marsaglia-mwc1 seed1 seed2 (bit-and seed1 0x) (bit-and seed2 0x) 36969 18000)) (defmulti update :rng-type) (defmulti randint32 :rng-type) (defn mwc1 [c v] (+ (* c (bit-and v 0x)) (bit-shift-right v 16))) (defmethod update :marsaglia-mwc1 [rng] (merge rng {:z (mwc1 (:constz rng) (:z rng)) :w (mwc1 (:constw rng) (:w rng))})) (defmethod randint32 :marsaglia-mwc1 [rng] (+ (bit-shift-left (bit-and (:z rng) 0x) 16) (bit-and (:w rng) 0x))) (defstruct *autoupdating-rng* :rng-type :rng-ref) (defn make-rng-autoupdating [corerng] (struct *autoupdating-rng* :autoupdating (ref corerng))) (defn update-then-apply [autorng fn] (let [refrng (:rng-ref autorng)] (dosync (alter refrng #(update %)) (fn @refrng (defmethod randint32 :autoupdating [rng] (update-then-apply rng #(randint32 %))) Easy to turn into a lazy stream version if preferred and type hints could speed it up... For details check: http://www.ms.uky.edu/~mai/RandomNumber Cheers, Robert Feldt --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: memory issue with nth
It doesn't blow the heap on my machine, using the Clojure in a Box setup, and I only have 1GB of memory total. I added a couple 0s, and it didn't make a difference. --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Running out of memory when using filter?
This also fails: (defn splode [n] (doseq [document (filter #(= % 20) (map inc (range n)))])) Looking at the heap dump, I see that the first item for which the filter returns true is the root of the chain of lazy cons's that's being kept. The filter is constructing a lazy-cons from the first of a lazy-cons returned by map. --Steve On Dec 6, 2008, at 9:29 PM, MikeM wrote: Some more experimentation: (defn splode3 [n] (with-local-vars [doc-count 0] (doseq [document (filter #(= % (- n 1)) (map inc (range n)))] (var-set doc-count (inc @doc-count))) 'done)) which does not blow up with (splode3 10). --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~--- smime.p7s Description: S/MIME cryptographic signature
Re: Running out of memory when using filter?
You reproduced it for sure -- On Dec 6, 5:58 pm, MikeM [EMAIL PROTECTED] wrote: Next, I tried this (since your app filters the seq from a map): (defn splode2 [n] (with-local-vars [doc-count 0] (doseq [document (filter #(= % 1) (map inc (range n)))] (var-set doc-count (inc @doc-count))) 'done)) and it blows up (out of memory) with (splode2 1000) I went ahead and dug around through the heap again, and found it's exactly the same thing that's holding on to all the memory, so this is definitely the same problem. I also saw your subsequent example which uses a different anonymous function which does NOT blow up, and that's very interesting. I'm not sure why this would be, but it seems that filter ends up holding on to the collection its filtering internally from the point at which it first matches - I think the second one doesn't blow up because it doesn't happen until almost the end. --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Running out of memory when using filter?
On Dec 6, 2008, at 9:48 PM, Paul Mooser wrote: I also saw your subsequent example which uses a different anonymous function which does NOT blow up, and that's very interesting. I'm not sure why this would be, but it seems that filter ends up holding on to the collection its filtering internally from the point at which it first matches - I think the second one doesn't blow up because it doesn't happen until almost the end. I agree with this as the reason why the second example worked. When filter finds a match it tries to construct a lazy cons of the first of the match (which in this case is a one of the members of the sequence) and the rest which it then goes on to fully realize. The first is still hooked up to that rest and since it's being retained, the entire sequence stays in memory. Somehow the first needs to shed its rest before we construct the new lazy_cons. I'm still thinking about the details of that. --Steve smime.p7s Description: S/MIME cryptographic signature
Re: Running out of memory when using filter?
I think I understand. The lazy-cons that filter is constructing maintains a reference to the whole coll in its tail so that it can evaluate (rest coll) when it is forced. Hmmm! --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Running clojure-contrib.jar
On Dec 7, 3:51 am, janus [EMAIL PROTECTED] wrote: All, It is my mistake, this is the error once again. Failed to load Main- Class manifest attribute from C:\clojure\clojure\clojure-contrib.jar. I did what Shulz said , however , I still have the same problem. Could you copy the error messages to the list? That would help in understanding the error better. Also, are you using the latest sources from the svn or the released version? In there latest sources there are some enhancements to the main (like adding -h, -e options etc.). So, with the latest svn HEAD, the windows equivalent of the following should work for you: java -server -cp /home/parth/src/clojure/clojure.jar:/home/parth/src/ clojure-contrib/clojure-contrib.jar clojure.main Note that on windows, apart from the path changes you would need to use ; instead of :. Parth Emeka On Dec 6, 7:17 pm, Stuart Halloway [EMAIL PROTECTED] wrote: If you have a space between jar and ; that is a problem. Stuart Start by telling us precisely what you did to run clojure. I have the below in my batch file SET CLASSPATH=/clojure/clojure/clojure.jar /clojure/clojure/clojure-contrib.jar;\ java clojure.lang.Repl To run means clicking batch file. I followed the instructiom from Clojure Programming Book. I got a message box with the Failed to load Main-Class manifest attribute from C;/clojure/ clojure/clojure. On click ok, it opened the Repl. Emeka Also: Sometimes for things like this asking on the #clojure IRC channel is more expedient, assuming it's a time of day when many people are around. Emeka Randall Schulz- Hide quoted text - - Show quoted text - --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Running out of memory when using filter?
On Dec 6, 2008, at 10:27 PM, Paul Mooser wrote: I think I understand. The lazy-cons that filter is constructing maintains a reference to the whole coll in its tail so that it can evaluate (rest coll) when it is forced. Hmmm! In the current implementation of filter, coll is held the entire time that (rest coll) is calculated on the first match. The following separation into two functions appears to solve it. I'll be looking at simplifying it. If you use a definition of filter like this in your test, I think it will succeed: (defn filter-iter [pred coll] (when (seq coll) (if (pred (first coll)) [(first coll) (rest coll)] (recur pred (rest coll) (defn filter Returns a lazy seq of the items in coll for which (pred item) returns true. pred must be free of side-effects. [pred coll] (let [result (filter-iter pred coll)] (when result (lazy-cons (result 0) (result 1) --Steve smime.p7s Description: S/MIME cryptographic signature
Re: Running out of memory when using filter?
Except your version of filter doesn't do any filtering on the rest in the case where the first satisfies the predicate. On Sat, Dec 6, 2008 at 7:43 PM, Stephen C. Gilardi [EMAIL PROTECTED] wrote: If you use a definition of filter like this in your test, I think it will succeed: (defn filter-iter [pred coll] (when (seq coll) (if (pred (first coll)) [(first coll) (rest coll)] (recur pred (rest coll) (defn filter Returns a lazy seq of the items in coll for which (pred item) returns true. pred must be free of side-effects. [pred coll] (let [result (filter-iter pred coll)] (when result (lazy-cons (result 0) (result 1) --Steve --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Running out of memory when using filter?
On Dec 6, 2008, at 10:43 PM, Stephen C. Gilardi wrote: The following separation into two functions appears to solve it. I'll be looking at simplifying it. Well it doesn't run out of memory, but it's not an implementation of filter either... ah well. --Steve smime.p7s Description: S/MIME cryptographic signature
Re: Running out of memory when using filter?
On Dec 6, 2008, at 10:52 PM, Mark Engelberg wrote: Except your version of filter doesn't do any filtering on the rest in the case where the first satisfies the predicate. Right. It's looking to me now like this may have to be solved in Java. I don't see how to write this in Clojure without retaining coll through the entire implementation of filter--including the call to (filter pred (rest coll)) and that's enough to make it fail. --Steve smime.p7s Description: S/MIME cryptographic signature
Re: Running out of memory when using filter?
Well, part of the puzzle is to figure out why filter works just fine on the output of the range function, but not on the output of the map function. I'm starting to wonder whether there might be a fundamental bug in the java implementation of LazyCons. Maybe it doesn't implement first correctly? On Sat, Dec 6, 2008 at 7:59 PM, Stephen C. Gilardi [EMAIL PROTECTED] wrote: Right. It's looking to me now like this may have to be solved in Java. I don't see how to write this in Clojure without retaining coll through the entire implementation of filter--including the call to (filter pred (rest coll)) and that's enough to make it fail. --Steve --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Running out of memory when using filter?
OK, I see what you're saying now. Range doesn't cause problems because it's not coded in a way that links to a bunch of other cells. So it's plausible that the problem is the way filter hangs on to the collection while generating the rest (since it's not a tail-recursive call in that case). This is a real problem. It means that a whole range of things can't be coded naturally with lazy sequences. Maybe LazyCons shouldn't cache. Make LazyCons something that executes its function every time. For most things, it's not a problem because sequences are often traversed only once. If a person wants to cache it for multiple traversals, he can explicitly call cache-seq on 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure Blogs | Yahoo Pipes | Clojure Pipe
On Sat, Dec 6, 2008 at 2:42 PM, Chouser [EMAIL PROTECTED] wrote: On Sat, Dec 6, 2008 at 4:24 PM, bc [EMAIL PROTECTED] wrote: A lot of people are writing Clojure-related blog posts; however, I am often only interested in the Clojure posts they do and not the other posts. Thanks, this is a great idea. At the risk of sounding self-absorbed, though, I noticed that although my blog appears to be included in that diagram, none of my blog posts appear in the feed. I couldn't figure out how to examine the pipe to see the source of the problem. My filter is pretty simplistic (I search for the word clojure in a post), so that may account for some blog posts not appearing in the feed. I did notice one of your posts in the feed (Writing a macro: for vs. doseq). I haven't found any way to increase the number of posts returned by the pipe, so it may be that your earlier (Is it hard to write a GUI in Clojure?) post wasn't included because it was older than other posts. Your other posts were quite a bit older. However, if one subscribes to the feed in a newsreader, one should pick up any new Clojure-related posts on any of the blogs. So, now we can eagerly await a new blog post from you to test the pipe! ;-) - Bill --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure Blogs | Yahoo Pipes | Clojure Pipe
On Sat, Dec 6, 2008 at 2:11 PM, Randall R Schulz [EMAIL PROTECTED] wrote: On Saturday 06 December 2008 13:24, bc wrote: Hi all, A lot of people are writing Clojure-related blog posts; however, I am often only interested in the Clojure posts they do and not the other posts. Therefore, I've created a mashup of clojure-related blog posts using Yahoo Pipes. The description is here: http://bc.tech.coop/blog/081206.html If you want to view the blogs or subscribe to the feeds, the url is: feed://pipes.yahoo.com/pipes/pipe.run?_id=4cc8ebb9ae0b852d6ab7d94956c e2638_render=rss Fascinating. Is that diagram generated by Yahoo! Pipes itself, or did you draw it? It's generated by Yahoo Pipes itself, not me. Also, what is the feed: scheme? When I click those links (in Firefox on my Linux system), nothing happens. What sort of application supports it? For whatever reason, Akregator (KDE-based RSS feed aggregator) does not like that URL. It's used by newsreaders. Most modern browsers recognize it too. I think you can just change feed: to http: and the same url will work in some browsers. - Bill --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: My Clojure Emacs Setup (I'll show mine if you show yours)
On Fri, Dec 5, 2008 at 5:23 PM, Mon Key [EMAIL PROTECTED] wrote: Nice blog entry :) Thanks! :) My setup tends to mirror yours esp. as I've culled most of it from your blog over the years... Most of my startup scripts are modified versions of those you've shared elsewhere. Glad you've found my posts useful. - Bill --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Running out of memory when using filter?
On Dec 6, 8:38 pm, puzzler [EMAIL PROTECTED] wrote: Maybe LazyCons shouldn't cache. Make LazyCons something that executes its function every time. For most things, it's not a problem because sequences are often traversed only once. If a person wants to cache it for multiple traversals, he can explicitly call cache-seq on it. Is caching really the problem here? I'm curious. Looking at LazyCons.java, I see that it uses an IFn f generate the rest, and saves the value (a seq) in _rest. I assume that the function f is what is actually holding a reference to the whole collection (it may actually be the version of the function that the _rest contains, but I'll get there in a moment). At this point, once we have a value for _first and _rest, it doesn't seem like there's any value to having a reference to f. The code seems to agree with me, because once _rest has been set, it sets f to null. However, clearly there is still a problem here, based on all the different code samples in the thread which exhibit the bad behavior. I'm just not sure which of our analyses are correct yet, either. --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Running out of memory when using filter?
I'm also running into, what I believe to be, the same problem. Every time I run the following code I get java.lang.OutOfMemoryError: Java heap space. (use 'clojure.contrib.duck-streams) (count (line-seq (reader big.csv))) If I change count to dorun then it will return without problem. I uploaded a file called bigcsv.zip which contains the big.csv file. As Gilardi pointed out to me in #clojure a text file with a million line feeds would probably have sufficed too, but I already uploaded it so take your pick. --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: memory issue with nth
I also have this problem, unless I set my heap to be substantial - going up in increments of 128M, I need to have at least a 768M heap for this to not occur. That seems completely crazy, but the rest of you are saying you don't have this issue. Maybe it's time to start looking at what platforms we are running, and how much memory you have the JVM configured to use? If people have their heap set to be large enough, they might not realize this is happening, or if it is a bug on a subset of platforms, then that might explain it as well. I'm running on OS X Leopard, and I've tried both the 1.5 and 1.6 JVMs. I don't normally pass any non-standard memory size arguments to the VM unless I expect I'll need it for something I'm doing. --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Running out of memory when using filter?
On Sun, Dec 7, 2008 at 1:16 AM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I'm also running into, what I believe to be, the same problem. Every time I run the following code I get java.lang.OutOfMemoryError: Java heap space. (use 'clojure.contrib.duck-streams) (count (line-seq (reader big.csv))) If I change count to dorun then it will return without problem. I think I can reproduce this one like so: user= (count (take 15000 (iterate #(str % more) some))) java.lang.OutOfMemoryError: Java heap space (NO_SOURCE_FILE:0) As with yours, I can replace 'count' with 'dorun' and it works fine. I can also use 'last': user= (.length (last (take 15000 (iterate #(str % more) some) 6 I think the problem in this case is 'count', which for all IPersistentCollections (including lazy sequences) calls the 'count' method of the instance. ASeq's count method is a tight for() loop, but since it's an instance method it must retain a 'this' reference to the head of the seq. Fixing this is hard becasue RT.count() is holding onto the head as well. I've attached a patch that fixes the problem, but it's pretty ugly, perhaps only useful to demonstrate that this is the problem. --Chouser --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~--- diff --git a/src/jvm/clojure/lang/RT.java b/src/jvm/clojure/lang/RT.java index 49550b7..11dd151 100644 --- a/src/jvm/clojure/lang/RT.java +++ b/src/jvm/clojure/lang/RT.java @@ -482,6 +482,15 @@ static public IPersistentMap meta(Object x){ public static int count(Object o){ if(o == null) return 0; + else if(o instanceof LazyCons) + { + int i = 0; + for( ; o != null; o = ((ISeq )o).rest(), i++) + ; + return i; + } + else if(o instanceof IPersistentCollection) + return ((IPersistentCollection) o).count(); else if(o instanceof IPersistentCollection) return ((IPersistentCollection) o).count(); else if(o instanceof String)
Re: memory issue with nth
On Dec 7, 11:18 am, Paul Mooser [EMAIL PROTECTED] wrote: I also have this problem, unless I set my heap to be substantial - going up in increments of 128M, I need to have at least a 768M heap for this to not occur. That seems completely crazy, but the rest of you are saying you don't have this issue. I am not seeing this problem. I set the heapsize down to 32M but this still works. [parth:~]% java -Xmx32M -cp /home/parth/src/clojure/clojure.jar clojure.main Clojure user= (nth (repeatedly (fn [] 0)) 1000) 0 user= (.maxMemory (Runtime/getRuntime)) 33357824 user= (nth (repeatedly (fn [] 0)) 1) 0 user= (System/getProperty java.version) 1.6.0_07 user= This is on debian. Parth Maybe it's time to start looking at what platforms we are running, and how much memory you have the JVM configured to use? If people have their heap set to be large enough, they might not realize this is happening, or if it is a bug on a subset of platforms, then that might explain it as well. I'm running on OS X Leopard, and I've tried both the 1.5 and 1.6 JVMs. I don't normally pass any non-standard memory size arguments to the VM unless I expect I'll need it for something I'm doing. --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: memory issue with nth
I run Java 6 on Unbuntu with an initial heap size of 500M and a maximum of 1G. I never use the default allocations. $ java -version java version 1.6.0_03 Java(TM) SE Runtime Environment (build 1.6.0_03-b05) Java HotSpot(TM) Server VM (build 1.6.0_03-b05, mixed mode) user= (time (nth (repeatedly (fn [] 0)) 1000)) Elapsed time: 150984.333662 msecs 0 I tested restricting the maximum heap size to 128M, no problem at all: $ clojure /tmpfs/clojure/clojure-contrib.jar:/home/lprefontaine/.clojure/lib . /tmpfs/clojure/clojure.jar rlwrap --remember -c -b (){}[],^%0@;:''|\ -f /home/lprefontaine/.clojure/.clj_completions java -Dpid=11051 -client -Xms128m -Xmx128m -XX:+UseConcMarkSweepGC -XX: +HeapDumpOnOutOfMemoryError -cp .:/tmpfs/clojure/clojure.jar clojure.lang.Repl Clojure user= (time (nth (repeatedly (fn [] 0)) 1000)) Elapsed time: 1211.868876 msecs 0 user= (time (nth (repeatedly (fn [] 0)) 1000)) Elapsed time: 128680.557706 msecs 0 user= Increasing the # of iterations still works for me with a 128M heap. I refreshed my Clojure version from CVS today (Saturday). Luc On Sat, 2008-12-06 at 22:18 -0800, Paul Mooser wrote: I also have this problem, unless I set my heap to be substantial - going up in increments of 128M, I need to have at least a 768M heap for this to not occur. That seems completely crazy, but the rest of you are saying you don't have this issue. Maybe it's time to start looking at what platforms we are running, and how much memory you have the JVM configured to use? If people have their heap set to be large enough, they might not realize this is happening, or if it is a bug on a subset of platforms, then that might explain it as well. I'm running on OS X Leopard, and I've tried both the 1.5 and 1.6 JVMs. I don't normally pass any non-standard memory size arguments to the VM unless I expect I'll need it for something I'm doing. --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---