Re: Clojure.contrib: name changes in monads
On 18.02.2009, at 22:40, jim wrote: > Here's an updated state-m monad transformer. I dropped my CA in the > mail today. I figure if I post a snippet of code to the list, it's > public domain, so do with it as you wish. Or wait till Rich gets my > CA. Thanks! It's in my working copy of the monads library module already, and I will check it in when I see your name on the contributors' list. I'll be absent for a few days anyway, so it hardly makes a difference. Konrad. --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: how to learn clojure ?
I agree with this. Clojure is significantly different than Common Lisp and Scheme, so reading On Lisp and Practical Common Lisp are going to cover a bunch of stuff not relevant to Clojure. The Prag Prog book, Programming Clojure, covers pretty much everything you need to know about Lisp, at least enough to get started with Clojure. After you've started to get the hang of Clojure from reading that book, then maybe go back and give SICP, On Lisp or Practical Common Lisp a try. On Wed, Feb 18, 2009 at 7:51 PM, Jeffrey Straszheim < straszheimjeff...@gmail.com> wrote: > The Common Lisp and Scheme books suggested are great, of course, > particularly _On Lisp_. However, I think learning CL or Scheme is an > awfully roundabout way to learn Clojure. > > I think we should really be pushing the Pragmatic book. It is good and > gets the user to Clojure in a straight line. > > > On Wed, Feb 18, 2009 at 6:11 PM, Timothy Pratley > wrote: > >> >> If you want to dive straight into Clojure I hope this might help: >> http://en.wikibooks.org/wiki/Clojure_Programming/By_Example >> >> >> > > > > --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Curiousity with dorun
In the definition of dorun: (defn dorun "When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. dorun can be used to force any effects. Walks through the successive nexts of the seq, does not retain the head and returns nil." ([coll] (when (and (seq coll) (or (first coll) true)) (recur (next coll ([n coll] (when (and (seq coll) (pos? n) (or (first coll) true)) (recur (dec n) (next coll) Why do we evaluate (or (first coll) true) instead of just calling it after the when? ie. (when (seq coll) (first coll) (recur (next coll)) I only bring this up because compiling with assert-if-lazy-seq=true and running something like: (doall (map range (repeat 0) (range 10))) brings up a lazy seq exception. --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Fully lazy sequences are here!
Thanks Rich! Do you think it's worthwhile to add `not-empty?' in the core? It just feels more natural to go: (when (not-empty? (filter even? [1 2])) ...) over (when (seq (filter ..)) ..) What do you think? - Mike On Feb 17, 11:43 am, Rich Hickey wrote: > I've merged the lazy branch into trunk, SVN rev 1287 > > Please do not rush to this version unless you are a library/tool > developer. Let them do their ports and chime in on their progress. > Move only when the libs/tools you depend upon have been ported. > > Thanks to all for your feedback and input! > > Rich --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Bug in clojure.contrib.lazy-xml: apostrophe not escaped correctly
On Wed, Feb 18, 2009 at 6:20 PM, Stephan Mühlstrasser wrote: > > user=> (use 'clojure.contrib.lazy-xml) > nil > user=> (emit { :tag :a, :attrs { :b "bloody apostrophe's :-)" }}) > > > nil Fixed, thanks for the report. --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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: how to learn clojure ?
Seeing this topic comes up a bit, I've taken the liberty of compiling a wiki list: http://en.wikibooks.org/wiki/Clojure_Programming/Further_Reading Please feel free to add to it. I noticed that the official FAQ http://code.google.com/p/clojure/wiki/FAQ has a few links on Lisp, but I think the Clojure specific ones are useful and a comprehensive list wont fit on the FAQ. Maybe the official FAQ can be linked to it. PS: How come the FAQ has no link from the front page? ;) Regards, Tim. --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Yet another "how do I make gen-class work?" thread
On Feb 18, 9:02 pm, Stuart Sierra wrote: > On Feb 18, 7:49 pm, mikel wrote: > > > (I assume there must be something simple I'm not noticing about how to > > set up my classpath properly). > > An attempt to make things clear... > > There are two directories involved in gen-class compilation: > 1. your sources dir > 2. your compiled files dir, which is set in the Java system property > "clojure.compile.path". This was the issue; setting clojure.compile.path made everything wonderful; thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Yet another "how do I make gen-class work?" thread
On Feb 18, 7:49 pm, mikel wrote: > (I assume there must be something simple I'm not noticing about how to > set up my classpath properly). An attempt to make things clear... There are two directories involved in gen-class compilation: 1. your sources dir 2. your compiled files dir, which is set in the Java system property "clojure.compile.path". The compiled dir must exist; Clojure will not create it. BOTH dirs must be on the classpath, like this: java \ -cp clojure.jar:/your/classes/dir:/your/sources/dir \ -Dclojure.compile.path=/your/classes/dir \ clojure.main Since your namespace is "xg.gf", there should be a file named /your/sources/dir/xg/gf.clj However, the "standard" way to use gen-class is to have a namespace with the same name as the resulting Java class, like this: In the file "/your/sources/dir/xg/gf/GenericFunction.clj": (ns xg.gf.GenericFunction (:gen-class :extends clojure.lang.AFn)) Now (compile 'xg.gf.GenericFunction) will generate a Java class named "xg.gf.GenericFunction". When THAT class is loaded later on, it will use the functions defined in the Clojure namespace "xg.gf.GenericFunction". It's important to remember that gen-class really only generates a stub class, which dynamically loads a Clojure namespace (from source or compiled) and uses the definitions from that namespace. -Stuart Sierra --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: test-is integration via SLIME
That's really nifty, Phil! I'll have to check it out. -Stuart Sierra On Feb 18, 7:07 pm, Phil Hagelberg wrote: > I've been cooking up a little tool to help with running tests using > test-is. It's a little cumbersome to need to switch back and forth > between the test buffer and the repl to see the test results, so I've > created an Emacs mode that actually overlays the results on top of the > test buffer itself. > > I've attached a screenshot of it in action. Basically it colors failing > "is" forms in red and erroring forms in brown. When you put the point in > a failing "is" form and press C-c ', it will show the failure message in > the minibuffer. > > I find it to be very useful when writing tests to be able to get instant > feedback. And if it's easier to write tests, hopefully that means more > tests will get written. =) > > http://github.com/technomancy/clojure-mode/blob/ef0f8f73a1b282aa28d16... > > Please try it out if you use SLIME and let me know how it works for > you. One serious caveat is that swank-clojure hasn't been updated to > work with clojure-trunk yet, so you'll need to use slightly older > versions of everything. Here's what I've got: > > Clojure: git://github.com/kevinoneill/clojure.git revision d866f14 > Contrib: git://github.com/technomancy/clojure-contrib.git revision 4802d99 > Swank-clojure: git://github.com/jochu/swank-clojure.git revision 581954d > SLIME: git://github.com/nablaone/slime.git revision 5b8cb89 > > Hopefully the dust will settle soon, but for you've got to step lightly. > > -Phil > > clojure-test-mode.png > 59KViewDownload --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: how to learn clojure ?
The Common Lisp and Scheme books suggested are great, of course, particularly _On Lisp_. However, I think learning CL or Scheme is an awfully roundabout way to learn Clojure. I think we should really be pushing the Pragmatic book. It is good and gets the user to Clojure in a straight line. On Wed, Feb 18, 2009 at 6:11 PM, Timothy Pratley wrote: > > If you want to dive straight into Clojure I hope this might help: > http://en.wikibooks.org/wiki/Clojure_Programming/By_Example > > > > --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Yet another "how do I make gen-class work?" thread
On Feb 18, 6:24 pm, mikel wrote: > On Feb 18, 5:57 pm, Laurent PETIT wrote: > > > > > When trying your code, I encounter the same problem ... > > > ... but what is the compiler error telling us ? > > > [clojure.lang.AFn] is not a class ? > > > ... maybe clojure.lang.AFn is ! > > > Let's try > > > (gen-class > > :name xg.gf.GenericFunction > > :extends clojure.lang.AFn > > ) > > > (get rid of the square brackets !) > > > It's sometimes weird how we just want to see what we want to see ! It took > > me almost 10 minutes to find what was just in front of me ! :-) > > Se what's in front of you this time :-) > > I remove the brackets and get a different error: > > java.io.IOException: No such file or directory (gf.clj:7) > [Thrown class clojure.lang.Compiler$CompilerException] (I assume there must be something simple I'm not noticing about how to set up my classpath properly). --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Yet another "how do I make gen-class work?" thread
On Feb 18, 5:57 pm, Laurent PETIT wrote: > When trying your code, I encounter the same problem ... > > ... but what is the compiler error telling us ? > > [clojure.lang.AFn] is not a class ? > > ... maybe clojure.lang.AFn is ! > > Let's try > > (gen-class > :name xg.gf.GenericFunction > :extends clojure.lang.AFn > ) > > (get rid of the square brackets !) > > It's sometimes weird how we just want to see what we want to see ! It took > me almost 10 minutes to find what was just in front of me ! :-) Se what's in front of you this time :-) I remove the brackets and get a different error: java.io.IOException: No such file or directory (gf.clj:7) [Thrown class clojure.lang.Compiler$CompilerException] --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Yet another "how do I make gen-class work?" thread
When trying your code, I encounter the same problem ... ... but what is the compiler error telling us ? [clojure.lang.AFn] is not a class ? ... maybe clojure.lang.AFn is ! Let's try (gen-class :name xg.gf.GenericFunction :extends clojure.lang.AFn ) (get rid of the square brackets !) It's sometimes weird how we just want to see what we want to see ! It took me almost 10 minutes to find what was just in front of me ! :-) -- Laurent 2009/2/19 mikel > > So I'm looking at improving the implementation of generic functions, > preparatory to making the library more generally available. One thing > I ought to do, I think, is make a Java class, GenericFunction, a > sibling to MultFn. GenericFunction's role is basically the same as > MultiFn's, it just has a different approach to dispatch. > > Now, of course I could write GenericFunction in Java, just as MultiFn > is written in Java, but I thought it would be nice to use Clojure's > Java interop features to do it. I haven't tried using gen-class > before, though, and things are going a bit haywire. Maybe someone can > point out where I've gone wrong. Some code and other diagnostic info > is below. Let me know what else I need to provide. > > (ns xg.gf) > > (gen-class > :name xg.gf.GenericFunction > :extends [clojure.lang.AFn] > ) > > user> (compile 'xg.gf) > > java.lang.ClassNotFoundException: [clojure/lang/AFn] (gf.clj:7) > [Thrown class clojure.lang.Compiler$CompilerException] > > > user> (. System (getProperty "java.class.path")) > > "/usr/local/clojure/trunk/clojure.jar:/usr/local/clojure/clojure- > contrib/trunk/clojure-contrib.jar:...:/Users/mikel/Valise/guild/trunk/ > software/clojure" > > caeneshluura:clojure mikel$ pwd > /Users/mikel/Valise/guild/trunk/software/clojure > > caeneshluura:clojure mikel$ ls > ./ xg/ > ../ classes/ > > /Users/mikel/Valise/guild/trunk/software/clojure/xg/gf.clj > /Users/mikel/Valise/guild/trunk/software/clojure/classes/xg/gf/ > > > > > -- Cordialement, Laurent PETIT --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: My SLIME installation diary
David writes: > I can't really claim to be handy with elisp, but I got by. > (Is there a guide to elisp functions anywhere? The Lisp > reference didn't include the Common Lisp emulation library, > and I never did find an equivalent to the clojure filter()). The Elisp CL emulation package is documented in its own top-level Info node for some reason rather than in the Elisp manual. > Anyway, here's what I added to my .emacs: > > (defun add-slime-mode-to-existing-buffers () > (interactive) > (let ((clojure-buffers (remove-if-not 'is-clojure-buffer (buffer- > list > (dolist (b clojure-buffers) > (set-buffer b) > (slime-mode > (eval-after-load 'slime '(add-slime-mode-to-existing-buffers)) Cool! It's a little simpler to check for the value of the major-mode local variable rather than to use the filename, so here's what I ended up with: (defun clojure-enable-slime-on-existing-buffers () (interactive) (dolist (buffer (buffer-list)) (if (equal '(major-mode . clojure-mode) (assoc 'major-mode (buffer-local-variables buffer))) (with-current-buffer buffer (slime-mode t) > Let me know if you add it to your repository. I've committed this to my copy, but I don't know when it will go upstream to the mainline clojure-mode branch, as the maintainer has been out of communication for some time. http://github.com/technomancy/clojure-mode/ > There could conceivably be some issues with multiple slime > connections, or with running slime-mode repeatedly on the same > buffer. I couldn't find any easy way to determine if a buffer already > had slime-mode -- love to hear from someone who is actually handy > with elisp! Calling slime-mode with an argument of t forces it to enable rather than toggling it. I don't know about multiple slime connections though; it seems kind of edge-casey, though I can look into it if it causes problems. Thanks for getting the ball rolling on this. -Phil --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Problem with clojure.xml/emit: unnecessary whitespace added
clojure.xml/emit adds newlines before and after the content of an element, and as far as I can see there is no way to suppress it: user=> (use 'clojure.xml) nil user=> (emit {:tag :a, :content ["b"]}) b nil As whitespace within XML elements is significant, I think that emit should not add newlines in front and after the actual content. clojure.contrib.lazy-xml/emit behaves like I would expect: user=> (use 'clojure.contrib.lazy-xml) nil user=> (emit {:tag :a, :content ["b"]}) b nil I think clojure.xml/emit should behave in the same way as clojure.contrib.lazy-xml/emit regarding additional whitespace. Regards Stephan --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Bug in clojure.contrib.lazy-xml: apostrophe not escaped correctly
Hi, I believe the following is a bug in clojure.contrib.lazy-xm: user=> (use 'clojure.contrib.lazy-xml) nil user=> (emit { :tag :a, :attrs { :b "bloody apostrophe's :-)" }}) nil The XML is broken, because the embedded apostrophe in attribute b is not replaced with an XML entity. The apostrophe must be added to the characters to be escaped. Changing line 125 in lazy-xml.clj to the following fixed it for me: (def escape-xml-map {\< "<" \> ">" \" """ \& "&" \' "'"}) Expected result: user=> (use 'clojure.contrib.lazy-xml) nil user=> (emit { :tag :a, :attrs { :b "bloody apostrophe's :-)" }}) nil Regards Stephan --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Yet another "how do I make gen-class work?" thread
So I'm looking at improving the implementation of generic functions, preparatory to making the library more generally available. One thing I ought to do, I think, is make a Java class, GenericFunction, a sibling to MultFn. GenericFunction's role is basically the same as MultiFn's, it just has a different approach to dispatch. Now, of course I could write GenericFunction in Java, just as MultiFn is written in Java, but I thought it would be nice to use Clojure's Java interop features to do it. I haven't tried using gen-class before, though, and things are going a bit haywire. Maybe someone can point out where I've gone wrong. Some code and other diagnostic info is below. Let me know what else I need to provide. (ns xg.gf) (gen-class :name xg.gf.GenericFunction :extends [clojure.lang.AFn] ) user> (compile 'xg.gf) java.lang.ClassNotFoundException: [clojure/lang/AFn] (gf.clj:7) [Thrown class clojure.lang.Compiler$CompilerException] user> (. System (getProperty "java.class.path")) "/usr/local/clojure/trunk/clojure.jar:/usr/local/clojure/clojure- contrib/trunk/clojure-contrib.jar:...:/Users/mikel/Valise/guild/trunk/ software/clojure" caeneshluura:clojure mikel$ pwd /Users/mikel/Valise/guild/trunk/software/clojure caeneshluura:clojure mikel$ ls ./ xg/ ../ classes/ /Users/mikel/Valise/guild/trunk/software/clojure/xg/gf.clj /Users/mikel/Valise/guild/trunk/software/clojure/classes/xg/gf/ --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Creating executable Jars?
Hi Emeka, Where Lucio says: "after that I execute this command in the same folder (c:\user \classes): " I had success if I instead followed: "after that I execute this command in the same folder (c:\user\apps \classes): " Adding the c:\user\apps\classes directory to your classpath is mandatory, otherwise the (compile) step won't work. I saw another thread where Rich advised creating a jar file with the .clj source inside instead: http://groups.google.com/group/clojure/browse_thread/thread/e45be60b8f7a4d16/356b1cf2a2701bbd?lnk=gst&q=compiling+clj+jar#356b1cf2a2701bbd This sounds like the better way to go. Kev On Feb 17, 11:09 pm, Emeka wrote: > Kev, > > I didn't make it, however, I guess the issue was on namespace and not on > the instruction given. I will try again and again until I get my head around > namespace, or could you help me to jump start? > > Emeka On Feb 17, 11:09 pm, Emeka wrote: > Kev, > > I didn't make it, however, I guess the issue was on namespace and not on > the instruction given. I will try again and again until I get my head around > namespace, or could you help me to jump start? > > 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: how to learn clojure ?
If you want to dive straight into Clojure I hope this might help: http://en.wikibooks.org/wiki/Clojure_Programming/By_Example --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure on CLR/DLR
"like any other .NET application" means "needs the .NET runtime.", but does not need Visual Studio or inserting Tab A into Slot B to get it all to work. On Feb 18, 11:51 am, Marko Kocić wrote: > On 18 феб, 15:13, dmiller wrote: > > > When the rough edges are filed off, it should distributable as a set > > of DLLs (and a console EXE) like any other .NET application. It > > should be able to follow the DLR to Mono. > > You mean DLR can create executables that don't need .NET runtime? --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure documentation for offline use?
This is great Kresimir. I've wanted to do this for a while, but gave up after a very short attempt back in November. Expanding your ant task so that others can use it without deciphering everything if they want to: wget -krmnp -E -X/page,/message --no-check-certificate -P https://clojure.org replace target with the directory where you want the output and you're off to the races. Tom On Feb 18, 11:30 am, Krešimir Šojat wrote: > If you want offline version of clojure.org: > > hg clonehttps://bitbucket.org/ksojat/truba/ > cd truba > ant clojure-org-download > (requires wget) > > When finished, it will place it in dist/clojure.org directory. > Or you can just copy wget command from clojure-org-download target. > > -- > Krešimir Šojat --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: My SLIME installation diary
I can't really claim to be handy with elisp, but I got by. (Is there a guide to elisp functions anywhere? The Lisp reference didn't include the Common Lisp emulation library, and I never did find an equivalent to the clojure filter()). Anyway, here's what I added to my .emacs: (defun find-ext-for-mode (m) (let (modes) (dolist (ext auto-mode-alist modes) (if (eq (cdr ext) m) (add-to-list 'modes (car ext)) ; (find-ext-for-mode 'clojure-mode) (defun is-clojure-buffer (b) (let ((regexes (find-ext-for-mode 'clojure-mode))) (find-if (lambda (regex) (string-match regex (buffer-name b))) regexes))) (defun add-slime-mode-to-existing-buffers () (interactive) (let ((clojure-buffers (remove-if-not 'is-clojure-buffer (buffer- list (dolist (b clojure-buffers) (set-buffer b) (slime-mode (eval-after-load 'slime '(add-slime-mode-to-existing-buffers)) Let me know if you add it to your repository. There could conceivably be some issues with multiple slime connections, or with running slime-mode repeatedly on the same buffer. I couldn't find any easy way to determine if a buffer already had slime-mode -- love to hear from someone who is actually handy with elisp! On Feb 13, 4:39 pm, Phil Hagelberg wrote: > David writes: > > I have a small problem with clojure-mode in your setup. > > > Since clojure-mode is autoloaded, it, and SLIME, aren't available > > until I load a '.clj' file. > > Starting SLIME, though, doesn't add the SLIME menu to the previously > > loaded '.clj' buffer > > (Newly loaded files get the menu, as they should). > > Yeah, I've thought about a hook that runs after SLIME loads to activate > slime-mode for all pre-existing clojure-mode buffers; just haven't > gotten around to it. > > If you're handy with elisp, I'd love a patch, otherwise I'll get around > to it eventually. =) > > -Phil --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure.contrib: name changes in monads
I like that. It makes it clear what is a monad, and what is not. On Wed, Feb 18, 2009 at 3:24 AM, Konrad Hinsen wrote: > > The latest Clojure version broke many of my code by introducing the > function sequence whose name collided with my sequence monad. So I > decided that since now is the time for breaking changes, I should > solve that kind of problem thoroughly. I just renamed all monads in > clojure.contrib.monads and clojure.contrib.probabilities, the names > now have a -m suffix: sequence-m, maybe-m, etc. > > Konrad. > > > > --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Datalog update
Makes sense. That would work. It certainly looks cleaner. On Wed, Feb 18, 2009 at 4:51 PM, Rich Hickey wrote: > > > > On Feb 18, 4:32 pm, Jeffrey Straszheim > wrote: > > Easy enough to do. The only drawback is I'd probably want to force it > into > > a hash during the query. For large datasets (say 100,000 records) this > > might get expensive. > > > > What I envisioned was that while this was the logical db, 'inserting' > any tuple would also add it to internal indexes, including of course a > default index on relname. You'd declare which other keys to index, and > how (sorted/hashed) when creating the db. > > Rich > > > On Wed, Feb 18, 2009 at 4:13 PM, Rich Hickey > wrote: > > > > > On Feb 18, 3:51 pm, Jeffrey Straszheim > > > wrote: > > > > Yes. I've been thinking about a database layer that would support > > > indexing, > > > > constraints, and so on. One step at a time. > > > > > Maybe I wasn't clear, I'm talking about the foundational layer. > > > Instead of: > > > > > (def data { > > > :table-1 #{ { :x 34 :y 33 } { :x 33 :y :fred } { :x "k" :y \u } } > > > :table-2 #{ { :a "fred" :b "mary" } { :a "sally" :b "joan" } } > > > }) > > > > > I'm recommending: > > > > > (def data > > > #{{:rel :table-1 :x 34 :y 33 } > > > {:rel :table-1 :x 33 :y :fred } > > > {:rel :table-1 :x "k" :y \u } > > > {:rel :table-2 :a "fred" :b "mary"} > > > {:rel :table-2 :a "sally" :b "joan" }}) > > > > > i.e. making relation and rule names non-special. > > > > > Rich > > > > > > (logic-rule (:fred :x ?x :y ?y) - (:sally :x ?x :z ?z) ("becky" :y > ?y) > > > >(not! :janet :qqq ?z) (if < ?x > ?y)) > > > > > > Translated into positional notation (assuming the columns are named > in > > > the > > > > obvious way): > > > > > > fred(X,Y) :- sally(X,Z), becky(Y), ~Janet(Z), when X > > > > > The "<" symbol can be any Clojure callable. Its return value will be > > > > interpreted as a boolean. > > > > > > So, you'd get every X,Z from the relation sally, cross product with > every > > > Y > > > > from becky, remove each tuple that has a Z in janet, and also remove > any > > > > tuple where X relation > > > > fred. > > > > > > On Wed, Feb 18, 2009 at 3:23 PM, Rich Hickey > > > wrote: > > > > > > > On Feb 9, 8:46 am, Jeffrey Straszheim > > > > > > wrote: > > > > > > No, but I'm really learning as I go here. I'll look into it. > > > > > > > > On Mon, Feb 9, 2009 at 7:58 AM, Rich Hickey < > richhic...@gmail.com> > > > > > wrote: > > > > > > > > > Looks like you're moving apace! > > > > > > > > > Have you considered query/subquery optimization instead of > magic > > > sets? > > > > > > > > > Rich > > > > > > > > > On Feb 8, 7:51 pm, Jeffrey Straszheim < > straszheimjeff...@gmail.com > > > > > > > > > wrote: > > > > > > > > By the way, if anyone on this list has experience > implementing > > > > > bottom-up > > > > > > > > optimizations for logic programs, particularly from the magic > set > > > > > family, > > > > > > > > and is willing to assist, please contact me. > > > > > > > > > > On Sun, Feb 8, 2009 at 7:47 PM, Jeffrey Straszheim < > > > > > > > > > > straszheimjeff...@gmail.com> wrote: > > > > > > > > > > > Stratified negation is working and in trunk. > > > > > > > > > > > I have some cool ideas of a simple, but powerful, way to > > > implement > > > > > > > > > evaluable predicates. They'll likely make it in by > midweek. > > > > > > > > > > > The the hard part (magic sets) begins. > > > > > > > > > > > On Feb 8, 11:43 am, Jeffrey Straszheim < > > > > > straszheimjeff...@gmail.com> > > > > > > > > > wrote: > > > > > > > > > > I now have recursive queries working. My next 3 > milestones > > > are > > > > > > > > > stratified > > > > > > > > > > negation, evaluable predicates, and then some version of > > > magic > > > > > sets > > > > > > > > > > optimization. But now, as long as your queries are > > > non-negated > > > > > it is > > > > > > > > > > working. > > > > > > > > > > > >http://code.google.com/p/clojure-datalog/ > > > > > > > I got a chance to look at your docs: > > > > > > >http://code.google.com/p/clojure-datalog/wiki/BasicSyntax > > > > > > > I think your choice of using maps (we don't call them hashes in > > > > > Clojure as they might not be hash tables) is right on the money for > > > > > Clojure, especially set-of-maps-is-relation, just like clojure.set. > > > > > > > Two thoughts: > > > > > > > I wonder though if the map of rel-names to rels isn't a wart > though. > > > > > It's a pet peeve of mine that relation names don't end up in the db > > > > > like any other attribute. Yes, they'll need to be indexed, but > > > > > eventually you'll want to support indexing on any desired > attributes > > > > > as well. Putting relation names in the db gives you a uniform meta- > > > > > query capability. I haven't thought this all the way through, but > you > > > > > might want to think about it. > > > > > > > I didn't know how to interpre
Re: Datalog update
On Feb 18, 4:32 pm, Jeffrey Straszheim wrote: > Easy enough to do. The only drawback is I'd probably want to force it into > a hash during the query. For large datasets (say 100,000 records) this > might get expensive. > What I envisioned was that while this was the logical db, 'inserting' any tuple would also add it to internal indexes, including of course a default index on relname. You'd declare which other keys to index, and how (sorted/hashed) when creating the db. Rich > On Wed, Feb 18, 2009 at 4:13 PM, Rich Hickey wrote: > > > On Feb 18, 3:51 pm, Jeffrey Straszheim > > wrote: > > > Yes. I've been thinking about a database layer that would support > > indexing, > > > constraints, and so on. One step at a time. > > > Maybe I wasn't clear, I'm talking about the foundational layer. > > Instead of: > > > (def data { > > :table-1 #{ { :x 34 :y 33 } { :x 33 :y :fred } { :x "k" :y \u } } > > :table-2 #{ { :a "fred" :b "mary" } { :a "sally" :b "joan" } } > > }) > > > I'm recommending: > > > (def data > > #{{:rel :table-1 :x 34 :y 33 } > > {:rel :table-1 :x 33 :y :fred } > > {:rel :table-1 :x "k" :y \u } > > {:rel :table-2 :a "fred" :b "mary"} > > {:rel :table-2 :a "sally" :b "joan" }}) > > > i.e. making relation and rule names non-special. > > > Rich > > > > (logic-rule (:fred :x ?x :y ?y) - (:sally :x ?x :z ?z) ("becky" :y ?y) > > >(not! :janet :qqq ?z) (if < ?x ?y)) > > > > Translated into positional notation (assuming the columns are named in > > the > > > obvious way): > > > > fred(X,Y) :- sally(X,Z), becky(Y), ~Janet(Z), when X > > > The "<" symbol can be any Clojure callable. Its return value will be > > > interpreted as a boolean. > > > > So, you'd get every X,Z from the relation sally, cross product with every > > Y > > > from becky, remove each tuple that has a Z in janet, and also remove any > > > tuple where X > > fred. > > > > On Wed, Feb 18, 2009 at 3:23 PM, Rich Hickey > > wrote: > > > > > On Feb 9, 8:46 am, Jeffrey Straszheim > > > > wrote: > > > > > No, but I'm really learning as I go here. I'll look into it. > > > > > > On Mon, Feb 9, 2009 at 7:58 AM, Rich Hickey > > > > wrote: > > > > > > > Looks like you're moving apace! > > > > > > > Have you considered query/subquery optimization instead of magic > > sets? > > > > > > > Rich > > > > > > > On Feb 8, 7:51 pm, Jeffrey Straszheim > > > > > > wrote: > > > > > > > By the way, if anyone on this list has experience implementing > > > > bottom-up > > > > > > > optimizations for logic programs, particularly from the magic set > > > > family, > > > > > > > and is willing to assist, please contact me. > > > > > > > > On Sun, Feb 8, 2009 at 7:47 PM, Jeffrey Straszheim < > > > > > > > > straszheimjeff...@gmail.com> wrote: > > > > > > > > > Stratified negation is working and in trunk. > > > > > > > > > I have some cool ideas of a simple, but powerful, way to > > implement > > > > > > > > evaluable predicates. They'll likely make it in by midweek. > > > > > > > > > The the hard part (magic sets) begins. > > > > > > > > > On Feb 8, 11:43 am, Jeffrey Straszheim < > > > > straszheimjeff...@gmail.com> > > > > > > > > wrote: > > > > > > > > > I now have recursive queries working. My next 3 milestones > > are > > > > > > > > stratified > > > > > > > > > negation, evaluable predicates, and then some version of > > magic > > > > sets > > > > > > > > > optimization. But now, as long as your queries are > > non-negated > > > > it is > > > > > > > > > working. > > > > > > > > > >http://code.google.com/p/clojure-datalog/ > > > > > I got a chance to look at your docs: > > > > >http://code.google.com/p/clojure-datalog/wiki/BasicSyntax > > > > > I think your choice of using maps (we don't call them hashes in > > > > Clojure as they might not be hash tables) is right on the money for > > > > Clojure, especially set-of-maps-is-relation, just like clojure.set. > > > > > Two thoughts: > > > > > I wonder though if the map of rel-names to rels isn't a wart though. > > > > It's a pet peeve of mine that relation names don't end up in the db > > > > like any other attribute. Yes, they'll need to be indexed, but > > > > eventually you'll want to support indexing on any desired attributes > > > > as well. Putting relation names in the db gives you a uniform meta- > > > > query capability. I haven't thought this all the way through, but you > > > > might want to think about it. > > > > > I didn't know how to interpret this: > > > > > (logic-rule (:fred :x ?x :y ?y) - (:sally :x ?x :z ?z) ("becky" :y ?y) > > > >(not! :janet :qqq ?z) (if < ?x ? > > > > y)) > > > > > Overall, it looks very promising! > > > > > If you weren't aware of it: > > > > > Foundations of Databases: The Logical Level > > > > Serge Abiteboul, Richard Hull, Victor Vianu > > > > >http://www.amazon.com/gp/product/0201537710 > > > > > has good coverage of Datalog, including QSQ. > > > > > R
Re: Fully lazy sequences are here!
At this point test-clojure doesn't generate any new failures or errors (except the old 'mod' function failures). Coverage is still relatively small, but (cycle []) bug and case of (reverse []) were caught with its help when rewriting tests :-) Thanks for all the fixes! Frantisek On Feb 18, 8:02 pm, Rich Hickey wrote: > On Feb 18, 12:20 pm, Frantisek Sodomka wrote: > > > How should I say it... It just didn't look "symmetrical" to me. > > > So, basically, there is a difference between functions returning > > sequences - depending on if they are lazy or eager. Hmm... > > > user=> (reverse []) > > nil > > user=> (if (reverse []) true false) > > false > > user=> (if (seq (reverse [])) true false) > > false > > > user=> (lazy-seq nil) > > () > > user=> (seq (lazy-seq nil)) > > nil > > user=> (if (lazy-seq nil) true false) > > true > > user=> (if (seq (lazy-seq nil)) true false) > > false > > > As long as I remember which function is lazy and which one is eager, I > > should be fine then. > > > Just wanted to really understand it. > > It shouldn't be that subtle. Sequence functions shouldn't return nil > unless they are variants of seq/next. I've fixed reverse and sort to > return () when passed empty colls - SVN 1294. > > Rich. --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: (newbie) idiomatic way to update a vector/list
thanks, i thought (assoc map key val) only works for maps, but i should have read the doc more carefully. On Feb 18, 9:34 pm, James Reeves wrote: > On Feb 18, 8:25 pm, linh wrote: > > > hello, > > what is the idiomatic way to do the following in clojure? > > > # ruby pseudo > > arr = [3 9 4 5] > > arr[1] = 7 > > => (def arr [3 9 4 5]) > #'user/arr > => (assoc arr 1 7) > [3 7 4 5] > > Note that because Clojure data structures are immutable, assoc only > returns the changed value; it doesn't update arr. > > - James --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure.contrib: name changes in monads
Konrad, Here's an updated state-m monad transformer. I dropped my CA in the mail today. I figure if I post a snippet of code to the list, it's public domain, so do with it as you wish. Or wait till Rich gets my CA. (defn state-t [m] (monad [m-result (with-monad m (fn [v] (fn [s] (m-result (list v s) m-bind (with-monad m (fn [stm f] (fn [s] (m-bind (stm s) (fn [[v ss]] ((f v) ss)) m-zero (with-monad m (if (not= ::undefined m-zero) ::undefined (fn [s] m-zero))) m-plus (with-monad m (if (= ::undefined m-plus) ::undefined (fn [& stms] (fn [s] (apply m-plus (map #(% s) stms)) ])) Jim On Feb 18, 2:24 am, Konrad Hinsen wrote: > The latest Clojure version broke many of my code by introducing the > function sequence whose name collided with my sequence monad. So I > decided that since now is the time for breaking changes, I should > solve that kind of problem thoroughly. I just renamed all monads in > clojure.contrib.monads and clojure.contrib.probabilities, the names > now have a -m suffix: sequence-m, maybe-m, etc. > > Konrad. --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Parenscript in clojure?
I've got something that's pretty close. There are some other things in the queue before I can get it cleaned up and ready for public consumption, but I'm working towards that. Jim On Feb 18, 2:39 am, Jan Rychter wrote: > Is anyone working on a Parenscript > (http://common-lisp.net/project/parenscript/) for Clojure? > > If not, perhaps someone would like to start? :-) > > Parenscript is an incredibly useful Javascript generator which makes > writing web applications in Common Lisp much more pleasant. In > particular, it gives you macros in Javascript, which is unbelievably > useful. > > --J. --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Datalog update
Easy enough to do. The only drawback is I'd probably want to force it into a hash during the query. For large datasets (say 100,000 records) this might get expensive. On Wed, Feb 18, 2009 at 4:13 PM, Rich Hickey wrote: > > > > On Feb 18, 3:51 pm, Jeffrey Straszheim > wrote: > > Yes. I've been thinking about a database layer that would support > indexing, > > constraints, and so on. One step at a time. > > Maybe I wasn't clear, I'm talking about the foundational layer. > Instead of: > > (def data { > :table-1 #{ { :x 34 :y 33 } { :x 33 :y :fred } { :x "k" :y \u } } > :table-2 #{ { :a "fred" :b "mary" } { :a "sally" :b "joan" } } > }) > > I'm recommending: > > (def data > #{{:rel :table-1 :x 34 :y 33 } > {:rel :table-1 :x 33 :y :fred } > {:rel :table-1 :x "k" :y \u } > {:rel :table-2 :a "fred" :b "mary"} > {:rel :table-2 :a "sally" :b "joan" }}) > > i.e. making relation and rule names non-special. > > Rich > > > (logic-rule (:fred :x ?x :y ?y) - (:sally :x ?x :z ?z) ("becky" :y ?y) > >(not! :janet :qqq ?z) (if < ?x ?y)) > > > > Translated into positional notation (assuming the columns are named in > the > > obvious way): > > > > fred(X,Y) :- sally(X,Z), becky(Y), ~Janet(Z), when X > > > The "<" symbol can be any Clojure callable. Its return value will be > > interpreted as a boolean. > > > > So, you'd get every X,Z from the relation sally, cross product with every > Y > > from becky, remove each tuple that has a Z in janet, and also remove any > > tuple where X > fred. > > > > On Wed, Feb 18, 2009 at 3:23 PM, Rich Hickey > wrote: > > > > > On Feb 9, 8:46 am, Jeffrey Straszheim > > > wrote: > > > > No, but I'm really learning as I go here. I'll look into it. > > > > > > On Mon, Feb 9, 2009 at 7:58 AM, Rich Hickey > > > wrote: > > > > > > > Looks like you're moving apace! > > > > > > > Have you considered query/subquery optimization instead of magic > sets? > > > > > > > Rich > > > > > > > On Feb 8, 7:51 pm, Jeffrey Straszheim > > > > > > wrote: > > > > > > By the way, if anyone on this list has experience implementing > > > bottom-up > > > > > > optimizations for logic programs, particularly from the magic set > > > family, > > > > > > and is willing to assist, please contact me. > > > > > > > > On Sun, Feb 8, 2009 at 7:47 PM, Jeffrey Straszheim < > > > > > > > > straszheimjeff...@gmail.com> wrote: > > > > > > > > > Stratified negation is working and in trunk. > > > > > > > > > I have some cool ideas of a simple, but powerful, way to > implement > > > > > > > evaluable predicates. They'll likely make it in by midweek. > > > > > > > > > The the hard part (magic sets) begins. > > > > > > > > > On Feb 8, 11:43 am, Jeffrey Straszheim < > > > straszheimjeff...@gmail.com> > > > > > > > wrote: > > > > > > > > I now have recursive queries working. My next 3 milestones > are > > > > > > > stratified > > > > > > > > negation, evaluable predicates, and then some version of > magic > > > sets > > > > > > > > optimization. But now, as long as your queries are > non-negated > > > it is > > > > > > > > working. > > > > > > > > > >http://code.google.com/p/clojure-datalog/ > > > > > I got a chance to look at your docs: > > > > >http://code.google.com/p/clojure-datalog/wiki/BasicSyntax > > > > > I think your choice of using maps (we don't call them hashes in > > > Clojure as they might not be hash tables) is right on the money for > > > Clojure, especially set-of-maps-is-relation, just like clojure.set. > > > > > Two thoughts: > > > > > I wonder though if the map of rel-names to rels isn't a wart though. > > > It's a pet peeve of mine that relation names don't end up in the db > > > like any other attribute. Yes, they'll need to be indexed, but > > > eventually you'll want to support indexing on any desired attributes > > > as well. Putting relation names in the db gives you a uniform meta- > > > query capability. I haven't thought this all the way through, but you > > > might want to think about it. > > > > > I didn't know how to interpret this: > > > > > (logic-rule (:fred :x ?x :y ?y) - (:sally :x ?x :z ?z) ("becky" :y ?y) > > >(not! :janet :qqq ?z) (if < ?x ? > > > y)) > > > > > Overall, it looks very promising! > > > > > If you weren't aware of it: > > > > > Foundations of Databases: The Logical Level > > > Serge Abiteboul, Richard Hull, Victor Vianu > > > > >http://www.amazon.com/gp/product/0201537710 > > > > > has good coverage of Datalog, including QSQ. > > > > > Rich > > > --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Datalog update
On Feb 18, 3:51 pm, Jeffrey Straszheim wrote: > Yes. I've been thinking about a database layer that would support indexing, > constraints, and so on. One step at a time. Maybe I wasn't clear, I'm talking about the foundational layer. Instead of: (def data { :table-1 #{ { :x 34 :y 33 } { :x 33 :y :fred } { :x "k" :y \u } } :table-2 #{ { :a "fred" :b "mary" } { :a "sally" :b "joan" } } }) I'm recommending: (def data #{{:rel :table-1 :x 34 :y 33 } {:rel :table-1 :x 33 :y :fred } {:rel :table-1 :x "k" :y \u } {:rel :table-2 :a "fred" :b "mary"} {:rel :table-2 :a "sally" :b "joan" }}) i.e. making relation and rule names non-special. Rich > (logic-rule (:fred :x ?x :y ?y) - (:sally :x ?x :z ?z) ("becky" :y ?y) >(not! :janet :qqq ?z) (if < ?x ?y)) > > Translated into positional notation (assuming the columns are named in the > obvious way): > > fred(X,Y) :- sally(X,Z), becky(Y), ~Janet(Z), when X > The "<" symbol can be any Clojure callable. Its return value will be > interpreted as a boolean. > > So, you'd get every X,Z from the relation sally, cross product with every Y > from becky, remove each tuple that has a Z in janet, and also remove any > tuple where X fred. > > On Wed, Feb 18, 2009 at 3:23 PM, Rich Hickey wrote: > > > On Feb 9, 8:46 am, Jeffrey Straszheim > > wrote: > > > No, but I'm really learning as I go here. I'll look into it. > > > > On Mon, Feb 9, 2009 at 7:58 AM, Rich Hickey > > wrote: > > > > > Looks like you're moving apace! > > > > > Have you considered query/subquery optimization instead of magic sets? > > > > > Rich > > > > > On Feb 8, 7:51 pm, Jeffrey Straszheim > > > > wrote: > > > > > By the way, if anyone on this list has experience implementing > > bottom-up > > > > > optimizations for logic programs, particularly from the magic set > > family, > > > > > and is willing to assist, please contact me. > > > > > > On Sun, Feb 8, 2009 at 7:47 PM, Jeffrey Straszheim < > > > > > > straszheimjeff...@gmail.com> wrote: > > > > > > > Stratified negation is working and in trunk. > > > > > > > I have some cool ideas of a simple, but powerful, way to implement > > > > > > evaluable predicates. They'll likely make it in by midweek. > > > > > > > The the hard part (magic sets) begins. > > > > > > > On Feb 8, 11:43 am, Jeffrey Straszheim < > > straszheimjeff...@gmail.com> > > > > > > wrote: > > > > > > > I now have recursive queries working. My next 3 milestones are > > > > > > stratified > > > > > > > negation, evaluable predicates, and then some version of magic > > sets > > > > > > > optimization. But now, as long as your queries are non-negated > > it is > > > > > > > working. > > > > > > > >http://code.google.com/p/clojure-datalog/ > > > I got a chance to look at your docs: > > >http://code.google.com/p/clojure-datalog/wiki/BasicSyntax > > > I think your choice of using maps (we don't call them hashes in > > Clojure as they might not be hash tables) is right on the money for > > Clojure, especially set-of-maps-is-relation, just like clojure.set. > > > Two thoughts: > > > I wonder though if the map of rel-names to rels isn't a wart though. > > It's a pet peeve of mine that relation names don't end up in the db > > like any other attribute. Yes, they'll need to be indexed, but > > eventually you'll want to support indexing on any desired attributes > > as well. Putting relation names in the db gives you a uniform meta- > > query capability. I haven't thought this all the way through, but you > > might want to think about it. > > > I didn't know how to interpret this: > > > (logic-rule (:fred :x ?x :y ?y) - (:sally :x ?x :z ?z) ("becky" :y ?y) > >(not! :janet :qqq ?z) (if < ?x ? > > y)) > > > Overall, it looks very promising! > > > If you weren't aware of it: > > > Foundations of Databases: The Logical Level > > Serge Abiteboul, Richard Hull, Victor Vianu > > >http://www.amazon.com/gp/product/0201537710 > > > has good coverage of Datalog, including QSQ. > > > Rich --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: how to learn clojure ?
MarisO writes: > All documentation I've seen about clojure assumes knowledge of lisp > which I dont have. I'm working on a screencast for PeepCode (http://peepcode.com) that is aimed at teaching Clojure to users of other dynamic languages. It's not ready yet, but it should be on sale in a week or two. I'll be sure to announce it here when it is, of course. -Phil http://technomancy.us --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Contributing
On Wed, Feb 18, 2009 at 2:34 PM, Joshua wrote: > > I am currently in a masters level Compiler class. We have a final > project for the class and I was wondering if there would be any > defects/enhancements that I could do in Clojure. I have about 5 years > of professional Java experience with dabbling with some other > languages. (not an expert, but pretty good). The amount of work for > the project should be about 20-40 hours (I have a month). > > Please let me know of any suggestions. Perhaps these are too trivial, but it'd be nice to have them done: arity checking during compilation: http://code.google.com/p/clojure/issues/detail?id=17 A Lisp reader without access to EvalReader(): http://code.google.com/p/clojure/issues/detail?id=34 --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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Contributing
Did you cover logic programming? Any bottom up logic query techniques? (My motives are probably transparent.) On Wed, Feb 18, 2009 at 2:34 PM, Joshua wrote: > > I am currently in a masters level Compiler class. We have a final > project for the class and I was wondering if there would be any > defects/enhancements that I could do in Clojure. I have about 5 years > of professional Java experience with dabbling with some other > languages. (not an expert, but pretty good). The amount of work for > the project should be about 20-40 hours (I have a month). > > Please let me know of any suggestions. > > Joshua > > > > --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Datalog update
Yes. I've been thinking about a database layer that would support indexing, constraints, and so on. One step at a time. (logic-rule (:fred :x ?x :y ?y) - (:sally :x ?x :z ?z) ("becky" :y ?y) (not! :janet :qqq ?z) (if < ?x ?y)) Translated into positional notation (assuming the columns are named in the obvious way): fred(X,Y) :- sally(X,Z), becky(Y), ~Janet(Z), when X wrote: > > > > On Feb 9, 8:46 am, Jeffrey Straszheim > wrote: > > No, but I'm really learning as I go here. I'll look into it. > > > > On Mon, Feb 9, 2009 at 7:58 AM, Rich Hickey > wrote: > > > > > Looks like you're moving apace! > > > > > Have you considered query/subquery optimization instead of magic sets? > > > > > Rich > > > > > On Feb 8, 7:51 pm, Jeffrey Straszheim > > > wrote: > > > > By the way, if anyone on this list has experience implementing > bottom-up > > > > optimizations for logic programs, particularly from the magic set > family, > > > > and is willing to assist, please contact me. > > > > > > On Sun, Feb 8, 2009 at 7:47 PM, Jeffrey Straszheim < > > > > > > straszheimjeff...@gmail.com> wrote: > > > > > > > Stratified negation is working and in trunk. > > > > > > > I have some cool ideas of a simple, but powerful, way to implement > > > > > evaluable predicates. They'll likely make it in by midweek. > > > > > > > The the hard part (magic sets) begins. > > > > > > > On Feb 8, 11:43 am, Jeffrey Straszheim < > straszheimjeff...@gmail.com> > > > > > wrote: > > > > > > I now have recursive queries working. My next 3 milestones are > > > > > stratified > > > > > > negation, evaluable predicates, and then some version of magic > sets > > > > > > optimization. But now, as long as your queries are non-negated > it is > > > > > > working. > > > > > > > >http://code.google.com/p/clojure-datalog/ > > I got a chance to look at your docs: > > http://code.google.com/p/clojure-datalog/wiki/BasicSyntax > > I think your choice of using maps (we don't call them hashes in > Clojure as they might not be hash tables) is right on the money for > Clojure, especially set-of-maps-is-relation, just like clojure.set. > > Two thoughts: > > I wonder though if the map of rel-names to rels isn't a wart though. > It's a pet peeve of mine that relation names don't end up in the db > like any other attribute. Yes, they'll need to be indexed, but > eventually you'll want to support indexing on any desired attributes > as well. Putting relation names in the db gives you a uniform meta- > query capability. I haven't thought this all the way through, but you > might want to think about it. > > I didn't know how to interpret this: > > (logic-rule (:fred :x ?x :y ?y) - (:sally :x ?x :z ?z) ("becky" :y ?y) >(not! :janet :qqq ?z) (if < ?x ? > y)) > > > Overall, it looks very promising! > > If you weren't aware of it: > > Foundations of Databases: The Logical Level > Serge Abiteboul, Richard Hull, Victor Vianu > > http://www.amazon.com/gp/product/0201537710 > > has good coverage of Datalog, including QSQ. > > Rich > > > > --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: (newbie) idiomatic way to update a vector/list
On Feb 18, 8:25 pm, linh wrote: > hello, > what is the idiomatic way to do the following in clojure? > > # ruby pseudo > arr = [3 9 4 5] > arr[1] = 7 => (def arr [3 9 4 5]) #'user/arr => (assoc arr 1 7) [3 7 4 5] Note that because Clojure data structures are immutable, assoc only returns the changed value; it doesn't update arr. - James --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
(newbie) idiomatic way to update a vector/list
hello, what is the idiomatic way to do the following in clojure? # ruby pseudo arr = [3 9 4 5] arr[1] = 7 --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Contributing
I am currently in a masters level Compiler class. We have a final project for the class and I was wondering if there would be any defects/enhancements that I could do in Clojure. I have about 5 years of professional Java experience with dabbling with some other languages. (not an expert, but pretty good). The amount of work for the project should be about 20-40 hours (I have a month). Please let me know of any suggestions. Joshua --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Datalog update
On Feb 9, 8:46 am, Jeffrey Straszheim wrote: > No, but I'm really learning as I go here. I'll look into it. > > On Mon, Feb 9, 2009 at 7:58 AM, Rich Hickey wrote: > > > Looks like you're moving apace! > > > Have you considered query/subquery optimization instead of magic sets? > > > Rich > > > On Feb 8, 7:51 pm, Jeffrey Straszheim > > wrote: > > > By the way, if anyone on this list has experience implementing bottom-up > > > optimizations for logic programs, particularly from the magic set family, > > > and is willing to assist, please contact me. > > > > On Sun, Feb 8, 2009 at 7:47 PM, Jeffrey Straszheim < > > > > straszheimjeff...@gmail.com> wrote: > > > > > Stratified negation is working and in trunk. > > > > > I have some cool ideas of a simple, but powerful, way to implement > > > > evaluable predicates. They'll likely make it in by midweek. > > > > > The the hard part (magic sets) begins. > > > > > On Feb 8, 11:43 am, Jeffrey Straszheim > > > > wrote: > > > > > I now have recursive queries working. My next 3 milestones are > > > > stratified > > > > > negation, evaluable predicates, and then some version of magic sets > > > > > optimization. But now, as long as your queries are non-negated it is > > > > > working. > > > > > >http://code.google.com/p/clojure-datalog/ I got a chance to look at your docs: http://code.google.com/p/clojure-datalog/wiki/BasicSyntax I think your choice of using maps (we don't call them hashes in Clojure as they might not be hash tables) is right on the money for Clojure, especially set-of-maps-is-relation, just like clojure.set. Two thoughts: I wonder though if the map of rel-names to rels isn't a wart though. It's a pet peeve of mine that relation names don't end up in the db like any other attribute. Yes, they'll need to be indexed, but eventually you'll want to support indexing on any desired attributes as well. Putting relation names in the db gives you a uniform meta- query capability. I haven't thought this all the way through, but you might want to think about it. I didn't know how to interpret this: (logic-rule (:fred :x ?x :y ?y) - (:sally :x ?x :z ?z) ("becky" :y ?y) (not! :janet :qqq ?z) (if < ?x ? y)) Overall, it looks very promising! If you weren't aware of it: Foundations of Databases: The Logical Level Serge Abiteboul, Richard Hull, Victor Vianu http://www.amazon.com/gp/product/0201537710 has good coverage of Datalog, including QSQ. Rich --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Static member and classes
On Feb 18, 2009, at 2:48 PM, BerlinBrown wrote: I was trying to access a public inner class and a field within that field. For example: fc.map(FileChannel.MapMode.READ_ONLY, 0, sz); public abstract class FileChannel public static class MapMode { public static final MapMode READ_ONLY = new MapMode("READ_ONLY"); Clojure uses the same name for inner classes as Java uses under the covers-the outer class followed by $ followed by the inner class. What you're looking for here is: user=> java.nio.channels.FileChannel$MapMode/READ_ONLY # --Steve smime.p7s Description: S/MIME cryptographic signature
Re: how to learn clojure ?
These are the resources that I've found to be most useful when initially learning lisp: - SICP lectures (http://groups.csail.mit.edu/mac/classes/6.001/abelson- sussman-lectures/) - Peter Seibel's book Practical Common Lisp (http://gigamonkeys.com/ book/) - Paul Graham's book ASNI Common Lisp (http://www.paulgraham.com/ acl.html). You can read On Lisp, but I would suggest starting here first. In my own studies, I found that Paul Graham's book was the most useful for me to learn the language. I had tried learning Lisp before, but it was his book that really made Lisp click for me.. As for learning Clojure take a look at Stuart Halloway's book from the Pragmatic Programmers (http://www.pragprog.com/titles/shcloj/ programming-clojure). And also check out his website where he has a great little series that translates the examples in Practical Common Lisp into Clojure (http://blog.thinkrelevance.com/2008/9/16/pcl- clojure). I think all of those should keep you busy for quite sometime. Good luck, hope this helps. Christopher On Feb 18, 4:53 am, MarisO wrote: > All documentation I've seen about clojure assumes knowledge of lisp > which I dont have. --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Static member and classes
I was trying to access a public inner class and a field within that field. For example: fc.map(FileChannel.MapMode.READ_ONLY, 0, sz); public abstract class FileChannel public static class MapMode { public static final MapMode READ_ONLY = new MapMode("READ_ONLY"); . This is what I tried and got the following error. mm (. java.nio.channels.FileChannel MapMode) bb (. fc map (. mm READ_ONLY) 0 sz) Caused by: java.lang.NoSuchFieldException: MapMode at java.lang.Class.getField(Unknown Source) at clojure.lang.Compiler$StaticFieldExpr.(Compiler.java: 962) at clojure.lang.Compiler$HostExpr$Parser.parse(Compiler.java: 746) at clojure.lang.Compiler.analyzeSeq(Compiler.java:4106) ... 60 more Clojure user=> --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: clojure.core.read-line broken
On Feb 18, 12:27 pm, "Stephen C. Gilardi" wrote: > This is from issue 47, svn 1229. It's unfortunate that a class can't > be both a BufferedReader and a PushbackReader simultaneously. Those > classes were implemented using class inheritance rather than via > interfaces. In this case, the default *in* is not a BufferedReader, > but does provide readLine. It looks to me like removing the hint is > the correct fix. Thanks, Steve -- I wasn't able to track down which revision introduced the breakage. Now I understand the motivation (avoiding reflection): user=> (set! *warn-on-reflection* true) true user=> (.readLine *in*) Reflection warning, line: 2 - reference to field readLine can't be resolved. hello "hello" user=> (.readLine #^clojure.lang.LineNumberingPushbackReader *in*) hello "hello" &, if I follow, the latter isn't robust because we need to allow for *in* to be dynamically rebound, & wouldn't want to require that it's always a LineNumberingPR. Some microbenchmarking (details below) shows that doing an instance? check combined with type hinting is almost twice as fast as relying on reflection, & hardly slower than the type-hinted code w/o an instance? check. How does the following implementation strike you? (defn r-l [] (if (instance? clojure.lang.LineNumberingPushbackReader *in*) (.readLine #^clojure.lang.LineNumberingPushbackReader *in*) (.readLine #^java.io.BufferedReader *in*))) Best, Perry --- 10 runs w/o type hinting: 0.119 msecs (avg) -- user=> (time (.readLine *in*)) "hello" "Elapsed time: 0.105 msecs" " \"hello\"" user=> (time (.readLine *in*)) "hello" "Elapsed time: 0.116 msecs" " \"hello\"" user=> (time (.readLine *in*)) "hello" "Elapsed time: 0.113 msecs" " \"hello\"" user=> (time (.readLine *in*)) "hello" "Elapsed time: 0.122 msecs" " \"hello\"" user=> (time (.readLine *in*)) "hello" "Elapsed time: 0.153 msecs" " \"hello\"" user=> (time (.readLine *in*)) "hello" "Elapsed time: 0.108 msecs" " \"hello\"" user=> (time (.readLine *in*)) "hello" "Elapsed time: 0.11 msecs" " \"hello\"" user=> (time (.readLine *in*)) "hello" "Elapsed time: 0.115 msecs" " \"hello\"" user=> (time (.readLine *in*)) "hello" "Elapsed time: 0.125 msecs" " \"hello\"" user=> (time (.readLine *in*)) "hello" "Elapsed time: 0.124 msecs" " \"hello\"" --- 10 runs with (r-l) func: 0.058 msecs (avg) --- user=> (time (r-l)) "hello" "Elapsed time: 0.055 msecs" " \"hello\"" user=> (time (r-l)) "hello" "Elapsed time: 0.055 msecs" " \"hello\"" user=> (time (r-l)) "hello" "Elapsed time: 0.064 msecs" " \"hello\"" user=> (time (r-l)) "hello" "Elapsed time: 0.061 msecs" " \"hello\"" user=> (time (r-l)) "hello" "Elapsed time: 0.057 msecs" " \"hello\"" user=> (time (r-l)) "hello" "Elapsed time: 0.056 msecs" " \"hello\"" user=> (time (r-l)) "hello" "Elapsed time: 0.058 msecs" " \"hello\"" user=> (time (r-l)) "hello" "Elapsed time: 0.062 msecs" " \"hello\"" user=> (time (r-l)) "hello" "Elapsed time: 0.054 msecs" " \"hello\"" user=> (time (r-l)) "hello" "Elapsed time: 0.061 msecs" " \"hello\"" --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure documentation for offline use?
If you want offline version of clojure.org: hg clone https://bitbucket.org/ksojat/truba/ cd truba ant clojure-org-download (requires wget) When finished, it will place it in dist/clojure.org directory. Or you can just copy wget command from clojure-org-download target. -- Krešimir Šojat --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Fully lazy sequences are here!
On Feb 18, 2:09 pm, Stefan Rusek wrote: > On Wed, Feb 18, 2009 at 8:02 PM, Rich Hickey wrote: > > > On Feb 18, 12:20 pm, Frantisek Sodomka wrote: > >> How should I say it... It just didn't look "symmetrical" to me. > > >> So, basically, there is a difference between functions returning > >> sequences - depending on if they are lazy or eager. Hmm... > > >> user=> (reverse []) > >> nil > >> user=> (if (reverse []) true false) > >> false > >> user=> (if (seq (reverse [])) true false) > >> false > > >> user=> (lazy-seq nil) > >> () > >> user=> (seq (lazy-seq nil)) > >> nil > >> user=> (if (lazy-seq nil) true false) > >> true > >> user=> (if (seq (lazy-seq nil)) true false) > >> false > > >> As long as I remember which function is lazy and which one is eager, I > >> should be fine then. > > >> Just wanted to really understand it. > > > It shouldn't be that subtle. Sequence functions shouldn't return nil > > unless they are variants of seq/next. I've fixed reverse and sort to > > return () when passed empty colls - SVN 1294. > > > Rich. > > Wouldn't it make more sense to to return an empty version of the same > collection type? That way the following would work more like someone > would expect. > > (conj (rest [1]) 2) -> [2] instead of (2) > That's not what I would expect. rest returns a sequence in O(1). It can't efficiently do otherwise for all collections. Rich --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: how to learn clojure ?
Paul Graham's book "On Lisp" is one of my all-time favorites. That one uses Common Lisp. Another good thing to check out are the free MIT videos of Abelson and Sussman's "Structure and Interpretation of Computer Programs", and the book these lectures follow. That uses the Scheme dialect of Lisp. Also, check out Doug Hoyte's new advanced book on macros once you get through these others. That's an awesome book. It's kind of a sequel to On Lisp, though by a different author. Rob On Feb 18, 7:53 am, MarisO wrote: > All documentation I've seen about clojure assumes knowledge of lisp > which I dont have. --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: how to learn clojure ?
Paul Graham's book "On Lisp" is one of my all-time favorites. That one uses Common Lisp. Another good thing to check out are the free MIT videos of Abelson and Sussman's "Structure and Interpretation of Computer Programs", and the book these lectures follow. That uses the Scheme dialect of Lisp. Also, check out Doug Hoyte's new advanced book on macros once you get through these others. That's an awesome book. It's kind of a sequel to On Lisp, though by a different author. Rob On Feb 18, 7:53 am, MarisO wrote: > All documentation I've seen about clojure assumes knowledge of lisp > which I dont have. --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Libraries? model and generic-functions
On Feb 18, 10:17 am, wlr wrote: > On Feb 17, 10:20 am, Raffael Cavallaro > wrote: > > > I am very interested in both of these subsystems and would love to see > > you package them as clojure.contrib libraries. Hopefully others feel > > the same and we'll see an announcement for them here soon. > > +1 I'd like to see a general predicate dispatch based upon Chambers/Chen; http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.47.4553 http://portal.acm.org/citation.cfm?id=320407 utilizing Clojure's ad-hoc hierarchies. Rich --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Performance of (fn [] ...)?
Creating a small object like that is cheap on the JVM. There are much better places to put optimization effort. On Wed, Feb 18, 2009 at 1:07 PM, Michel Salim wrote: > > > > On Feb 18, 3:17 am, Laurent PETIT wrote: > > Hello, > > > > 2009/2/18 CuppoJava > > > > > > > > > Hi, > > > I've noticed that I'm creating a lot of maps of functions, and I'm > > > wondering if there's a performance penalty for this. > > > > > ie. > > > (defn create_fn [] > > > (fn [] (println "hi"))) > > > > If you use AOT compilation, you'll see that this code will add 2 new > classes > > to the namespace it is declared in : one class for create_fn itself, and > one > > anonymous class for (fn [] (println "hi")) > > > > > ((create_fn)) <--- Does this "create" a new function every-time it's > > > called? Or is the function code cached somewhere? How much of a > > > performance penalty does this incur? > > > > Each call to create_fn will create a new instance (object) of the > anonymous > > class for (fn [] (println "hi")) > > > Is this something that will eventually be optimized? This anonymous > function does not capture any variable, and therefore can just be > instantiated once. > > Regards, > > -- > Michel S. > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Idiomatic Way to Write the Following:
Ahh, this is the best one looking yet! :-) On Feb 18, 1:45 pm, Jeff Valk wrote: > Here's another. > > (defn remove-at [v & idxs] > (vec (for [i (range (count v)) :when (not ((set idxs) i))] (v i > > - Jeff > And this one is definitely the fastest one: > On Wednesday 18 February 2009 12:07, Chouser wrote: > > > > > On Wed, Feb 18, 2009 at 12:30 PM, Telman Yusupov wrote: > > > No prettier, but a bit faster: > > > (defn remove-at42 [coll & indexes] > > (let [iset (set indexes)] > > (loop [i (int 0) sq (seq coll) v []] > > (if-not sq > > v > > (recur (inc i) > > (next sq) > > (if (iset i) > > v > > (conj v (first sq > > > --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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Fully lazy sequences are here!
On Wed, Feb 18, 2009 at 8:02 PM, Rich Hickey wrote: > > > > On Feb 18, 12:20 pm, Frantisek Sodomka wrote: >> How should I say it... It just didn't look "symmetrical" to me. >> >> So, basically, there is a difference between functions returning >> sequences - depending on if they are lazy or eager. Hmm... >> >> user=> (reverse []) >> nil >> user=> (if (reverse []) true false) >> false >> user=> (if (seq (reverse [])) true false) >> false >> >> user=> (lazy-seq nil) >> () >> user=> (seq (lazy-seq nil)) >> nil >> user=> (if (lazy-seq nil) true false) >> true >> user=> (if (seq (lazy-seq nil)) true false) >> false >> >> As long as I remember which function is lazy and which one is eager, I >> should be fine then. >> >> Just wanted to really understand it. >> > > It shouldn't be that subtle. Sequence functions shouldn't return nil > unless they are variants of seq/next. I've fixed reverse and sort to > return () when passed empty colls - SVN 1294. > > Rich. > Wouldn't it make more sense to to return an empty version of the same collection type? That way the following would work more like someone would expect. (conj (rest [1]) 2) -> [2] instead of (2) --Stefan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Questions about a Clojure Datalog
I see nothing in his code or documentation for handling negation or stratification. Also, it appears to be a top down evaluator, and I don't see any fixed-point or other recursion handling. I *suspect* this does not guarantee termination over arbitrary safe rules. It is not real Datalog. On Wed, Feb 18, 2009 at 12:42 PM, Telman Yusupov wrote: > > Could this be of any help for your development? There is now a version > of Datalog for PLT Scheme: > > Software: > > http://planet.plt-scheme.org/display.ss?package=datalog.plt&owner=jaymccarthy > > Documentation: > > http://planet.plt-scheme.org/package-source/jaymccarthy/datalog.plt/1/0/planet-docs/datalog/index.html > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure documentation for offline use?
If you're just looking for the API documentation, then you could use this file [1]. If you're looking for the rest of the stuff on the site, then I'm not sure. [1] http://clojure.googlegroups.com/web/clj-libs%20(3).html On Wed, Feb 18, 2009 at 11:18 AM, Oliver wrote: > > Hi, > > I'm wondering if there's any way of getting hold of the Clojure > documentation for usage offline? There's no download link online and > it doesn't appear in SVN. I attempted to scrape the site but it ended > in failure, and there probably should be a better way than having to > rely on scraping. > > Many thanks, > Oliver > > > > --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Fully lazy sequences are here!
On Feb 18, 12:20 pm, Frantisek Sodomka wrote: > How should I say it... It just didn't look "symmetrical" to me. > > So, basically, there is a difference between functions returning > sequences - depending on if they are lazy or eager. Hmm... > > user=> (reverse []) > nil > user=> (if (reverse []) true false) > false > user=> (if (seq (reverse [])) true false) > false > > user=> (lazy-seq nil) > () > user=> (seq (lazy-seq nil)) > nil > user=> (if (lazy-seq nil) true false) > true > user=> (if (seq (lazy-seq nil)) true false) > false > > As long as I remember which function is lazy and which one is eager, I > should be fine then. > > Just wanted to really understand it. > It shouldn't be that subtle. Sequence functions shouldn't return nil unless they are variants of seq/next. I've fixed reverse and sort to return () when passed empty colls - SVN 1294. Rich. > > On Feb 18, 5:58 pm, Chouser wrote: > > > On Wed, Feb 18, 2009 at 11:46 AM, Frantisek Sodomka > > wrote: > > > > What about 'conj'? Documentation says: > > > (conj nil item) returns (item). > > > > Currently: > > > user=> (conj nil 1) > > > (1) > > > user=> (conj () 1) > > > (1) > > > Is there something wrong with that? It looks right and like it > > matches the docs to me. > > > > Idiom "conj nil" is used in 'reverse': (reduce conj nil coll) > > > Currently: > > > user=> (reverse [1 2]) > > > (2 1) > > > user=> (reverse [1]) > > > (1) > > > user=> (reverse []) > > > nil > > > > It looks that now all sequence functions return () instead of nil. Is > > > 'reverse' correct? > > > Things that return lazy seqs now return an empty lazy seq, which > > prints as (), instead of nil. However, 'reverse' is not lazy and > > normally returns a PersistentList. I don't know that it'd be more > > correct to return an empty PersistentList than to return nil as it > > does now. > > > --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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure documentation for offline use?
On Feb 18, 10:18 am, Oliver wrote: > Hi, > > I'm wondering if there's any way of getting hold of the Clojure > documentation for usage offline? There's no download link online and > it doesn't appear in SVN. I attempted to scrape the site but it ended > in failure, and there probably should be a better way than having to > rely on scraping. I use the ScrapBook Firefox plugin[0] to maintain a local copy. I think there's a pdf version in the files section of the group, but I don't know how up-to-date it is. :dudley [0] https://addons.mozilla.org/en-US/firefox/addon/427 --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Idiomatic Way to Write the Following:
Here's another. (defn remove-at [v & idxs] (vec (for [i (range (count v)) :when (not ((set idxs) i))] (v i - Jeff On Wednesday 18 February 2009 12:07, Chouser wrote: > > On Wed, Feb 18, 2009 at 12:30 PM, Telman Yusupov wrote: > > No prettier, but a bit faster: > > (defn remove-at42 [coll & indexes] > (let [iset (set indexes)] > (loop [i (int 0) sq (seq coll) v []] > (if-not sq > v > (recur (inc i) >(next sq) >(if (iset i) > v > (conj v (first sq > > --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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: how to learn clojure ?
You got the recursion part down pat:-) If you want a Common Lisp book, "Practical Common Lisp" is very good, very practical, and you can read it online for free: http://www.gigamonkeys.com/book/ On Feb 18, 7:53 am, MarisO wrote: > All documentation I've seen about clojure assumes knowledge of lisp > which I dont have. --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Clojure documentation for offline use?
Hi, I'm wondering if there's any way of getting hold of the Clojure documentation for usage offline? There's no download link online and it doesn't appear in SVN. I attempted to scrape the site but it ended in failure, and there probably should be a better way than having to rely on scraping. Many thanks, Oliver --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: clojure.core.read-line broken
On Feb 18, 2009, at 12:05 PM, Perry Trolard wrote: On the most recent svn (r1293), read-line throws a ClassCastException when called: user=> (read-line) java.lang.ClassCastException: clojure.lang.LineNumberingPushbackReader cannot be cast to java.io.BufferedReader (NO_SOURCE_FILE:0) Removing the type hint solves the issue: user=> (source read-line) (defn read-line "Reads the next line from stream that is the current value of *in* ." [] (. #^java.io.BufferedReader *in* (readLine))) nil user=> (.readLine *in*) this is a line "this is a line" This is from issue 47, svn 1229. It's unfortunate that a class can't be both a BufferedReader and a PushbackReader simultaneously. Those classes were implemented using class inheritance rather than via interfaces. In this case, the default *in* is not a BufferedReader, but does provide readLine. It looks to me like removing the hint is the correct fix. --Steve smime.p7s Description: S/MIME cryptographic signature
Re: Performance of (fn [] ...)?
On Feb 18, 3:17 am, Laurent PETIT wrote: > Hello, > > 2009/2/18 CuppoJava > > > > > Hi, > > I've noticed that I'm creating a lot of maps of functions, and I'm > > wondering if there's a performance penalty for this. > > > ie. > > (defn create_fn [] > > (fn [] (println "hi"))) > > If you use AOT compilation, you'll see that this code will add 2 new classes > to the namespace it is declared in : one class for create_fn itself, and one > anonymous class for (fn [] (println "hi")) > > > ((create_fn)) <--- Does this "create" a new function every-time it's > > called? Or is the function code cached somewhere? How much of a > > performance penalty does this incur? > > Each call to create_fn will create a new instance (object) of the anonymous > class for (fn [] (println "hi")) > Is this something that will eventually be optimized? This anonymous function does not capture any variable, and therefore can just be instantiated once. Regards, -- Michel S. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Idiomatic Way to Write the Following:
On Wed, Feb 18, 2009 at 12:30 PM, Telman Yusupov wrote: > > I'm not sure which version is more idiomatic, but the last one seems > to give me the best performance out of all versions. No prettier, but a bit faster: (defn remove-at42 [coll & indexes] (let [iset (set indexes)] (loop [i (int 0) sq (seq coll) v []] (if-not sq v (recur (inc i) (next sq) (if (iset i) v (conj v (first sq --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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure on CLR/DLR
On 18 феб, 15:13, dmiller wrote: > When the rough edges are filed off, it should distributable as a set > of DLLs (and a console EXE) like any other .NET application. It > should be able to follow the DLR to Mono. > You mean DLR can create executables that don't need .NET runtime? --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Questions about a Clojure Datalog
It is worth looking at. On Wed, Feb 18, 2009 at 12:42 PM, Telman Yusupov wrote: > > Could this be of any help for your development? There is now a version > of Datalog for PLT Scheme: > > Software: > > http://planet.plt-scheme.org/display.ss?package=datalog.plt&owner=jaymccarthy > > Documentation: > > http://planet.plt-scheme.org/package-source/jaymccarthy/datalog.plt/1/0/planet-docs/datalog/index.html > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: bug affecting clojure.core/bean?
Seems I got it totally wrong :-( I'll re-read the lazy page ... Sorry, -- Laurent 2009/2/18 David Nolen > If I've been following things correct: > rest _used_ to force the seq, it does no longer. > next forces the seq > > In my own mind i'm thinking next to mean (return the seq with the next > value computed), rest now means just give me the uncomputed remaining values > of the seq. > > On Wed, Feb 18, 2009 at 12:00 PM, Laurent PETIT > wrote: > >> >> >> 2009/2/18 Mark Volkmann >> >> >>> On Wed, Feb 18, 2009 at 10:27 AM, Rich Hickey >>> wrote: >>> > >>> > On Feb 18, 11:04 am, Chouser wrote: >>> >> On Wed, Feb 18, 2009 at 12:35 AM, Rob wrote: >>> >> >>> >> > I'm wondering if I found a bug. I have the latest source from svn >>> >> > (r1291). >>> >> >>> >> > user=> (bean 1) >>> >> > java.lang.IllegalArgumentException: Wrong number of args passed to: >>> >> > core$bean--5161$fn--5179$thisfn >>> >> >>> >> You sure did. The conversion to lazy-seq code appears to introduce a >>> >> paren typo and an incorrect nil pun. Patch attached. >>> >> >>> > >>> > Patch applied, svn 1293 - thanks! >>> > >>> >> Rich, I think it'd be pretty useful to have as you mentioned in IRC a >>> >> variant of & destructuring that provided an unforced lazy-seq. It >>> >> seems pretty common to want, in the body of a lazy-seq, a destructured >>> >> 'first' but an unforced 'rest'. This is already the third or fourth >>> >> time I've wanted to be able to do something like: >>> >> >>> >> (fn thisfn [plseq] >>> >> (lazy-seq >>> >> (when-let [[pkey &rest etc] plseq] >>> >> (cons (new clojure.lang.MapEntry pkey (v pkey)) >>> >> (thisfn etc) >>> >> >>> > >>> > Yes, sure. It just comes down to the name: >>> > >>> > &rest >>> > && >>> > >>> > others? >>> >>> Of those I prefer &rest because its meaning is more explicit. >> >> >> Maybe I miss the point totally, but didn't the recent change give the >> function 'next the meaning of not forcing the seq ? >> >> So &next instead of &rest ? ... and maybe either &rest or &next , and not >> just & anymore ? >> >> >>> >>> >>> -- >>> R. Mark Volkmann >>> Object Computing, Inc. >>> >>> >>> >> >> >> >> > > > > --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Questions about a Clojure Datalog
Could this be of any help for your development? There is now a version of Datalog for PLT Scheme: Software: http://planet.plt-scheme.org/display.ss?package=datalog.plt&owner=jaymccarthy Documentation: http://planet.plt-scheme.org/package-source/jaymccarthy/datalog.plt/1/0/planet-docs/datalog/index.html --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Idiomatic Way to Write the Following:
I tried to get the results using some clever one liner but couldn't come up with it. It looks like rolling your own function is the way to go (but I would love to see this proven wrong). It would be very helpful if there were a function that does vector difference, like the one for sets. For example: (use 'clojure.set) (defn remove-at2 [coll & indexes] (vec (difference (set coll) (set (map #(coll %) (vec indexes)) could become: (defn remove-at-hypothetical [coll & indexes] (vec-difference coll (map #(coll %) (vec indexes Unfortunately, the set version does not maintain the order of elements in the vector. Here is the recursive version that does keep the order of elements intact: (defn remove-at3 [coll & indexes] (loop [idx (vec indexes) result coll] (if (empty? idx) (vec result) (let [current (coll (first idx)) new-result (if current (remove #(= % current) result) result)] (recur (rest idx) new-result) I'm not sure which version is more idiomatic, but the last one seems to give me the best performance out of all versions. On Feb 18, 1:10 am, CuppoJava wrote: > Mmm, subvec doesn't quite seem to do the same thing. > > I want a function that removes certain indexes of a vector: > eg. (remove_at [1 2 3 4 5 6] 0 3) => [2 3 5 6] --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: bug affecting clojure.core/bean?
If I've been following things correct: rest _used_ to force the seq, it does no longer. next forces the seq In my own mind i'm thinking next to mean (return the seq with the next value computed), rest now means just give me the uncomputed remaining values of the seq. On Wed, Feb 18, 2009 at 12:00 PM, Laurent PETIT wrote: > > > 2009/2/18 Mark Volkmann > > >> On Wed, Feb 18, 2009 at 10:27 AM, Rich Hickey >> wrote: >> > >> > On Feb 18, 11:04 am, Chouser wrote: >> >> On Wed, Feb 18, 2009 at 12:35 AM, Rob wrote: >> >> >> >> > I'm wondering if I found a bug. I have the latest source from svn >> >> > (r1291). >> >> >> >> > user=> (bean 1) >> >> > java.lang.IllegalArgumentException: Wrong number of args passed to: >> >> > core$bean--5161$fn--5179$thisfn >> >> >> >> You sure did. The conversion to lazy-seq code appears to introduce a >> >> paren typo and an incorrect nil pun. Patch attached. >> >> >> > >> > Patch applied, svn 1293 - thanks! >> > >> >> Rich, I think it'd be pretty useful to have as you mentioned in IRC a >> >> variant of & destructuring that provided an unforced lazy-seq. It >> >> seems pretty common to want, in the body of a lazy-seq, a destructured >> >> 'first' but an unforced 'rest'. This is already the third or fourth >> >> time I've wanted to be able to do something like: >> >> >> >> (fn thisfn [plseq] >> >> (lazy-seq >> >> (when-let [[pkey &rest etc] plseq] >> >> (cons (new clojure.lang.MapEntry pkey (v pkey)) >> >> (thisfn etc) >> >> >> > >> > Yes, sure. It just comes down to the name: >> > >> > &rest >> > && >> > >> > others? >> >> Of those I prefer &rest because its meaning is more explicit. > > > Maybe I miss the point totally, but didn't the recent change give the > function 'next the meaning of not forcing the seq ? > > So &next instead of &rest ? ... and maybe either &rest or &next , and not > just & anymore ? > > >> >> >> -- >> R. Mark Volkmann >> Object Computing, Inc. >> >> >> > > > > > --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Fully lazy sequences are here!
How should I say it... It just didn't look "symmetrical" to me. So, basically, there is a difference between functions returning sequences - depending on if they are lazy or eager. Hmm... user=> (reverse []) nil user=> (if (reverse []) true false) false user=> (if (seq (reverse [])) true false) false user=> (lazy-seq nil) () user=> (seq (lazy-seq nil)) nil user=> (if (lazy-seq nil) true false) true user=> (if (seq (lazy-seq nil)) true false) false As long as I remember which function is lazy and which one is eager, I should be fine then. Just wanted to really understand it. Thanks, Frantisek On Feb 18, 5:58 pm, Chouser wrote: > On Wed, Feb 18, 2009 at 11:46 AM, Frantisek Sodomka > wrote: > > > What about 'conj'? Documentation says: > > (conj nil item) returns (item). > > > Currently: > > user=> (conj nil 1) > > (1) > > user=> (conj () 1) > > (1) > > Is there something wrong with that? It looks right and like it > matches the docs to me. > > > Idiom "conj nil" is used in 'reverse': (reduce conj nil coll) > > Currently: > > user=> (reverse [1 2]) > > (2 1) > > user=> (reverse [1]) > > (1) > > user=> (reverse []) > > nil > > > It looks that now all sequence functions return () instead of nil. Is > > 'reverse' correct? > > Things that return lazy seqs now return an empty lazy seq, which > prints as (), instead of nil. However, 'reverse' is not lazy and > normally returns a PersistentList. I don't know that it'd be more > correct to return an empty PersistentList than to return nil as it > does now. > > --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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: bug affecting clojure.core/bean?
2009/2/18 Mark Volkmann > > On Wed, Feb 18, 2009 at 10:27 AM, Rich Hickey > wrote: > > > > On Feb 18, 11:04 am, Chouser wrote: > >> On Wed, Feb 18, 2009 at 12:35 AM, Rob wrote: > >> > >> > I'm wondering if I found a bug. I have the latest source from svn > >> > (r1291). > >> > >> > user=> (bean 1) > >> > java.lang.IllegalArgumentException: Wrong number of args passed to: > >> > core$bean--5161$fn--5179$thisfn > >> > >> You sure did. The conversion to lazy-seq code appears to introduce a > >> paren typo and an incorrect nil pun. Patch attached. > >> > > > > Patch applied, svn 1293 - thanks! > > > >> Rich, I think it'd be pretty useful to have as you mentioned in IRC a > >> variant of & destructuring that provided an unforced lazy-seq. It > >> seems pretty common to want, in the body of a lazy-seq, a destructured > >> 'first' but an unforced 'rest'. This is already the third or fourth > >> time I've wanted to be able to do something like: > >> > >> (fn thisfn [plseq] > >> (lazy-seq > >> (when-let [[pkey &rest etc] plseq] > >> (cons (new clojure.lang.MapEntry pkey (v pkey)) > >> (thisfn etc) > >> > > > > Yes, sure. It just comes down to the name: > > > > &rest > > && > > > > others? > > Of those I prefer &rest because its meaning is more explicit. Maybe I miss the point totally, but didn't the recent change give the function 'next the meaning of not forcing the seq ? So &next instead of &rest ? ... and maybe either &rest or &next , and not just & anymore ? > > > -- > R. Mark Volkmann > Object Computing, Inc. > > > > --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
clojure.core.read-line broken
On the most recent svn (r1293), read-line throws a ClassCastException when called: user=> (read-line) java.lang.ClassCastException: clojure.lang.LineNumberingPushbackReader cannot be cast to java.io.BufferedReader (NO_SOURCE_FILE:0) Removing the type hint solves the issue: user=> (source read-line) (defn read-line "Reads the next line from stream that is the current value of *in* ." [] (. #^java.io.BufferedReader *in* (readLine))) nil user=> (.readLine *in*) this is a line "this is a line" Perry --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: bug affecting clojure.core/bean?
Or maybe: &next ??? :- Frantisek On Feb 18, 5:27 pm, Rich Hickey wrote: > On Feb 18, 11:04 am, Chouser wrote: > > > On Wed, Feb 18, 2009 at 12:35 AM, Rob wrote: > > > > I'm wondering if I found a bug. I have the latest source from svn > > > (r1291). > > > > user=> (bean 1) > > > java.lang.IllegalArgumentException: Wrong number of args passed to: > > > core$bean--5161$fn--5179$thisfn > > > You sure did. The conversion to lazy-seq code appears to introduce a > > paren typo and an incorrect nil pun. Patch attached. > > Patch applied, svn 1293 - thanks! > > > Rich, I think it'd be pretty useful to have as you mentioned in IRC a > > variant of & destructuring that provided an unforced lazy-seq. It > > seems pretty common to want, in the body of a lazy-seq, a destructured > > 'first' but an unforced 'rest'. This is already the third or fourth > > time I've wanted to be able to do something like: > > > (fn thisfn [plseq] > > (lazy-seq > > (when-let [[pkey &rest etc] plseq] > > (cons (new clojure.lang.MapEntry pkey (v pkey)) > > (thisfn etc) > > Yes, sure. It just comes down to the name: > > &rest > && > > others? > > Rich --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Performance of (fn [] ...)?
Thanks for the replies. I have no qualms about creating functions now. =) On Feb 18, 3:15 am, Michael Wood wrote: > On Wed, Feb 18, 2009 at 8:50 AM, David Nolen wrote: > > new MBP 2.53ghz > > > (defn create-fn [] > > (fn [] (println "hi"))) > > > (time (dotimes [x 4000] > > (create-fn))) > > >> "Elapsed time: 1034.409 msecs" > > > Hopefully you don't need 40,000,000 functions in less than a second ;) > > Well that takes about 12 seconds for me on a dual CPU P3 1GHz > (/proc/cpuinfo says 930MHz?). :) > > -- > Michael Wood --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Fully lazy sequences are here!
On Wed, Feb 18, 2009 at 11:46 AM, Frantisek Sodomka wrote: > > What about 'conj'? Documentation says: > (conj nil item) returns (item). > > Currently: > user=> (conj nil 1) > (1) > user=> (conj () 1) > (1) Is there something wrong with that? It looks right and like it matches the docs to me. > Idiom "conj nil" is used in 'reverse': (reduce conj nil coll) > Currently: > user=> (reverse [1 2]) > (2 1) > user=> (reverse [1]) > (1) > user=> (reverse []) > nil > > It looks that now all sequence functions return () instead of nil. Is > 'reverse' correct? Things that return lazy seqs now return an empty lazy seq, which prints as (), instead of nil. However, 'reverse' is not lazy and normally returns a PersistentList. I don't know that it'd be more correct to return an empty PersistentList than to return nil as it does now. --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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: bug affecting clojure.core/bean?
On Wed, Feb 18, 2009 at 10:27 AM, Rich Hickey wrote: > > On Feb 18, 11:04 am, Chouser wrote: >> On Wed, Feb 18, 2009 at 12:35 AM, Rob wrote: >> >> > I'm wondering if I found a bug. I have the latest source from svn >> > (r1291). >> >> > user=> (bean 1) >> > java.lang.IllegalArgumentException: Wrong number of args passed to: >> > core$bean--5161$fn--5179$thisfn >> >> You sure did. The conversion to lazy-seq code appears to introduce a >> paren typo and an incorrect nil pun. Patch attached. >> > > Patch applied, svn 1293 - thanks! > >> Rich, I think it'd be pretty useful to have as you mentioned in IRC a >> variant of & destructuring that provided an unforced lazy-seq. It >> seems pretty common to want, in the body of a lazy-seq, a destructured >> 'first' but an unforced 'rest'. This is already the third or fourth >> time I've wanted to be able to do something like: >> >> (fn thisfn [plseq] >> (lazy-seq >> (when-let [[pkey &rest etc] plseq] >> (cons (new clojure.lang.MapEntry pkey (v pkey)) >> (thisfn etc) >> > > Yes, sure. It just comes down to the name: > > &rest > && > > others? Of those I prefer &rest because its meaning is more explicit. -- R. Mark Volkmann Object Computing, Inc. --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Fully lazy sequences are here!
Or maybe more general question: Is there any function in Clojure which when returning empty sequence, returns nil instead of () ??? user=> (butlast [1 2 3]) (1 2) user=> (butlast [1]) nil user=> (butlast []) nil Thanks, Frantisek On Feb 18, 5:46 pm, Frantisek Sodomka wrote: > What about 'conj'? Documentation says: > (conj nil item) returns (item). > > Currently: > user=> (conj nil 1) > (1) > user=> (conj () 1) > (1) > > Idiom "conj nil" is used in 'reverse': (reduce conj nil coll) > Currently: > user=> (reverse [1 2]) > (2 1) > user=> (reverse [1]) > (1) > user=> (reverse []) > nil > > It looks that now all sequence functions return () instead of nil. Is > 'reverse' correct? > > Thank you, Frantisek > > On Feb 17, 8:43 pm, Rich Hickey wrote: > > > I've merged the lazy branch into trunk, SVN rev 1287 > > > Please do not rush to this version unless you are a library/tool > > developer. Let them do their ports and chime in on their progress. > > Move only when the libs/tools you depend upon have been ported. > > > Thanks to all for your feedback and input! > > > Rich --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Fully lazy sequences are here!
What about 'conj'? Documentation says: (conj nil item) returns (item). Currently: user=> (conj nil 1) (1) user=> (conj () 1) (1) Idiom "conj nil" is used in 'reverse': (reduce conj nil coll) Currently: user=> (reverse [1 2]) (2 1) user=> (reverse [1]) (1) user=> (reverse []) nil It looks that now all sequence functions return () instead of nil. Is 'reverse' correct? Thank you, Frantisek On Feb 17, 8:43 pm, Rich Hickey wrote: > I've merged the lazy branch into trunk, SVN rev 1287 > > Please do not rush to this version unless you are a library/tool > developer. Let them do their ports and chime in on their progress. > Move only when the libs/tools you depend upon have been ported. > > Thanks to all for your feedback and input! > > Rich --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: compiling a GUI app and also: interference of Java's built-in architechture
My impression is that if you build and compile whatever application you're making and deploy it using something like Java Web Start, the user usually doesn't have to do anything with regards to manually getting other libraries like Jambi; it would download it automatically or something. And there may be options for creating opaque executables for Windows and Linux—I know that you can do this for Mac OS X. I read that a disadvantage to Qt is that you have to use a different library file for different operating systems. Having said that, I could find much more documentation for Swing than for Jambi. How active of a project is Jambi? On Feb 18, 4:17 am, Korny Sietsma wrote: > As an end-user of various guis - the "no extra dependencies" and > "instantly cross platform" points can be a huge win, for users, if not > for developers. > > I regularly use tools like JEdit and JDiskReport and JXplorer - and > they *just work*. On Linux, and Solaris, and Windows, and OS/X. And > over ssh with remote X. I've even run Netbeans this way, though with > some pain. > > Sure, you can probably convince QT to run on most of these - though > I'm betting not on the Solaris systems I have to work with :) But I'd > be surprised if it were seamless and easy for the end user who has to > download and install your application, to also install the libraries > needed to run it... > > YMMV of course - my list of environments is hardly the most common > scenario for gui users. But it's quite appealing that I can write a > small gui in Swing / Clojure and it will just run everywhere that has > a graphics device! > > - Korny > > > > On Tue, Feb 17, 2009 at 4:57 AM, Dan wrote: > > >> Hello, > > >> Do you know of a good pointer that goes beyond the "don't use it" > >> argument, and really makes a thorough comparison of pros and cons of the 2 > >> frameworks ? > > > I'm not saying don't use Swing, I'm saying prefer Jambi. > > > My memory of Swing is dated so I'd have trouble making a thorough comparison > > but I can provide an outline. > > > In favour of Swing: > > > - No extra dependencies > > - No license restriction (Qt 4.4 requires you to buy a commercial license if > > you don't want to opensource your app, won't be true anymore with Qt 4.5) > > - De facto standard > > - Instantly cross-platform (Jambi requires you to package a different jar > > for each platform) > > > In favour of Qt: > > > - Great GUI builder (optional of course but you should give it a try, it's > > powerful and doesn't get in your way) > > - Cross-language (you can easily use the same GUI in C++, Python, Java, > > Ruby, Perl, and a few others with minimal porting efforts > > - Signals and slots, great way to manage events, objects emits signal which > > you connect to slots. Often you just have to connect them together with no > > extra code. If I want to implement a backbutton to work with a QWebview, I > > just have to connect the clicked signal from the button to the back slot > > from the web view (one liner). > > - Encourages separation of your GUI and logic (very easy to change your GUI > > without impeding the rest of your program) > > - Better layout (this is subjective but I was fighting all the time with > > Swing's and not Qt's) > > - Better organisation (subjective again but I find it much easier to find my > > way around Qt) > > > That's all I can think of at the moment. Overall, I don't think Swing is > > terrible toolkit but Qt definitly feels a lot better to me. > > > You can check this blog post to have an overview on how to use it in > > clojure: > > >http://briancarper.net/2008/10/31/qt4-in-lisp/ > > -- > Kornelis Sietsma korny at my surname dot com > kornys on gmail, twitter, facebook, etc. > "Every jumbled pile of person has a thinking part > that wonders what the part that isn't thinking > isn't thinking of" --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: bug affecting clojure.core/bean?
On Feb 18, 11:04 am, Chouser wrote: > On Wed, Feb 18, 2009 at 12:35 AM, Rob wrote: > > > I'm wondering if I found a bug. I have the latest source from svn > > (r1291). > > > user=> (bean 1) > > java.lang.IllegalArgumentException: Wrong number of args passed to: > > core$bean--5161$fn--5179$thisfn > > You sure did. The conversion to lazy-seq code appears to introduce a > paren typo and an incorrect nil pun. Patch attached. > Patch applied, svn 1293 - thanks! > Rich, I think it'd be pretty useful to have as you mentioned in IRC a > variant of & destructuring that provided an unforced lazy-seq. It > seems pretty common to want, in the body of a lazy-seq, a destructured > 'first' but an unforced 'rest'. This is already the third or fourth > time I've wanted to be able to do something like: > > (fn thisfn [plseq] > (lazy-seq > (when-let [[pkey &rest etc] plseq] > (cons (new clojure.lang.MapEntry pkey (v pkey)) > (thisfn etc) > Yes, sure. It just comes down to the name: &rest && others? Rich --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Fully lazy sequences are here!
On Feb 18, 5:22 am, Frantisek Sodomka wrote: > There is something that confuses me: > user=> (cycle []) > () > > user=> (= (cycle []) ()) > true > user=> (= (cycle []) nil) > true > user=> (= () nil) > false > Fixed in svn 1292 - thanks for the report. Rich --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: how to learn clojure ?
Practical Common Lisp is also online and free. Though there are significant differences between the two languages many of the strange and beautiful concepts that Clojure embraces are covered there. Especially dynamic variables, macros, destructuring bind, and multiple dispatch. On Wed, Feb 18, 2009 at 7:53 AM, MarisO wrote: > > All documentation I've seen about clojure assumes knowledge of lisp > which I dont have. > > > > --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: bug affecting clojure.core/bean?
On Wed, Feb 18, 2009 at 12:35 AM, Rob wrote: > > I'm wondering if I found a bug. I have the latest source from svn > (r1291). > > user=> (bean 1) > java.lang.IllegalArgumentException: Wrong number of args passed to: > core$bean--5161$fn--5179$thisfn You sure did. The conversion to lazy-seq code appears to introduce a paren typo and an incorrect nil pun. Patch attached. Rich, I think it'd be pretty useful to have as you mentioned in IRC a variant of & destructuring that provided an unforced lazy-seq. It seems pretty common to want, in the body of a lazy-seq, a destructured 'first' but an unforced 'rest'. This is already the third or fourth time I've wanted to be able to do something like: (fn thisfn [plseq] (lazy-seq (when-let [[pkey &rest etc] plseq] (cons (new clojure.lang.MapEntry pkey (v pkey)) (thisfn etc) --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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~--- commit 539242b543c99bf430c5b821f9c4a0ca769a8a26 Author: Chouser Date: Wed Feb 18 10:57:25 2009 -0500 Fix bean lazy-seq diff --git a/trunk/src/clj/clojure/core_proxy.clj b/trunk/src/clj/clojure/core_proxy.clj index 2b2d01d..120ffbf 100644 --- a/trunk/src/clj/clojure/core_proxy.clj +++ b/trunk/src/clj/clojure/core_proxy.clj @@ -340,11 +340,11 @@ (count [] (count pmap)) (assoc [k v] (assoc (snapshot) k v)) (without [k] (dissoc (snapshot) k)) - (seq [] ((fn thisfn [pseq] + (seq [] ((fn thisfn [plseq] (lazy-seq - (when pseq + (when-let [pseq (seq plseq)] (cons (new clojure.lang.MapEntry (first pseq) (v (first pseq))) - (thisfn (rest pseq) (keys pmap))) + (thisfn (rest pseq)) (keys pmap))
Re: clojure.xml & whitespace
On Wed, Feb 18, 2009 at 2:20 PM, mikel wrote: >> On Wed, Feb 18, 2009 at 12:59 PM, Christophe Grand >> >> > clojure.xml currently removes significant whitespaces. I guess that >> > people processing xml as data want this behavior (while people >> > processing xml as mark-up don't). What's the best way to accomodate >> > these to use cases? Through a *remove-all-whitespaces* var? > > On Feb 18, 6:29 am, "Remco van 't Veer" wrote: >> Maybe *ignore-whitespace* is a beter name since it doesn't remove >> anything and will retain some of it. I would prefer it to default to >> true. > > It's not obvious which thing a true value for *ignore-whitespace* > does; "ignore" in the sense of pretend it in't there? Or "ignore" in > the sense of skip over it, but leave it in? > > Maybe the Common Lisp convention would be more clear: *preserve- > whitespace* I agree that's beter. --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Libraries? model and generic-functions
On Feb 17, 10:20 am, Raffael Cavallaro wrote: > I am very interested in both of these subsystems and would love to see > you package them as clojure.contrib libraries. Hopefully others feel > the same and we'll see an announcement for them here soon. +1 --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: clojure.xml & whitespace
On Wed, Feb 18, 2009 at 8:04 AM, Christophe Grand wrote: > Mark Volkmann a écrit : >> On Wed, Feb 18, 2009 at 7:40 AM, Christophe Grand >> wrote: >> >>> Remco van 't Veer a écrit : >>> Maybe *ignore-whitespace* is a beter name since it doesn't remove anything and will retain some of it. I would prefer it to default to true. >>> I would prefer it to default to false since it's the standard way to >>> handle whitespace in XML. (Ignorable whitespaces are always ignored by >>> clojure.xml.) >>> >> >> I agree. That would be consistent with Apache Xerces which also uses >> that term and retains all whitespace by default. >> > > Patch attached. > > Mark, by "all whitespace" do you mean all significant whitespaces or > really all whitespaces (including ignorable whitespaces)? Good catch. I should have said "ignorable whitespace". -- R. Mark Volkmann Object Computing, Inc. --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: clojure and embedded derby
Stuart, Yes, it is running in a REPL right now, but I have gone to the extent of unloading NetBeans (and I assume clojure) fully (no java processes running), and still the lock file remains. But it does not prevent me from reloading my clojure project in NetBeans and re- connecting. However, NetBeans database browsing service cannot log onto the same database, until the lock file is removed. Jeff, I guess it surprises me that closing the connection doesn't remove the lock file, but maybe that has something to do with JDBC connection pooling?? Don't know for sure, that WAS a good idea to peruse the derby source code in the connection logic. Derby documentation recommends shutting down embedded server's in java (and therefore clojure) programs before the app exits, although early experiments in that do not appear to affect this lock file. Thanks for the advice and experience all, Brian On Feb 17, 2:59 pm, Jeff Valk wrote: > I've seen the same thing with embedded Derby while using SLIME. From within > the REPL I was always able to reconnect to the same database, so it didn't > really impact me. Outside the REPL I didn't notice a problem. > > If it holds you up, here's one observation you might investigate. Calling > (.close conn) doesn't remove the lock file, however causing a new connection > to fail does. It seems the embedded Derby driver may have some locking > clean-up logic in its connect call. Perhaps browsing the Derby source might > show how to invoke the real "release lock" method. > > - Jeff > > On Tuesday 17 February 2009 12:57, Stuart Sierra wrote: > > > > > Is your Clojure app running in a REPL? I've run into situations where > > it seems like the Derby lock file doesn't go away until the Clojure > > process terminates. > > > -Stuart Sierra > > > On Feb 17, 10:28 am, BrianS wrote: > > > Has anyone had experience creating clojure applications that use the > > > embedded derby database driver? I am having an issue where I am unable > > > to get the derby embedded database to shut down properly from within > > > clojure. > > > > More specifically, whenever a java app accesses a derby embedded > > > database, it creates a lock file to prevent other apps from accessing > > > the db and corrupting it. This file should be removed in a proper > > > shutdown of a derby database, but so far, even though I appear to have > > > gotten the derby database engine to shutdown from within clojure with > > > (java.sql.DriverManager/getConnection "jdbc:derby:;shutdown=true"), > > > the lock file still remains, and no app can access the derby database > > > until the db.lck file is deleted manually. > > > > I assumed this file would be deleted automagically during database > > > shutdown, but is this actually something my app should do manually > > > after shutting down its derby database? Thanks in advance for any > > > assistance, I appreciate that this is only marginally a clojure issue. > > > > Brian --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure on CLR/DLR
When the rough edges are filed off, it should distributable as a set of DLLs (and a console EXE) like any other .NET application. It should be able to follow the DLR to Mono. On Feb 18, 3:23 am, Johan Berntsson wrote: > On Feb 17, 9:17 am, dmiller wrote: > > > Also, this code is not set up for casual play. You need to be in > > Visual Studio, download the DLR, connect Tab A to Slot B, etc. I'm > > thinking it should not be in trunk/src by the criteria you cite. > > I'm really looking forward to a CLR version of Clojure, but I don't > like the sound of this. I hope we will be able to use ClojureCLR > without Visual Studio later on, and mono support wouldn't hurt either > (the DLR has already been ported to mono, so it should be possible). > > /Johan --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Fully lazy sequences are coming - feedback wanted!
On Feb 17, 10:52 pm, Mark Engelberg wrote: > Since there is no canonical empty sequence, this makes me wonder > whether one particular empty sequence might have some kind of > performance benefit over another. > > For example, if I were going to give a name to one empty sequence to > reuse within my code, would one of these be preferable?: > (def empty '()) > (def empty (sequence [])) > or some other variation? There cannot be a canonical empty sequence since lazy-seqs don't know if they are empty until forced. This should suffice, and seems better than any parochial name like empty (which is also names a core function BTW): () I recommend people not use '() in Clojure, it's ugly and unnecessary. Rich --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: how to learn clojure ?
On Wed, Feb 18, 2009 at 9:04 AM, Joshua Fox wrote: > Try this book http://www.pragprog.com/titles/shcloj/programming-clojure > Agreed, that book is a good introduction to Lisp and Clojure for programmers from other backgrounds, as are the Clojure for Java Programmers screencasts at http://clojure.blip.tv. --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: clojure.xml & whitespace
Mark Volkmann a écrit : > On Wed, Feb 18, 2009 at 7:40 AM, Christophe Grand > wrote: > >> Remco van 't Veer a écrit : >> >>> Maybe *ignore-whitespace* is a beter name since it doesn't remove >>> anything and will retain some of it. I would prefer it to default to >>> true. >>> >>> >> I would prefer it to default to false since it's the standard way to >> handle whitespace in XML. (Ignorable whitespaces are always ignored by >> clojure.xml.) >> > > I agree. That would be consistent with Apache Xerces which also uses > that term and retains all whitespace by default. > Patch attached. Mark, by "all whitespace" do you mean all significant whitespaces or really all whitespaces (including ignorable whitespaces)? -- Professional: http://cgrand.net/ (fr) On Clojure: http://clj-me.blogspot.com/ (en) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~--- diff --git a/src/clj/clojure/xml.clj b/src/clj/clojure/xml.clj index 251f16c..0dfae98 100644 --- a/src/clj/clojure/xml.clj +++ b/src/clj/clojure/xml.clj @@ -10,6 +10,9 @@ (:import (org.xml.sax ContentHandler Attributes SAXException) (javax.xml.parsers SAXParser SAXParserFactory))) +(def #^{:doc "When set to true clojure.xml/parse ignores significant whitespace."} + *ignore-whitespace* false) + (def *stack*) (def *current*) (def *state*) ; :element :chars :between @@ -25,8 +28,9 @@ (let [push-content (fn [e c] (assoc e :content (conj (or (:content e) []) c))) push-chars (fn [] - (when (and (= *state* :chars) -(some (complement #(. Character (isWhitespace %))) (str *sb*))) + (when (and (= *state* :chars) +(not (and *ignore-whitespace* + (every? #(. Character (isWhitespace %)) (str *sb*) (set! *current* (push-content *current* (str *sb*)] (new clojure.lang.XMLHandler (proxy [ContentHandler] []
Re: how to learn clojure ?
Try this book http://www.pragprog.com/titles/shcloj/programming-clojure On Wed, Feb 18, 2009 at 2:53 PM, MarisO wrote: > > All documentation I've seen about clojure assumes knowledge of lisp > which I dont have. > > > > --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
bug affecting clojure.core/bean?
Hi, I'm wondering if I found a bug. I have the latest source from svn (r1291). user=> (bean 1) java.lang.IllegalArgumentException: Wrong number of args passed to: core$bean--5161$fn--5179$thisfn It used to show the bean properties of the java.lang.Integer. Rob --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
how to learn clojure ?
All documentation I've seen about clojure assumes knowledge of lisp which I dont have. --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
how to learn clojure ?
All documentation I've seen about clojure assumes knowledge of lisp which I dont have. --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: clojure.xml & whitespace
On Wed, Feb 18, 2009 at 7:40 AM, Christophe Grand wrote: > > Remco van 't Veer a écrit : >> Maybe *ignore-whitespace* is a beter name since it doesn't remove >> anything and will retain some of it. I would prefer it to default to >> true. >> > > I would prefer it to default to false since it's the standard way to > handle whitespace in XML. (Ignorable whitespaces are always ignored by > clojure.xml.) I agree. That would be consistent with Apache Xerces which also uses that term and retains all whitespace by default. -- R. Mark Volkmann Object Computing, Inc. --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: clojure.xml & whitespace
Remco van 't Veer a écrit : > Maybe *ignore-whitespace* is a beter name since it doesn't remove > anything and will retain some of it. I would prefer it to default to > true. > I would prefer it to default to false since it's the standard way to handle whitespace in XML. (Ignorable whitespaces are always ignored by clojure.xml.) Christophe -- Professional: http://cgrand.net/ (fr) On Clojure: http://clj-me.blogspot.com/ (en) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: clojure.xml & whitespace
> > On Wed, Feb 18, 2009 at 12:59 PM, Christophe Grand > > wrote: > > > clojure.xml currently removes significant whitespaces. I guess that > > people processing xml as data want this behavior (while people > > processing xml as mark-up don't). What's the best way to accomodate > > these to use cases? Through a *remove-all-whitespaces* var? > > > Christophe > > > -- > > Professional:http://cgrand.net/(fr) > > On Clojure:http://clj-me.blogspot.com/(en) On Feb 18, 6:29 am, "Remco van 't Veer" wrote: > Maybe *ignore-whitespace* is a beter name since it doesn't remove > anything and will retain some of it. I would prefer it to default to > true. It's not obvious which thing a true value for *ignore-whitespace* does; "ignore" in the sense of pretend it in't there? Or "ignore" in the sense of skip over it, but leave it in? Maybe the Common Lisp convention would be more clear: *preserve- whitespace* --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: clojure.xml & whitespace
Maybe *ignore-whitespace* is a beter name since it doesn't remove anything and will retain some of it. I would prefer it to default to true. On Wed, Feb 18, 2009 at 12:59 PM, Christophe Grand wrote: > > clojure.xml currently removes significant whitespaces. I guess that > people processing xml as data want this behavior (while people > processing xml as mark-up don't). What's the best way to accomodate > these to use cases? Through a *remove-all-whitespaces* var? > > Christophe > > -- > Professional: http://cgrand.net/ (fr) > On Clojure: http://clj-me.blogspot.com/ (en) > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Fully lazy sequences are here!
I believe it's already done. Frantisek On Feb 18, 12:39 pm, Mark Volkmann wrote: > Now that next is recommended over rest, should nthrest be renamed to nthnext? > > -- > R. Mark Volkmann > Object Computing, Inc. --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
clojure.xml & whitespace
clojure.xml currently removes significant whitespaces. I guess that people processing xml as data want this behavior (while people processing xml as mark-up don't). What's the best way to accomodate these to use cases? Through a *remove-all-whitespaces* var? Christophe -- Professional: http://cgrand.net/ (fr) On Clojure: http://clj-me.blogspot.com/ (en) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Fully lazy sequences are here!
Now that next is recommended over rest, should nthrest be renamed to nthnext? -- R. Mark Volkmann Object Computing, Inc. --~--~-~--~~~---~--~~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---