Re: Clojure ad on StackOverflow.com
I'd vote for it. *smiles* On Feb 8, 2:23 am, Baishampayan Ghose b.gh...@ocricket.com wrote: Hi, This is an interesting attempt by the StackOverflow people to promote FOSS projectshttp://meta.stackoverflow.com/questions/31913/open-source-advertising sidebar-1h-2010/31972 (http://bit.ly/so-foss-ads) I think we should create a couple of Clojure ads and vote them up. Regards, BG -- Baishampayan Ghose b.gh...@ocricket.com oCricket.com -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
newbie encountering java.lang.OutOfMemoryError: Java heap space
Hi all. I'm trying to learn clojure with the excellent Programming Clojure and projecteuler.net. I am encountering the java heap space error, and can't find a workaround, nor a smarter way to write my code (which I am certain exist). Trying to solve Problem 14 (some spoilers might be ahead, for those wanting to solve it in the future). The problem and my code are in https://pastee.org/hj3sh here is the problem: I am trying to produce a map of one O(million) key-value pairs using a recursive function. I can produce a map of the first 10 numbers in ~1300 msecs, with 217211 keys. However, for 15 and up, I get java.lang.OutOfMemoryError: Java heap space. so, I assume my code is ok on efficiency, but the recursion is too deep. am I right? can anyone suggest a way to overcome this problem? any additional tips and thoughts on the code would be of great help to me, as I am making my first steps in clojure. Thank you, Aviad -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
XML problem
Hello Clojure group I am testing Clojure and I have an error parsing thix XML excerpt below. Is this a SAX bug ou a Clojure bug .. or my mistake ? thank's for help IN REPL (ns x (:require [clojure.xml :as xml]) ) x= (try (xml/parse exampleSortieXML.xml)(catch Exception e (. e printStackTrace) )) ANWSER *** org.xml.sax.SAXParseException: The reference to entity utmn must end with the ';' delimiter. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java: 195) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java: 174) Etc... XML file ** traffic entry statusCode=200 method=GET url=http://www.google- analytics.com/__utm.gif? utmwv=4.6.5utmn=1786408720utmhn=www.witbe.netutmcs=UTF-8utmsr=1680x1050utmsc=24- bitutmul=frutmje=1utmfl=10.0%20r42utmcn=1utmdt=Witbe%20-%20v %C3%A9ritable%20supervision%20de%20bout%20en%20bout%20et%20monitoring %20de%20la%20Qualit%C3%A9%20d%27Exp%C3%A9rience%20%3A%20Syst%C3%A8mes %20d%27Information%20et%20Services%20Multi- playutmhid=2134295609utmr=-utmp=%2Fqoe%2Findex.php %2FAccueil.htmlutmac=UA-7415175-1utmcc=__utma %3D218258335.1952450742.1265618759.1265618759.1265618759.1%3B%2B__utmz %3D218258335.1265618759.1.1.utmcsr%3D(direct)%7Cutmccn%3D(direct) %7Cutmcmd%3D(none)%3B bytes=35 start=2010-02-08T09:45:58.811+0100 end=2010-02-08T09:45:58.922+0100 timeInMillis=111 /entry /traffic -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Newbie question - Functional programming special cases
Thanks, that answers my questions. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Clojure Dev Environment
Hi, There are several blog posts about setting up a development environment for Clojure mostly in Emacs (and on Linux or Mac and not Windows). Is there one place where I can find up-to-date information on how to create a real-world Clojure project (and using Clojure and Java libraries)? Do you know of someone who maintains such information for newbies anywhere? I can't find such information on Clojure website. - I tried Clojure some time ago and I like it. But I was struggling with Emacs at the same time. - I am getting an error with Enclojure that it cannot find the jar files even though they are located in the prefs foloder. - La Clojure's plugin is not working in Idea 9. Thanks for any help -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
How would I write an emitter/collector?
I know that loo exists - and I'm puzzled by what the lazy functions do. What I think would be interesting functionality is to have an emitter/ collector combination, for example: (collect (doseq [ n (range 10)] (when (even? n) (emit n would return the list (0 2 4 6 8). Any ideas how I could implement this? You might ask why anybody would want this. Well, I think it would be neat because it separates your logic from actual looping mechanics. I'm saying I don't care how the list is constructed, just as long as it is. I know there are functions like filter that would be better in this particular example - but I'm only using it for illustrative purposes. It would also allow you do do something like (collect (doseq [ n (range 10)] (when (even? n) (emit n) (emit (* 2 n) to give you the list (0 0 2 4 4 8 6 12 8 16). Admittedly this particular example might not be of much use; but the general idea is that it allows you to collect all sorts of weird and wonderful things, possibly involving complicated logic as to when/if you want things collection. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Prepping clojure for packaging (was: Re: Clojure for system administration)
That's exactly what Debian does. For every Java package also provide the maven xml file and the jar is discoverable from maven. The installed packages on the local system acts as a local maven repo. http://wiki.debian.org/Java/MavenRepoSpec I see they also solved the problem of not downloading during build. Just FYI, with Maven, the first time you run a build it downloads all the needed dependencies. If you've specified version numbers for ALL the dependencies it will never try to download them again and just use the ones in your local repo (i.e. ~/.m2/repositories). You can also disable dependency updates with the '-o' flag (o stands for offline); for example: 'maven clean install -o' -- ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Brian Schlining bschlin...@gmail.com -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Clojure binding for Open CL
Hi, I was just wondering if (by now) Open CL has been 'wrapped' by higher level languages. I came across these from the Khronos site (http:// www.khronos.org/developers/resources/opencl/#timplementations) - 1. http://ruby-opencl.rubyforge.org/ 2. http://planet.plt-scheme.org/display.ss?package=opencl.pltowner=jaymccarthy 3. http://mathema.tician.de/software/pyopencl Wondering if anyone is already working on a Open CL binding. I would love if I can code in clojure and it runs through Open CL drivers :) on my Radeon! Thanks! -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: newbie encountering java.lang.OutOfMemoryError: Java heap space
(Disclaimer: never tried myself) http://hausheer.osola.com/docs/5 2010/2/10 Aviad R avi@gmail.com Hi all. I'm trying to learn clojure with the excellent Programming Clojure and projecteuler.net. I am encountering the java heap space error, and can't find a workaround, nor a smarter way to write my code (which I am certain exist). Trying to solve Problem 14 (some spoilers might be ahead, for those wanting to solve it in the future). The problem and my code are in https://pastee.org/hj3sh here is the problem: I am trying to produce a map of one O(million) key-value pairs using a recursive function. I can produce a map of the first 10 numbers in ~1300 msecs, with 217211 keys. However, for 15 and up, I get java.lang.OutOfMemoryError: Java heap space. so, I assume my code is ok on efficiency, but the recursion is too deep. am I right? can anyone suggest a way to overcome this problem? any additional tips and thoughts on the code would be of great help to me, as I am making my first steps in clojure. Thank you, Aviad -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- Communication is essential. So we need decent tools when communication is lacking, when language capability is hard to acquire... - http://esperanto.net - http://esperanto-jongeren.nl Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure binding for Open CL
Not sure about Clojure bindings but the JavaCL bindings (both mid-level and low level) might get you closer: http://code.google.com/p/javacl/ OpenCL's ugly and finicky API is crying out for wrapping in better languages; and the OpenCL language itself would ideally get wrapped as well (see: http://ochafik.free.fr/blog/?p=207 ) We also have pretty experimental OpenCL framework, here — http://openendedgroup.com/field/wiki/BaseGraphicsSystem_OpenCL. That also binds to Java. While it isn't as well tested as either of the links above it does integrate OpenCL into an OpenGL-based graphics system which is something you might ultimately be interested in. best, Marc. On Tue, Feb 9, 2010 at 10:48 PM, ka sancha...@gmail.com wrote: Hi, I was just wondering if (by now) Open CL has been 'wrapped' by higher level languages. I came across these from the Khronos site (http:// www.khronos.org/developers/resources/opencl/#timplementations) - 1. http://ruby-opencl.rubyforge.org/ 2. http://planet.plt-scheme.org/display.ss?package=opencl.pltowner=jaymccarthy 3. http://mathema.tician.de/software/pyopencl Wondering if anyone is already working on a Open CL binding. I would love if I can code in clojure and it runs through Open CL drivers :) on my Radeon! Thanks! -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojure gen-class questions
thanks! -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure Dev Environment
2010/2/9 abaitam abai...@gmail.com: Hi, There are several blog posts about setting up a development environment for Clojure mostly in Emacs (and on Linux or Mac and not Windows). Is there one place where I can find up-to-date information on how to create a real-world Clojure project (and using Clojure and Java libraries)? Do you know of someone who maintains such information for newbies anywhere? I can't find such information on Clojure website. - I tried Clojure some time ago and I like it. But I was struggling with Emacs at the same time. - I am getting an error with Enclojure that it cannot find the jar files even though they are located in the prefs foloder. - La Clojure's plugin is not working in Idea 9. Try Eclipse counterclockwise: http://vimeo.com/channels/fulldisclojure#9223070 http://www.youtube.com/watch?v=1T0ZjBMIQS8 then http://code.google.com/p/counterclockwise/wiki/Documentation#Install_Counterclockwise_plugin HTH, -- Laurent -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How would I write an emitter/collector?
This type of stuff could be done easily w/ the existing sequence fns You first one is simply (filter even? (range 10)) The second one is a little trickier, but it could be written like this (map (juxt identity #(* 2 %)) (filter even? (range 10))) This is usually considered better form than using when/if directly. Now, these are finite examples. If you wanted an infinite lazy seq, you could substitute (interate inc 1) for (range 10). Just be very careful evaluating this at a REPL. Unless I missed the point of your post entirely. Sean On Feb 10, 7:23 am, Mark Carter alt.mcar...@googlemail.com wrote: I know that loo exists - and I'm puzzled by what the lazy functions do. What I think would be interesting functionality is to have an emitter/ collector combination, for example: (collect (doseq [ n (range 10)] (when (even? n) (emit n would return the list (0 2 4 6 8). Any ideas how I could implement this? You might ask why anybody would want this. Well, I think it would be neat because it separates your logic from actual looping mechanics. I'm saying I don't care how the list is constructed, just as long as it is. I know there are functions like filter that would be better in this particular example - but I'm only using it for illustrative purposes. It would also allow you do do something like (collect (doseq [ n (range 10)] (when (even? n) (emit n) (emit (* 2 n) to give you the list (0 0 2 4 4 8 6 12 8 16). Admittedly this particular example might not be of much use; but the general idea is that it allows you to collect all sorts of weird and wonderful things, possibly involving complicated logic as to when/if you want things collection. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Prepping clojure for packaging (was: Re: Clojure for system administration)
Hi, On Feb 10, 12:31 am, Brian Schlining bschlin...@gmail.com wrote: That's exactly what Debian does. For every Java package also provide the maven xml file and the jar is discoverable from maven. The installed packages on the local system acts as a local maven repo. http://wiki.debian.org/Java/MavenRepoSpec I see they also solved the problem of not downloading during build. Just FYI, with Maven, the first time you run a build it downloads all the needed dependencies. If you've specified version numbers for ALL the dependencies it will never try to download them again and just use the ones in your local repo (i.e. ~/.m2/repositories). You can also disable dependency updates with the '-o' flag (o stands for offline); for example: 'maven clean install -o' I would also think, that you can construct a local maven repository via the packaging system (deb in this case) before the build. Then tell maven just to use this repository. Then no download at package build time would be necessary, no? Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: XML problem
Hello Yvan, I guess it's neither a clojure nor java SAX parser problem, but rather a problem in the xml file itself. It is illegal to have ampersands in attributes values. The ampersand should be replaced by amp; everywhere in attribute values. In other case, the xml parser tries to resolve what begins with and ends with ; as an xml entity and replace it with the xml entity value. Is the xml produced by hand, or by string concatenation, rather than produced by an xml producer ? 2010/2/10 yvan yvan.go...@gmail.com: Hello Clojure group I am testing Clojure and I have an error parsing thix XML excerpt below. Is this a SAX bug ou a Clojure bug .. or my mistake ? thank's for help IN REPL (ns x (:require [clojure.xml :as xml]) ) x= (try (xml/parse exampleSortieXML.xml)(catch Exception e (. e printStackTrace) )) ANWSER *** org.xml.sax.SAXParseException: The reference to entity utmn must end with the ';' delimiter. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java: 195) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java: 174) Etc... XML file ** traffic entry statusCode=200 method=GET url=http://www.google- analytics.com/__utm.gif? utmwv=4.6.5utmn=1786408720utmhn=www.witbe.netutmcs=UTF-8utmsr=1680x1050utmsc=24- bitutmul=frutmje=1utmfl=10.0%20r42utmcn=1utmdt=Witbe%20-%20v %C3%A9ritable%20supervision%20de%20bout%20en%20bout%20et%20monitoring %20de%20la%20Qualit%C3%A9%20d%27Exp%C3%A9rience%20%3A%20Syst%C3%A8mes %20d%27Information%20et%20Services%20Multi- playutmhid=2134295609utmr=-utmp=%2Fqoe%2Findex.php %2FAccueil.htmlutmac=UA-7415175-1utmcc=__utma %3D218258335.1952450742.1265618759.1265618759.1265618759.1%3B%2B__utmz %3D218258335.1265618759.1.1.utmcsr%3D(direct)%7Cutmccn%3D(direct) %7Cutmcmd%3D(none)%3B bytes=35 start=2010-02-08T09:45:58.811+0100 end=2010-02-08T09:45:58.922+0100 timeInMillis=111 /entry /traffic -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure binding for Open CL
From his todo list (1), it looks as if ztellman (2) might have concrete plans to include it in the (currently OpenGL) wrapper project penumbra (3). 1. http://wiki.github.com/ztellman/penumbra/todo 2. http://ideolalia.com/ 3. http://github.com/ztellman/penumbra On Feb 9, 9:48 pm, ka sancha...@gmail.com wrote: Hi, I was just wondering if (by now) Open CL has been 'wrapped' by higher level languages. I came across these from the Khronos site (http://www.khronos.org/developers/resources/opencl/#timplementations) - 1.http://ruby-opencl.rubyforge.org/ 2.http://planet.plt-scheme.org/display.ss?package=opencl.pltowner=jaym... 3.http://mathema.tician.de/software/pyopencl Wondering if anyone is already working on a Open CL binding. I would love if I can code in clojure and it runs through Open CL drivers :) on my Radeon! Thanks! -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: XML problem
Here is the proof I was searching ! http://www.w3.org/TR/xml/#NT-AttValue 2010/2/10 Laurent PETIT laurent.pe...@gmail.com: Hello Yvan, I guess it's neither a clojure nor java SAX parser problem, but rather a problem in the xml file itself. It is illegal to have ampersands in attributes values. The ampersand should be replaced by amp; everywhere in attribute values. In other case, the xml parser tries to resolve what begins with and ends with ; as an xml entity and replace it with the xml entity value. Is the xml produced by hand, or by string concatenation, rather than produced by an xml producer ? 2010/2/10 yvan yvan.go...@gmail.com: Hello Clojure group I am testing Clojure and I have an error parsing thix XML excerpt below. Is this a SAX bug ou a Clojure bug .. or my mistake ? thank's for help IN REPL (ns x (:require [clojure.xml :as xml]) ) x= (try (xml/parse exampleSortieXML.xml)(catch Exception e (. e printStackTrace) )) ANWSER *** org.xml.sax.SAXParseException: The reference to entity utmn must end with the ';' delimiter. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java: 195) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java: 174) Etc... XML file ** traffic entry statusCode=200 method=GET url=http://www.google- analytics.com/__utm.gif? utmwv=4.6.5utmn=1786408720utmhn=www.witbe.netutmcs=UTF-8utmsr=1680x1050utmsc=24- bitutmul=frutmje=1utmfl=10.0%20r42utmcn=1utmdt=Witbe%20-%20v %C3%A9ritable%20supervision%20de%20bout%20en%20bout%20et%20monitoring %20de%20la%20Qualit%C3%A9%20d%27Exp%C3%A9rience%20%3A%20Syst%C3%A8mes %20d%27Information%20et%20Services%20Multi- playutmhid=2134295609utmr=-utmp=%2Fqoe%2Findex.php %2FAccueil.htmlutmac=UA-7415175-1utmcc=__utma %3D218258335.1952450742.1265618759.1265618759.1265618759.1%3B%2B__utmz %3D218258335.1265618759.1.1.utmcsr%3D(direct)%7Cutmccn%3D(direct) %7Cutmcmd%3D(none)%3B bytes=35 start=2010-02-08T09:45:58.811+0100 end=2010-02-08T09:45:58.922+0100 timeInMillis=111 /entry /traffic -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: error reporting for macro expansion
+1 on this. Although of course you could just use the shell for this (e.g. grep or awk). But it's certainly nicer to have that integrated in the compiler (possibly also in the compiled code?) On Feb 9, 12:45 pm, Jeff Rose ros...@gmail.com wrote: I agree, the error reporting from the compiler can often be hard to dig through. Besides showing both the location of the macro definition and its usage, it would be nice to hide all of the clojure.lang.* calls in the stack trace by default, or fold them into a single line. That way the user code in the callstack would be separated by 1 line rather 10 or 20, so you could more easily trace the execution path. On Feb 8, 8:11 pm, John R. Williams shponglesp...@gmail.com wrote: The Clojure compiler is not very helpful when it comes to debugging exceptions that occur while macros are being expanded. As an example, consider this code: ;; macro-fail.clj (defmacro broken [] (/ 0 0)) (broken) Here's the stack trace I get when I compile this file: Exception in thread main java.lang.ArithmeticException: Divide by zero (macro-fail.clj:0) at clojure.lang.Compiler.eval(Compiler.java:5365) at clojure.lang.Compiler.load(Compiler.java:5759) at clojure.lang.Compiler.loadFile(Compiler.java:5722) at clojure.main$load_script__5893.invoke(main.clj:213) at clojure.main$script_opt__5922.invoke(main.clj:265) at clojure.main$main__5940.doInvoke(main.clj:346) at clojure.lang.RestFn.invoke(RestFn.java:409) at clojure.lang.Var.invoke(Var.java:365) at clojure.lang.AFn.applyToHelper(AFn.java:165) at clojure.lang.Var.applyTo(Var.java:482) at clojure.main.main(main.java:37) Caused by: java.lang.ArithmeticException: Divide by zero at clojure.lang.Numbers.divide(Numbers.java:138) at user$broken__1.invoke(macro-fail.clj:2) at clojure.lang.Var.invoke(Var.java:369) at clojure.lang.AFn.applyToHelper(AFn.java:167) at clojure.lang.Var.applyTo(Var.java:482) at clojure.lang.Compiler.macroexpand1(Compiler.java:5212) at clojure.lang.Compiler.macroexpand(Compiler.java:5267) at clojure.lang.Compiler.eval(Compiler.java:5335) ... 10 more As you can see, line 3, where the macro is used, appears nowhere in the stack trace. I've made some progress addressing this issue by adding an exception handler in Compiler.macroexpand1. I also discovered that, although the reader attaches line numbers to the forms it reads, it does not attach file names. I've added some code in LispReader.java that attaches the file name, but it does so by getting the value of Compiler.SOURCE_PATH. I suspect a less hackish fix would involve passing a filename to the reader some other way. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How would I write an emitter/collector?
On 10 Feb, 12:23, Mark Carter alt.mcar...@googlemail.com wrote: Any ideas how I could implement this? I've made a stab at it, but I'm not there yet. (import (java.util ArrayList List)) (defn arraylist-list [aList] (let [size (. aList size)] (loop [accum nil index 0] (if ( index size) (recur (concat accum (list (. aList get index))) (inc index)) accum (defn collect-lambda [f] (let [alist (new ArrayList) emit (fn [new-member] (. alist add new-member))] (f emit) (arraylist-list alist))) So far, so good. Now I can type (collect-lambda (fn [emit] (emit 1) (emit 2))) and get the result (1 2) - which is what we expect. There's a lot of goo there, though, which would be nice to eliminate via a macro. I really want to be able to say that emit is part of my syntax. To try to solve this problem, I started out by defining unpartial - which is kind of the opposite of partial: (defmacro unpartial [x body] `(fn [~x] ~...@body)) Seems an odd thing to do just now, but there's a logic to it. I can do things like ((unpartial y (+ y 2)) 3) and get the value 5 - again, this is what I expect. I now try to define the macro that I'm really interested in: (defmacro collect [ body] `(let [f# (unpartial emit ~...@body)] (collect-lambda f#))) Admittedly, my understanding of composing macros is very shaky. However, when I do (collect (emit 1) (emit 2)) expecting the result (1 2), I instead get the error java.lang.Exception: Can't use qualified name as parameter: user/emit Grrr. How can I fix this? I can get closer if I define collect as (defmacro collect [emitter body] `(let [f# (unpartial ~emitter ~...@body)] (collect-lambda f#))) and use it by (collect emit (emit 15) (emit 6)) to return (15 6). But I'd rather like to be able to omit the emit parameter. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: newbie encountering java.lang.OutOfMemoryError: Java heap space
thank you. I have -server and -Xmx1024m set in my 'swank-clojure-extra-vm-args, but the problem remains. Aviad On 10 February 2010 15:57, Joop Kiefte iko...@gmail.com wrote: (Disclaimer: never tried myself) http://hausheer.osola.com/docs/5 2010/2/10 Aviad R avi@gmail.com Hi all. I'm trying to learn clojure with the excellent Programming Clojure and projecteuler.net. I am encountering the java heap space error, and can't find a workaround, nor a smarter way to write my code (which I am certain exist). Trying to solve Problem 14 (some spoilers might be ahead, for those wanting to solve it in the future). The problem and my code are in https://pastee.org/hj3sh here is the problem: I am trying to produce a map of one O(million) key-value pairs using a recursive function. I can produce a map of the first 10 numbers in ~1300 msecs, with 217211 keys. However, for 15 and up, I get java.lang.OutOfMemoryError: Java heap space. so, I assume my code is ok on efficiency, but the recursion is too deep. am I right? can anyone suggest a way to overcome this problem? any additional tips and thoughts on the code would be of great help to me, as I am making my first steps in clojure. Thank you, Aviad -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- Communication is essential. So we need decent tools when communication is lacking, when language capability is hard to acquire... - http://esperanto.net - http://esperanto-jongeren.nl Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How would I write an emitter/collector?
Hi, On Feb 10, 1:23 pm, Mark Carter alt.mcar...@googlemail.com wrote: I know that loo exists - and I'm puzzled by what the lazy functions do. What I think would be interesting functionality is to have an emitter/ collector combination, for example: (collect (doseq [ n (range 10)] (when (even? n) (emit n would return the list (0 2 4 6 8). Any ideas how I could implement this? You might ask why anybody would want this. Well, I think it would be neat because it separates your logic from actual looping mechanics. I'm saying I don't care how the list is constructed, just as long as it is. I know there are functions like filter that would be better in this particular example - but I'm only using it for illustrative purposes. It would also allow you do do something like (collect (doseq [ n (range 10)] (when (even? n) (emit n) (emit (* 2 n) to give you the list (0 0 2 4 4 8 6 12 8 16). Admittedly this particular example might not be of much use; but the general idea is that it allows you to collect all sorts of weird and wonderful things, possibly involving complicated logic as to when/if you want things collection. I don't think, what you want to do is very idiomatic for clojure. It is more idiomatic to provide a way to obtain a seq on your data structure and then use other means like map, to get the desired result. Your examples can be written as: (mapcat #(when (even? %) [(emit %)]) (range 10)) and (mapcat #(when (even? %) [(emit %) (emit (* 2 %))]) (range 10)) This consists can be generalised as (defn collect-lambda [emitter collector coll] (mapcat (collector emitter) coll)) Again your examples: (collect-lambda emit (fn [emit] (fn [n] (when (even? n) [(emit n)]))) (range 10)) and (collect-lambda emit (fn [emit] (fn [n] (when (even? n) [(emit n) (emit (* 2 n))]))) (range 10)) Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How would I write an emitter/collector?
It looks like you want to implement something akin to what other languages call generators. In Clojure, we generally use list comprehensions to get (almost) the same effect, but it's a little cleaner in my opinion. eg. in your first two examples (collect (doseq [ n (range 10)] (when (even? n) (emit n ;;becomes: (for [n (range 10) :when (even? n)] n) (collect (doseq [ n (range 10)] (when (even? n) (emit n) (emit (* 2 n) ;;becomes: (for [n (range 10)] (if (even? n) n (* 2 n))) It's almost as expressive as what you want, except that decomposes nicely and efficiently into filter and map functions. I would recommend that you try those out first and see how they feel. If you REALLY want your emit and collect functions, here's one possible implementation. The only tricky part you need to watch out for is the ~'collector escaping. (def -collector) (defn emit [x] (set! -collector (conj -collector x))) (defmacro collect [ body] `(binding [~'-collector []] ~...@body ~'-collector)) Your examples work nicely with this. Hope this is helpful -Patrick -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Problems using clojure.contrib.string
Hello Group, I'm working on a Clojure project and I'm using Leiningen for the builds. I'm trying to use the most recent clojure and clojure- contrib, but I'm having a problem getting it to compile due to apparent errors in clojure.contrib.string. This works fine on the more stable versions of these libraries, which use clojure.contrib.str- utils2. Here's my project file: (defproject myproj 0.1 :dependencies [[org.clojure/clojure 1.2.0-master-SNAPSHOT] [org.clojure/clojure-contrib 1.2.0-SNAPSHOT]] :main myproj) And I'm later using clojure.contrib.string as such: (ns myproj (:gen-class) (:require [clojure.contrib.string :as str-utils :only (join)]) (:import (java.io File FileNotFoundException BufferedReader InputStreamReader OutputStreamWriter))) I'm then using the str-utils/join function in the code, but I can't get it to compile. I get the following Java exceptions when doing lein compile: java.lang.RuntimeException: java.lang.IllegalArgumentException: Unable to resolve classname: Replacement snip at clojure.main.main(main.java:37) Caused by: java.lang.IllegalArgumentException: Unable to resolve classname: Replacement at clojure.lang.Compiler$HostExpr.tagToClass(Compiler.java:893) I also get this a couple of times: [null] java.lang.VerifyError: (class: clojure/contrib/string $replace_first_re__81, method: invoke signature: (Ljava/lang/ Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;) Unable to pop operand off an empty stack snip at clojure.main.main(main.java:37) [null] Caused by: java.lang.VerifyError: (class: clojure/contrib/ string$replace_first_re__81, method: invoke signature: (Ljava/lang/ Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;) Unable to pop operand off an empty stack Any ideas here? Not a big deal as I can just use the older code. Thanks, Matt -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How would I write an emitter/collector?
There are some bugs with my previous post. Here's a revised version. ;;--USING LIST COMPREHENSIONS--- (for [n (range 10) :when (even? n)] n) (apply concat (for [n (range 10) :when (even? n)] [n (* 2 n)])) ;;EMIT/COLLECT IMPLEMENTATION-- (def -collector) (defn emit [x] (set! -collector (conj -collector x))) (defmacro collect [ body] `(binding [-collector []] ~...@body -collector)) ;;USING EMIT/COLLECT- (collect (doseq [ n (range 10)] (when (even? n) (emit n (apply concat (for [n (range 10) :when (even? n)] [n (* 2 n)])) Sincerely -Patrick -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How would I write an emitter/collector?
Patrick, I can't speak for the OP, but I found his question interesting and I'd like to compliment you on your response. You gave alternative Clojure-like ways to do the same thing, but in addition to that you actually answered his question. I find these kinds of responses very instructive because you don't ignore the OP's request when juxtaposing your alternative suggestion. It helps them make a better decision about what route they want to go. Thanks, - Greg On Feb 10, 2010, at 10:40 AM, CuppoJava wrote: It looks like you want to implement something akin to what other languages call generators. In Clojure, we generally use list comprehensions to get (almost) the same effect, but it's a little cleaner in my opinion. eg. in your first two examples (collect (doseq [ n (range 10)] (when (even? n) (emit n ;;becomes: (for [n (range 10) :when (even? n)] n) (collect (doseq [ n (range 10)] (when (even? n) (emit n) (emit (* 2 n) ;;becomes: (for [n (range 10)] (if (even? n) n (* 2 n))) It's almost as expressive as what you want, except that decomposes nicely and efficiently into filter and map functions. I would recommend that you try those out first and see how they feel. If you REALLY want your emit and collect functions, here's one possible implementation. The only tricky part you need to watch out for is the ~'collector escaping. (def -collector) (defn emit [x] (set! -collector (conj -collector x))) (defmacro collect [ body] `(binding [~'-collector []] ~...@body ~'-collector)) Your examples work nicely with this. Hope this is helpful -Patrick -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How would I write an emitter/collector?
On 10 Feb, 15:57, CuppoJava patrickli_2...@hotmail.com wrote: Here's a revised version. OK. Wow guys. Thanks for your help. I've still a lot to learn, being new to Java, Lisp and Clojure. You are right, generators was the kind of thing I was after. I had come to Clojure after I had given up on VB.Net, and was looking for an alternative. I found VB.Net to be a bit flaky and complicated - and my doesn't it crank out a lot of boiler plate code behind the scenes. I also had weird installation problems on other people's machines. The assemblies had weird permissions - something I was not in a position to correct. So I decided that .Net was not for me, and tried to see what else was out there. I'm a pretty reasonable python programmer, but I find Lispy languages alluring. I've been able to get Java to interoperate with MS Access and Excel, so so far Clojure is looking like something I can use. All the best. Mark. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How would I write an emitter/collector?
It sounds like Clojure might be a good fit for you then. I personally came to Clojure after getting fed up with Java, and experimenting with Ruby, so I can understand your predicament. The most dangerous thing to watch out for, and this really can't be stressed enough, is that learning Clojure is much easier if you actively try and forget the way you do things in other languages. From my experience, you really cannot jump into doing advanced things (eg. like generators) straight away because Clojure offers a completely different set of basic tools. And the only way to learn how to use those basic tools, is by writing programs from scratch, in the most straight-forward way possible. For this reason, I also strongly advise against trying to learn Clojure by porting an existing program. That is how I attempted to first learn Clojure and I realized much later that I didn't get anything out of it. Have fun -Patrick PS: Thanks for the kind comments Greg. This question stuck out to me because it really wasn't too long ago when I asked exactly the same thing, and some nice people helped me out in exactly the same way. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojure gen-class questions
yes,thank you, this looks very helpful On Feb 9, 3:44 pm, Meikel Brandmeyer m...@kotka.de wrote: Hi, I wrote up a post:http://tr.im/NwCL Hope it helps. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: newbie encountering java.lang.OutOfMemoryError: Java heap space
Aviad, Welcome to Clojure. I don't want to tell you how to solve it. That's all part of the fun. But my hint to you would be that you don't need to keep all 1 million lists in memory. In fact, you should be able to solve this problem by only keeping three numbers in memory at any one time: The number that has produced the longest chain, the size of the longest chain and the size of the current chain you are working on. Also, as I was recently reminded by this group, it is never a good idea to use def within a function. This problem can be solved using only pure functions. Good luck, Brenton On Feb 10, 7:13 am, Aviad Reich avi@gmail.com wrote: thank you. I have -server and -Xmx1024m set in my 'swank-clojure-extra-vm-args, but the problem remains. Aviad On 10 February 2010 15:57, Joop Kiefte iko...@gmail.com wrote: (Disclaimer: never tried myself) http://hausheer.osola.com/docs/5 2010/2/10 Aviad R avi@gmail.com Hi all. I'm trying to learn clojure with the excellent Programming Clojure and projecteuler.net. I am encountering the java heap space error, and can't find a workaround, nor a smarter way to write my code (which I am certain exist). Trying to solve Problem 14 (some spoilers might be ahead, for those wanting to solve it in the future). The problem and my code are inhttps://pastee.org/hj3sh here is the problem: I am trying to produce a map of one O(million) key-value pairs using a recursive function. I can produce a map of the first 10 numbers in ~1300 msecs, with 217211 keys. However, for 15 and up, I get java.lang.OutOfMemoryError: Java heap space. so, I assume my code is ok on efficiency, but the recursion is too deep. am I right? can anyone suggest a way to overcome this problem? any additional tips and thoughts on the code would be of great help to me, as I am making my first steps in clojure. Thank you, Aviad -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- Communication is essential. So we need decent tools when communication is lacking, when language capability is hard to acquire... -http://esperanto.net -http://esperanto-jongeren.nl Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: XML problem
Hi, yvan wrote: Hello Clojure group I am testing Clojure and I have an error parsing thix XML excerpt below. Is this a SAX bug ou a Clojure bug .. or my mistake ? thank's for help IN REPL (ns x (:require [clojure.xml :as xml]) ) x= (try (xml/parse exampleSortieXML.xml)(catch Exception e (. e printStackTrace) )) ANWSER *** org.xml.sax.SAXParseException: The reference to entity utmn must end with the ';' delimiter. Your XML is not valid, you must escape all with amp; The excerp UTF-8utmsr should thus be UTF-8amp;utmsr. Alex at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java: 195) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java: 174) Etc... XML file ** traffic entry statusCode=200 method=GET url=http://www.google- analytics.com/__utm.gif? utmwv=4.6.5utmn=1786408720utmhn=www.witbe.netutmcs=UTF-8utmsr=1680x1050utmsc=24- bitutmul=frutmje=1utmfl=10.0%20r42utmcn=1utmdt=Witbe%20-%20v %C3%A9ritable%20supervision%20de%20bout%20en%20bout%20et%20monitoring %20de%20la%20Qualit%C3%A9%20d%27Exp%C3%A9rience%20%3A%20Syst%C3%A8mes %20d%27Information%20et%20Services%20Multi- playutmhid=2134295609utmr=-utmp=%2Fqoe%2Findex.php %2FAccueil.htmlutmac=UA-7415175-1utmcc=__utma %3D218258335.1952450742.1265618759.1265618759.1265618759.1%3B%2B__utmz %3D218258335.1265618759.1.1.utmcsr%3D(direct)%7Cutmccn%3D(direct) %7Cutmcmd%3D(none)%3B bytes=35 start=2010-02-08T09:45:58.811+0100 end=2010-02-08T09:45:58.922+0100 timeInMillis=111 /entry /traffic -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Problems using clojure.contrib.string
Hi Matt, Just pushed a fix, see if that helps. Note that argument order was reversed in most functions from c.c.str- utils2 to c.c.string. -SS On Feb 10, 10:44 am, Matt Culbreth mattculbr...@gmail.com wrote: Hello Group, I'm working on a Clojure project and I'm using Leiningen for the builds. I'm trying to use the most recent clojure and clojure- contrib, but I'm having a problem getting it to compile due to apparent errors in clojure.contrib.string. This works fine on the more stable versions of these libraries, which use clojure.contrib.str- utils2. Here's my project file: (defproject myproj 0.1 :dependencies [[org.clojure/clojure 1.2.0-master-SNAPSHOT] [org.clojure/clojure-contrib 1.2.0-SNAPSHOT]] :main myproj) And I'm later using clojure.contrib.string as such: (ns myproj (:gen-class) (:require [clojure.contrib.string :as str-utils :only (join)]) (:import (java.io File FileNotFoundException BufferedReader InputStreamReader OutputStreamWriter))) I'm then using the str-utils/join function in the code, but I can't get it to compile. I get the following Java exceptions when doing lein compile: java.lang.RuntimeException: java.lang.IllegalArgumentException: Unable to resolve classname: Replacement snip at clojure.main.main(main.java:37) Caused by: java.lang.IllegalArgumentException: Unable to resolve classname: Replacement at clojure.lang.Compiler$HostExpr.tagToClass(Compiler.java:893) I also get this a couple of times: [null] java.lang.VerifyError: (class: clojure/contrib/string $replace_first_re__81, method: invoke signature: (Ljava/lang/ Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;) Unable to pop operand off an empty stack snip at clojure.main.main(main.java:37) [null] Caused by: java.lang.VerifyError: (class: clojure/contrib/ string$replace_first_re__81, method: invoke signature: (Ljava/lang/ Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;) Unable to pop operand off an empty stack Any ideas here? Not a big deal as I can just use the older code. Thanks, Matt -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Noob question: rebinding using def
Hi guys, I'm new to both clojure and functional programming and as an exercise in learning Clojure, I decided to write a naive bayes categorizer. I have a piece of code wherein I have a doseq inside which i am calling a function which returns a value. What I would like to do is have the value returned by the function to be added to a particular binding (variable), so that at the end of the doseq, I'll have a total sum of all values returned. Right now im doing this by using def to rebind the value. The exact code I'm using is: (def prob-sum 0) (doseq [cat cat-all] (def prob-sum (+ prob-sum (probability-of-category-given-document cat tokens I know that using def to rebind is not good practice and I should probably be using ref. However, this executes only in a single thread, so I'm not sure if it would be appropriate to use ref. Also, I realize that I'm abusing the concept of data immutability, but in this case I really need this to be mutable. However, I have a gut feeling that I'm not really approaching this in the right way (as in correct way to do it in a functional language), and I would really appreciate it if someone could set me upon the right track. Regards, chaosprophet -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How would I write an emitter/collector?
On 10 Feb, 16:21, Greg g...@kinostudios.com wrote: Patrick, I can't speak for the OP, but I found his question interesting and I'd like to compliment you on your response. I've been experimenting with Patrick's solution - and it's really quite good. I had a function which collected the things I emitted, and then realised it wouldn't be a convenient representation from the callers point of view. So instead of the callee collecting the emisions, I changed it so that it simply didn't bother. This achieves a very nice separation of concerns. Callee doesn't bother to work out why you want something, it just spits it out there and lets some caller worry about it. So callees don't have to bother about accumulating results, and you don't have to pass along results up the chain - callee just fires and forgets. Very neat. I think Patrick gets to be called King Of Clojure - at least for today. ;) Regards. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: newbie encountering java.lang.OutOfMemoryError: Java heap space
Hi Aviad, Disclaimer: I haven't read the book, nor do I know Clojure very well. However, based on your question (which I did read) and Brenton's hint, it seems to me like the solution will involve a lazy sequence, which is a frequent tool to use whenever you're dealing with a problems that involve a lot of memory. - Greg On Feb 10, 2010, at 10:13 AM, Aviad Reich wrote: thank you. I have -server and -Xmx1024m set in my 'swank-clojure-extra-vm-args, but the problem remains. Aviad On 10 February 2010 15:57, Joop Kiefte iko...@gmail.com wrote: (Disclaimer: never tried myself) http://hausheer.osola.com/docs/5 2010/2/10 Aviad R avi@gmail.com Hi all. I'm trying to learn clojure with the excellent Programming Clojure and projecteuler.net. I am encountering the java heap space error, and can't find a workaround, nor a smarter way to write my code (which I am certain exist). Trying to solve Problem 14 (some spoilers might be ahead, for those wanting to solve it in the future). The problem and my code are in https://pastee.org/hj3sh here is the problem: I am trying to produce a map of one O(million) key-value pairs using a recursive function. I can produce a map of the first 10 numbers in ~1300 msecs, with 217211 keys. However, for 15 and up, I get java.lang.OutOfMemoryError: Java heap space. so, I assume my code is ok on efficiency, but the recursion is too deep. am I right? can anyone suggest a way to overcome this problem? any additional tips and thoughts on the code would be of great help to me, as I am making my first steps in clojure. Thank you, Aviad -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- Communication is essential. So we need decent tools when communication is lacking, when language capability is hard to acquire... - http://esperanto.net - http://esperanto-jongeren.nl Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Interesting ICFP slides from Guy Steele -- Organizing Functional Code for Parallel Execution
I ran across this on reddit this morning, and thought people on the group might find it interesting: http://docs.google.com/viewer?url=http%3A%2F%2Fresearch.sun.com%2Fprojects%2Fplrg%2FPublications%2FICFPAugust2009Steele.pdfpli=1 It actually mentions clojure briefly at the end, although I'm not sure what it said was right (that lists were represented as trees in clojure). Nonetheless, the slide deck is pretty interesting. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Noob question: rebinding using def
chaosprophet, Clojure wants you to think in terms of sequences instead to loops. Instead to looping through cat-all and keeping track of the sum, you want to use map and reduce. (reduce + (map #(probability-of-category-given-document % tokens) cat- all)) Brenton On Feb 10, 7:14 am, chaosprophet bg.x...@gmail.com wrote: Hi guys, I'm new to both clojure and functional programming and as an exercise in learning Clojure, I decided to write a naive bayes categorizer. I have a piece of code wherein I have a doseq inside which i am calling a function which returns a value. What I would like to do is have the value returned by the function to be added to a particular binding (variable), so that at the end of the doseq, I'll have a total sum of all values returned. Right now im doing this by using def to rebind the value. The exact code I'm using is: (def prob-sum 0) (doseq [cat cat-all] (def prob-sum (+ prob-sum (probability-of-category-given-document cat tokens I know that using def to rebind is not good practice and I should probably be using ref. However, this executes only in a single thread, so I'm not sure if it would be appropriate to use ref. Also, I realize that I'm abusing the concept of data immutability, but in this case I really need this to be mutable. However, I have a gut feeling that I'm not really approaching this in the right way (as in correct way to do it in a functional language), and I would really appreciate it if someone could set me upon the right track. Regards, chaosprophet -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: newbie encountering java.lang.OutOfMemoryError: Java heap space
Thank you all! your advice were indeed very helpful! I eventually solved it using memoization. and indeed keeping only (http://clojure-euler.wikispaces.com/Problem+014 - lxmonk if you're interested) This indeed is a great community, so let me try another (related) question. Comparing my solution with an identical one - but without memoization produces a faster result. I understand that caching all the results has some overhead, but how come it isn't balanced with the speedup from the cached values? Again, Thanks! Aviad On 10 February 2010 19:40, Greg g...@kinostudios.com wrote: Hi Aviad, Disclaimer: I haven't read the book, nor do I know Clojure very well. However, based on your question (which I did read) and Brenton's hint, it seems to me like the solution will involve a lazy sequence, which is a frequent tool to use whenever you're dealing with a problems that involve a lot of memory. - Greg On Feb 10, 2010, at 10:13 AM, Aviad Reich wrote: thank you. I have -server and -Xmx1024m set in my 'swank-clojure-extra-vm-args, but the problem remains. Aviad On 10 February 2010 15:57, Joop Kiefte iko...@gmail.com wrote: (Disclaimer: never tried myself) http://hausheer.osola.com/docs/5 2010/2/10 Aviad R avi@gmail.com Hi all. I'm trying to learn clojure with the excellent Programming Clojure and projecteuler.net. I am encountering the java heap space error, and can't find a workaround, nor a smarter way to write my code (which I am certain exist). Trying to solve Problem 14 (some spoilers might be ahead, for those wanting to solve it in the future). The problem and my code are in https://pastee.org/hj3sh here is the problem: I am trying to produce a map of one O(million) key-value pairs using a recursive function. I can produce a map of the first 10 numbers in ~1300 msecs, with 217211 keys. However, for 15 and up, I get java.lang.OutOfMemoryError: Java heap space. so, I assume my code is ok on efficiency, but the recursion is too deep. am I right? can anyone suggest a way to overcome this problem? any additional tips and thoughts on the code would be of great help to me, as I am making my first steps in clojure. Thank you, Aviad -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- Communication is essential. So we need decent tools when communication is lacking, when language capability is hard to acquire... - http://esperanto.net - http://esperanto-jongeren.nl Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: newbie encountering java.lang.OutOfMemoryError: Java heap space
אביעד On 10 February 2010 19:54, Aviad Reich avi@gmail.com wrote: Thank you all! your advice were indeed very helpful! I eventually solved it using memoization. and indeed keeping only 3 values in memory. (http://clojure-euler.wikispaces.com/Problem+014 - lxmonk, if you're interested) This indeed is a great community, so let me try another (related) question. Comparing my solution with an identical one - but without memoization produces a faster result. I understand that caching all the results has some overhead, but how come it isn't balanced with the speedup from the cached values? Again, Thanks! Aviad On 10 February 2010 19:40, Greg g...@kinostudios.com wrote: Hi Aviad, Disclaimer: I haven't read the book, nor do I know Clojure very well. However, based on your question (which I did read) and Brenton's hint, it seems to me like the solution will involve a lazy sequence, which is a frequent tool to use whenever you're dealing with a problems that involve a lot of memory. - Greg On Feb 10, 2010, at 10:13 AM, Aviad Reich wrote: thank you. I have -server and -Xmx1024m set in my 'swank-clojure-extra-vm-args, but the problem remains. Aviad On 10 February 2010 15:57, Joop Kiefte iko...@gmail.com wrote: (Disclaimer: never tried myself) http://hausheer.osola.com/docs/5 2010/2/10 Aviad R avi@gmail.com Hi all. I'm trying to learn clojure with the excellent Programming Clojure and projecteuler.net. I am encountering the java heap space error, and can't find a workaround, nor a smarter way to write my code (which I am certain exist). Trying to solve Problem 14 (some spoilers might be ahead, for those wanting to solve it in the future). The problem and my code are in https://pastee.org/hj3sh here is the problem: I am trying to produce a map of one O(million) key-value pairs using a recursive function. I can produce a map of the first 10 numbers in ~1300 msecs, with 217211 keys. However, for 15 and up, I get java.lang.OutOfMemoryError: Java heap space. so, I assume my code is ok on efficiency, but the recursion is too deep. am I right? can anyone suggest a way to overcome this problem? any additional tips and thoughts on the code would be of great help to me, as I am making my first steps in clojure. Thank you, Aviad -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- Communication is essential. So we need decent tools when communication is lacking, when language capability is hard to acquire... - http://esperanto.net - http://esperanto-jongeren.nl Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: newbie encountering java.lang.OutOfMemoryError: Java heap space
Aviad, You don't get a speedup because you are never calling the memoized function with the same arguments. In your code, n is different each time. memoize basically creates a map of arguments to results. When you call the function with args that it has seen before it bypasses actually calling the underlying function and just returns the results. If you really wanted to use memoize here then you use it on the vl function. Brenton On Feb 10, 9:54 am, Aviad Reich avi@gmail.com wrote: Thank you all! your advice were indeed very helpful! I eventually solved it using memoization. and indeed keeping only (http://clojure-euler.wikispaces.com/Problem+014- lxmonk if you're interested) This indeed is a great community, so let me try another (related) question. Comparing my solution with an identical one - but without memoization produces a faster result. I understand that caching all the results has some overhead, but how come it isn't balanced with the speedup from the cached values? Again, Thanks! Aviad On 10 February 2010 19:40, Greg g...@kinostudios.com wrote: Hi Aviad, Disclaimer: I haven't read the book, nor do I know Clojure very well. However, based on your question (which I did read) and Brenton's hint, it seems to me like the solution will involve a lazy sequence, which is a frequent tool to use whenever you're dealing with a problems that involve a lot of memory. - Greg On Feb 10, 2010, at 10:13 AM, Aviad Reich wrote: thank you. I have -server and -Xmx1024m set in my 'swank-clojure-extra-vm-args, but the problem remains. Aviad On 10 February 2010 15:57, Joop Kiefte iko...@gmail.com wrote: (Disclaimer: never tried myself) http://hausheer.osola.com/docs/5 2010/2/10 Aviad R avi@gmail.com Hi all. I'm trying to learn clojure with the excellent Programming Clojure and projecteuler.net. I am encountering the java heap space error, and can't find a workaround, nor a smarter way to write my code (which I am certain exist). Trying to solve Problem 14 (some spoilers might be ahead, for those wanting to solve it in the future). The problem and my code are inhttps://pastee.org/hj3sh here is the problem: I am trying to produce a map of one O(million) key-value pairs using a recursive function. I can produce a map of the first 10 numbers in ~1300 msecs, with 217211 keys. However, for 15 and up, I get java.lang.OutOfMemoryError: Java heap space. so, I assume my code is ok on efficiency, but the recursion is too deep. am I right? can anyone suggest a way to overcome this problem? any additional tips and thoughts on the code would be of great help to me, as I am making my first steps in clojure. Thank you, Aviad -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- Communication is essential. So we need decent tools when communication is lacking, when language capability is hard to acquire... -http://esperanto.net -http://esperanto-jongeren.nl Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group,
Re: newbie encountering java.lang.OutOfMemoryError: Java heap space
Looking at your post I notice some things that strike me as 'odd'. The use of (def) in a form that is not a top most form. From my experience this leads to trouble in the best of times. I think a better way would be to close over your known-map with a closure. While I don't have high hopes that closing over known-map will solve your out of memory issue it starts, i believe, making the code more idiomatic. Once that is done I would look at simplifying what update- known-map and dist functions do. Its unclear to me why you do a merge of a zipmap of keys to numbers. Making that clearer might help. I also don't understand your use of a map to hold the intermediate solutions. My first thought upon reading the question was a pair of numbers, the first being the number and the second being the count of the Collatz chain would do the trick, but I could be missing something. (William Hidden) On Feb 10, 10:13 am, Aviad Reich avi@gmail.com wrote: thank you. I have -server and -Xmx1024m set in my 'swank-clojure-extra-vm-args, but the problem remains. Aviad On 10 February 2010 15:57, Joop Kiefte iko...@gmail.com wrote: (Disclaimer: never tried myself) http://hausheer.osola.com/docs/5 2010/2/10 Aviad R avi@gmail.com Hi all. I'm trying to learn clojure with the excellent Programming Clojure and projecteuler.net. I am encountering the java heap space error, and can't find a workaround, nor a smarter way to write my code (which I am certain exist). Trying to solve Problem 14 (some spoilers might be ahead, for those wanting to solve it in the future). The problem and my code are inhttps://pastee.org/hj3sh here is the problem: I am trying to produce a map of one O(million) key-value pairs using a recursive function. I can produce a map of the first 10 numbers in ~1300 msecs, with 217211 keys. However, for 15 and up, I get java.lang.OutOfMemoryError: Java heap space. so, I assume my code is ok on efficiency, but the recursion is too deep. am I right? can anyone suggest a way to overcome this problem? any additional tips and thoughts on the code would be of great help to me, as I am making my first steps in clojure. Thank you, Aviad -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- Communication is essential. So we need decent tools when communication is lacking, when language capability is hard to acquire... -http://esperanto.net -http://esperanto-jongeren.nl Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Problems using clojure.contrib.string
Yes that worked very well, thanks Stuart. I'm assuming that this fix will make its way to the nightly build and will be published to http://build.clojure.org/job/clojure-contrib/ as usual? On Feb 10, 12:32 pm, Stuart Sierra the.stuart.sie...@gmail.com wrote: Hi Matt, Just pushed a fix, see if that helps. Note that argument order was reversed in most functions from c.c.str- utils2 to c.c.string. -SS On Feb 10, 10:44 am, Matt Culbreth mattculbr...@gmail.com wrote: Hello Group, I'm working on a Clojure project and I'm using Leiningen for the builds. I'm trying to use the most recent clojure and clojure- contrib, but I'm having a problem getting it to compile due to apparent errors in clojure.contrib.string. This works fine on the more stable versions of these libraries, which use clojure.contrib.str- utils2. Here's my project file: (defproject myproj 0.1 :dependencies [[org.clojure/clojure 1.2.0-master-SNAPSHOT] [org.clojure/clojure-contrib 1.2.0-SNAPSHOT]] :main myproj) And I'm later using clojure.contrib.string as such: (ns myproj (:gen-class) (:require [clojure.contrib.string :as str-utils :only (join)]) (:import (java.io File FileNotFoundException BufferedReader InputStreamReader OutputStreamWriter))) I'm then using the str-utils/join function in the code, but I can't get it to compile. I get the following Java exceptions when doing lein compile: java.lang.RuntimeException: java.lang.IllegalArgumentException: Unable to resolve classname: Replacement snip at clojure.main.main(main.java:37) Caused by: java.lang.IllegalArgumentException: Unable to resolve classname: Replacement at clojure.lang.Compiler$HostExpr.tagToClass(Compiler.java:893) I also get this a couple of times: [null] java.lang.VerifyError: (class: clojure/contrib/string $replace_first_re__81, method: invoke signature: (Ljava/lang/ Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;) Unable to pop operand off an empty stack snip at clojure.main.main(main.java:37) [null] Caused by: java.lang.VerifyError: (class: clojure/contrib/ string$replace_first_re__81, method: invoke signature: (Ljava/lang/ Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;) Unable to pop operand off an empty stack Any ideas here? Not a big deal as I can just use the older code. Thanks, Matt -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Problems using clojure.contrib.string
yes On Feb 10, 1:25 pm, Matt Culbreth mattculbr...@gmail.com wrote: Yes that worked very well, thanks Stuart. I'm assuming that this fix will make its way to the nightly build and will be published tohttp://build.clojure.org/job/clojure-contrib/as usual? On Feb 10, 12:32 pm, Stuart Sierra the.stuart.sie...@gmail.com wrote: Hi Matt, Just pushed a fix, see if that helps. Note that argument order was reversed in most functions from c.c.str- utils2 to c.c.string. -SS On Feb 10, 10:44 am, Matt Culbreth mattculbr...@gmail.com wrote: Hello Group, I'm working on a Clojure project and I'm using Leiningen for the builds. I'm trying to use the most recent clojure and clojure- contrib, but I'm having a problem getting it to compile due to apparent errors in clojure.contrib.string. This works fine on the more stable versions of these libraries, which use clojure.contrib.str- utils2. Here's my project file: (defproject myproj 0.1 :dependencies [[org.clojure/clojure 1.2.0-master-SNAPSHOT] [org.clojure/clojure-contrib 1.2.0-SNAPSHOT]] :main myproj) And I'm later using clojure.contrib.string as such: (ns myproj (:gen-class) (:require [clojure.contrib.string :as str-utils :only (join)]) (:import (java.io File FileNotFoundException BufferedReader InputStreamReader OutputStreamWriter))) I'm then using the str-utils/join function in the code, but I can't get it to compile. I get the following Java exceptions when doing lein compile: java.lang.RuntimeException: java.lang.IllegalArgumentException: Unable to resolve classname: Replacement snip at clojure.main.main(main.java:37) Caused by: java.lang.IllegalArgumentException: Unable to resolve classname: Replacement at clojure.lang.Compiler$HostExpr.tagToClass(Compiler.java:893) I also get this a couple of times: [null] java.lang.VerifyError: (class: clojure/contrib/string $replace_first_re__81, method: invoke signature: (Ljava/lang/ Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;) Unable to pop operand off an empty stack snip at clojure.main.main(main.java:37) [null] Caused by: java.lang.VerifyError: (class: clojure/contrib/ string$replace_first_re__81, method: invoke signature: (Ljava/lang/ Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;) Unable to pop operand off an empty stack Any ideas here? Not a big deal as I can just use the older code. Thanks, Matt -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure binding for Open CL
A few months back I created very basic bindings for CL4Java (the code for it still exists in Penumbra, under src/opencl). It then subsequently was renamed to JOCL, which was already in use by another OpenCL library, and they started to work on combining their efforts, and I decided to wait until everything was figured out on that end. If anyone can point me in the direction of a clean binding in Java for OpenCL (I don't care so much about utility functions, just the underlying API), I'd be happy to take another crack at it. Zach On Feb 10, 6:58 am, atucker agjf.tuc...@googlemail.com wrote: From his todo list (1), it looks as if ztellman (2) might have concrete plans to include it in the (currently OpenGL) wrapper project penumbra (3). 1.http://wiki.github.com/ztellman/penumbra/todo 2.http://ideolalia.com/ 3.http://github.com/ztellman/penumbra On Feb 9, 9:48 pm, ka sancha...@gmail.com wrote: Hi, I was just wondering if (by now) Open CL has been 'wrapped' by higher level languages. I came across these from the Khronos site (http://www.khronos.org/developers/resources/opencl/#timplementations) - 1.http://ruby-opencl.rubyforge.org/ 2.http://planet.plt-scheme.org/display.ss?package=opencl.pltowner=jaym... 3.http://mathema.tician.de/software/pyopencl Wondering if anyone is already working on a Open CL binding. I would love if I can code in clojure and it runs through Open CL drivers :) on my Radeon! Thanks! -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojure gen-class questions
Meikel, As a beginner, I tried running the first example,changing namespaces or not, etc ,and I keep getting user= (ns some.Example (gen-class)) nil some.Example= (defn -toString [this] HI !) #'some.Example/-toString some.Example= (ns user) nil user= (-toString (some.Example.)) java.lang.Exception: Unable to resolve symbol: -toString in this context (NO_SOU RCE_FILE:21) Brian On Feb 9, 3:44 pm, Meikel Brandmeyer m...@kotka.de wrote: Hi, I wrote up a post:http://tr.im/NwCL Hope it helps. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Interesting ICFP slides from Guy Steele -- Organizing Functional Code for Parallel Execution
What he said is basically right, only instead of list it's called vector. Not sure if vector branching is 64 or 32. On 10 fev, 15:42, Paul Mooser taron...@gmail.com wrote: I ran across this on reddit this morning, and thought people on the group might find it interesting: http://docs.google.com/viewer?url=http%3A%2F%2Fresearch.sun.com%2Fpro... It actually mentions clojure briefly at the end, although I'm not sure what it said was right (that lists were represented as trees in clojure). Nonetheless, the slide deck is pretty interesting. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
The Detroit Java User Group Looking For a Speaker
Hello, I apologize in advance it this is an inappropriate forum for this message. I organize the Detroit Java User Group (www.detroitjug.org) and I'd like to find a knowledgeable speaker who can present Clojure to our JUG. If there are any members of the group in the Michigan or Ohio area that would be interested in presenting, I'd love to hear from you. If you live further and would need us to cover traveling expenses, I could look into that also. Just let me know. Thanks to all, for your time and consideration. Cheers! David McKinnon www.detroitjug.org @detroitjava mckinnon.david [...@] ymail.com -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojure gen-class questions
Hi, Am 10.02.2010 um 21:05 schrieb Brian Wolf: As a beginner, I tried running the first example,changing namespaces or not, etc ,and I keep getting user= (ns some.Example (gen-class)) nil some.Example= (defn -toString [this] HI !) #'some.Example/-toString some.Example= (ns user) nil user= (-toString (some.Example.)) java.lang.Exception: Unable to resolve symbol: -toString in this context (NO_SOU RCE_FILE:21) gen-class only works with AOT compilation. So you have to compile the namespace. See http://clojure.org/compilation. Then you have to a colon in the ns-clause: :gen-class instead of gen-class. And finally you have to 'use' your namespace if you want to call the clojure function: (in-ns 'user) (use 'some.Example). Or you have to use the dot notation for the method calls. (.toString (some.Example.)). However for this you have to compile the class with 'compile'. Note: ns is used only to setup a namespace. So it should be called only once. To switch namespaces in the Repl use in-ns. Since the repl sets up user for you, you shouldn't use ns. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
how to determine what implements a protocol?
hi, is there a query to tell me if a datatype implements a particular protocol? i'm guessing there must be some forehead-slapping answer, but i haven't gleaned the clue yet :-{ thanks. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Interesting ICFP slides from Guy Steele -- Organizing Functional Code for Parallel Execution
2010/2/10 André Ferreira greis...@gmail.com: What he said is basically right, only instead of list it's called vector. Not sure if vector branching is 64 or 32. If you could append two vectors quickly in Clojure, you'd be able to use a lot of the techniques described in those slides. The whole discussion also reminded me of rope implementations of strings. In any case, it definitely feels like there are some good ideas in there that would be nice to see in a Clojure parallel library. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Dutch Clojure users
On 7 feb, 13:09, Hubert Iwaniuk neo...@kungfoo.pl wrote: Great to hear that there is Clojure group around. For ease of finding it:http://groups.google.com/group/amsterdam-clojurians?hl=en Cheers, Hubert Joined as well. I'm in Utrecht. Shame I missed today's meeting. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: how to determine what implements a protocol?
No need to slap your forehead, but here it is: - clojure.core/extends? ([protocol atype]) Returns true if atype explicitly extends protocol -SS On Feb 10, 4:03 pm, Raoul Duke rao...@gmail.com wrote: hi, is there a query to tell me if a datatype implements a particular protocol? i'm guessing there must be some forehead-slapping answer, but i haven't gleaned the clue yet :-{ thanks. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: how to determine what implements a protocol?
On Wed, Feb 10, 2010 at 1:20 PM, Stuart Sierra the.stuart.sie...@gmail.com wrote: No need to slap your forehead, but here it is: - clojure.core/extends? ([protocol atype]) Returns true if atype explicitly extends protocol thanks! at least a d'oh will be required. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Interesting ICFP slides from Guy Steele -- Organizing Functional Code for Parallel Execution
Yeah, I'm aware of the tree nature of many clojure data structures, but just wasn't sure that applied to actual lists. On Feb 10, 12:06 pm, André Ferreira greis...@gmail.com wrote: What he said is basically right, only instead of list it's called vector. Not sure if vector branching is 64 or 32. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: how to determine what implements a protocol?
clojure.core/extends? doesn't seem to cover all the use cases? or i'm mistyping (er ha ha) something? (ns p) (defprotocol P1 (foo [this])) (ns d) (deftype T1 [f] :as this p/P1 (foo [] (println this))) (deftype T2 [f] :as this) (extend ::T2 p/P1 {:foo (fn [this] (println this))}) (println P1?T1 (extends? p/P1 :d/T1)) (println P1?T2 (extends? p/P1 :d/T2)) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: how to determine what implements a protocol?
Hi, Am 10.02.2010 um 22:20 schrieb Stuart Sierra: No need to slap your forehead, but here it is: - clojure.core/extends? ([protocol atype]) Returns true if atype explicitly extends protocol This only checks whether extend was explicitly called on atype. What you mean is 'satisfies?'. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
defn within defn
Hi all. Is it not recommended to use defn within defn? Normal function is faster than the function which has inner function which actually doesn't run. -- (defn aaa1 [] (defn bbb [] 1) 1) (defn aaa2 [] 1) user (time (dotimes [_ 1000] (aaa1))) Elapsed time: 4083.291 msecs nil user (time (dotimes [_ 1000] (aaa2))) Elapsed time: 58.34 msecs nil -- In scheme's case both code have been excuted in the same time. None of clojure code I have seen have inner function. I like inner function because it doesn't consume a name from namespace and make it clear that inner function is only used by outer function. Thanks. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: defn within defn
Hozumi, nested defn's are definitely not recommended. I suggest using letfn for the inner function. Bill Smith Austin, TX On Feb 10, 3:28 pm, Hozumi fat...@googlemail.com wrote: Hi all. Is it not recommended to use defn within defn? Normal function is faster than the function which has inner function which actually doesn't run. -- (defn aaa1 [] (defn bbb [] 1) 1) (defn aaa2 [] 1) user (time (dotimes [_ 1000] (aaa1))) Elapsed time: 4083.291 msecs nil user (time (dotimes [_ 1000] (aaa2))) Elapsed time: 58.34 msecs nil -- In scheme's case both code have been excuted in the same time. None of clojure code I have seen have inner function. I like inner function because it doesn't consume a name from namespace and make it clear that inner function is only used by outer function. Thanks. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: defn within defn
scheme's define is scoped inside a function. clojure is not scheme. clojure's def (which defn uses) is not lexical or scoped in anyway, it always operates on global names. if you want lexical scope please use one of clojure's lexical scoping constructs, let or letfn. On Wed, Feb 10, 2010 at 1:28 PM, Hozumi fat...@googlemail.com wrote: Hi all. Is it not recommended to use defn within defn? Normal function is faster than the function which has inner function which actually doesn't run. -- (defn aaa1 [] (defn bbb [] 1) 1) (defn aaa2 [] 1) user (time (dotimes [_ 1000] (aaa1))) Elapsed time: 4083.291 msecs nil user (time (dotimes [_ 1000] (aaa2))) Elapsed time: 58.34 msecs nil -- In scheme's case both code have been excuted in the same time. None of clojure code I have seen have inner function. I like inner function because it doesn't consume a name from namespace and make it clear that inner function is only used by outer function. Thanks. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- And what is good, Phaedrus, And what is not good— Need we ask anyone to tell us these things? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Contributing to Clojure.Contrib
http://clojure.org/contributing seq-utils was recently renamed: http://groups.google.com/group/clojure-dev/browse_thread/thread/49068754a8c2efb9# On Wed, Feb 10, 2010 at 3:38 PM, Wardrop t...@tomwardrop.com wrote: I've written a function which I think would be a good inclusion into the Clojure.Contrib library. I have two questions though, the first is how? How do I go about adding a single function to an existing namespace; in this case, seq-utils, and what are the pre-requisites? My second question is, what are the standards that code most confirm to in order to be accepted (or suitable) for Clojure.Contrib. Maybe someone could look over my function, and make some comments on it's general quality and suitability. My function code can be found here: http://gist.github.com/300990 Cheers -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- And what is good, Phaedrus, And what is not good— Need we ask anyone to tell us these things? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Contributing to Clojure.Contrib
Take a look here: http://clojure.org/contributing On Feb 10, 6:38 pm, Wardrop t...@tomwardrop.com wrote: I've written a function which I think would be a good inclusion into the Clojure.Contrib library. I have two questions though, the first is how? How do I go about adding a single function to an existing namespace; in this case, seq-utils, and what are the pre-requisites? My second question is, what are the standards that code most confirm to in order to be accepted (or suitable) for Clojure.Contrib. Maybe someone could look over my function, and make some comments on it's general quality and suitability. My function code can be found here:http://gist.github.com/300990 Cheers -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Dutch Clojure users
Just at home, 4 of us were there. 1 american, 1 italian, 1 pole and me, a dutchy. I don't think this was the last time for me, and maybe some day I should invite you to Ede :) or arrange something in Utrecht or Rotterdam (I work there nearby). 2010/2/10 Joost jo...@zeekat.nl On 7 feb, 13:09, Hubert Iwaniuk neo...@kungfoo.pl wrote: Great to hear that there is Clojure group around. For ease of finding it: http://groups.google.com/group/amsterdam-clojurians?hl=en Cheers, Hubert Joined as well. I'm in Utrecht. Shame I missed today's meeting. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- Communication is essential. So we need decent tools when communication is lacking, when language capability is hard to acquire... - http://esperanto.net - http://esperanto-jongeren.nl Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: defn within defn
Hi, Bill. oh, letfn is what I wanted ! Thank you. Sorry, I missed preview disqussion. letfn - mutually recursive local functions http://groups.google.com/group/clojure/browse_thread/thread/a7aad1d5b94db748 letfn is pretty good. --- (defn aaa1 [] (letfn [(bbb [] 1)] 1)) user (time (dotimes [_ 1000] (aaa1))) Elapsed time: 100.981 msecs nil --- Hi Kevin. I have understood that def is not lexical scoped. --- (defn aaa1 [] (defn bbb [] 1) 1) user (aaa) 1 user bbb #user$aaa1__2324$bbb__2326 user$aaa1__2324$bbb__2...@55eef3c1 --- Thank you! On 2月11日, 午前8:01, Kevin Downey redc...@gmail.com wrote: scheme's define is scoped inside a function. clojure is not scheme. clojure's def (which defn uses) is not lexical or scoped in anyway, it always operates on global names. if you want lexical scope please use one of clojure's lexical scoping constructs, let or letfn. On Wed, Feb 10, 2010 at 1:28 PM, Hozumi fat...@googlemail.com wrote: Hi all. Is it not recommended to use defn within defn? Normal function is faster than the function which has inner function which actually doesn't run. --- --- (defn aaa1 [] (defn bbb [] 1) 1) (defn aaa2 [] 1) user (time (dotimes [_ 1000] (aaa1))) Elapsed time: 4083.291 msecs nil user (time (dotimes [_ 1000] (aaa2))) Elapsed time: 58.34 msecs nil --- --- In scheme's case both code have been excuted in the same time. None of clojure code I have seen have inner function. I like inner function because it doesn't consume a name from namespace and make it clear that inner function is only used by outer function. Thanks. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- And what is good, Phaedrus, And what is not good— Need we ask anyone to tell us these things? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Contributing to Clojure.Contrib
Thanks for the link. As part of my second question, could someone take a look at the code I've posted and tell me if it's a good implementation and follows clojure idioms and standards. By the way, does anyone know of a good resource that specifies common clojure coding and formatting standards, like what to call function arguments (e.g. idx for indexes and coll for collections to name the more obvious ones). Cheers On Feb 11, 9:44 am, Sean Devlin francoisdev...@gmail.com wrote: Take a look here: http://clojure.org/contributing On Feb 10, 6:38 pm, Wardrop t...@tomwardrop.com wrote: I've written a function which I think would be a good inclusion into the Clojure.Contrib library. I have two questions though, the first is how? How do I go about adding a single function to an existing namespace; in this case, seq-utils, and what are the pre-requisites? My second question is, what are the standards that code most confirm to in order to be accepted (or suitable) for Clojure.Contrib. Maybe someone could look over my function, and make some comments on it's general quality and suitability. My function code can be found here:http://gist.github.com/300990 Cheers -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Contributing to Clojure.Contrib
http://groups.google.com/group/clojure-dev/browse_thread/thread/d090b5599909497c# On Wed, Feb 10, 2010 at 3:57 PM, Wardrop t...@tomwardrop.com wrote: Thanks for the link. As part of my second question, could someone take a look at the code I've posted and tell me if it's a good implementation and follows clojure idioms and standards. By the way, does anyone know of a good resource that specifies common clojure coding and formatting standards, like what to call function arguments (e.g. idx for indexes and coll for collections to name the more obvious ones). Cheers On Feb 11, 9:44 am, Sean Devlin francoisdev...@gmail.com wrote: Take a look here: http://clojure.org/contributing On Feb 10, 6:38 pm, Wardrop t...@tomwardrop.com wrote: I've written a function which I think would be a good inclusion into the Clojure.Contrib library. I have two questions though, the first is how? How do I go about adding a single function to an existing namespace; in this case, seq-utils, and what are the pre-requisites? My second question is, what are the standards that code most confirm to in order to be accepted (or suitable) for Clojure.Contrib. Maybe someone could look over my function, and make some comments on it's general quality and suitability. My function code can be found here:http://gist.github.com/300990 Cheers -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- And what is good, Phaedrus, And what is not good— Need we ask anyone to tell us these things? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Hiring round #6
Hello, We have a very interesting big-data project need more devs. We are looking for our 7th clojure dev on an all work-at-home team. You must live in the US to be on our team.Full-time employees get a MBP 15 3g (for travel backup internet). So far our team consists of (in no particular order): Dan Larkin, Phil Hagelberg, Jim Duey, Steve Gilardi, George Jahad and Tim Dysinger (me). You must: * Know clojure, git emacs well enough to contribute to a complex project * Have some FP and/or Java experience beyond clojure * Live in the US be available during the day for full-time work * Communicate pair-program well with others * Be disciplined enough to work from home * Not be on Windows If you tried before and want to keep trying - great! there's a lot of good people out there; don't be discouraged. we just have to keep picking the top voted applicant each round. Email your resume / info to jobs on sonian.net Tim Dysinger -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Noob question: rebinding using def
Ah, I didn't know about the reduce function. I'll give that a try and thanks a lot. On Feb 10, 10:42 pm, Brenton bashw...@gmail.com wrote: chaosprophet, Clojure wants you to think in terms of sequences instead to loops. Instead to looping through cat-all and keeping track of the sum, you want to use map and reduce. (reduce + (map #(probability-of-category-given-document % tokens) cat- all)) Brenton On Feb 10, 7:14 am, chaosprophet bg.x...@gmail.com wrote: Hi guys, I'm new to both clojure and functional programming and as an exercise in learning Clojure, I decided to write a naive bayes categorizer. I have a piece of code wherein I have a doseq inside which i am calling a function which returns a value. What I would like to do is have the value returned by the function to be added to a particular binding (variable), so that at the end of the doseq, I'll have a total sum of all values returned. Right now im doing this by using def to rebind the value. The exact code I'm using is: (def prob-sum 0) (doseq [cat cat-all] (def prob-sum (+ prob-sum (probability-of-category-given-document cat tokens I know that using def to rebind is not good practice and I should probably be using ref. However, this executes only in a single thread, so I'm not sure if it would be appropriate to use ref. Also, I realize that I'm abusing the concept of data immutability, but in this case I really need this to be mutable. However, I have a gut feeling that I'm not really approaching this in the right way (as in correct way to do it in a functional language), and I would really appreciate it if someone could set me upon the right track. Regards, chaosprophet -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
refs, agents and add-watch
I have this code: (def material (ref 2)) (def products-store (ref 2)) (def products (ref 0)) (def artisan (agent idle)) (defn manufacture [state] (dosync (alter material dec) (alter products inc)) (str idle)) (defn ask-material [a-key the-ref old-state new-state] (if (= new-state 0) (dosync (alter material + (int (rand 10)) (defn send-products [a-key the-ref old-state new-state] (if (= new-state 4) (dosync (alter products - new-state) (alter products-store + new-state when I evaluate this: (add-watch products :prodkey send-products) (add-watch material :matkey ask-material) (send artisan manufacture) (send artisan manufacture) (send artisan manufacture) (send artisan manufacture) java.lang.RuntimeException: Agent has errors (repl-1:8) I'm clearly missing something but I have no idea what, if someone could point me in the right direction I would be very grateful. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: refs, agents and add-watch
On 11 February 2010 02:50, MiltondSilva shadowtr...@gmail.com wrote: I have this code: [snip] java.lang.RuntimeException: Agent has errors (repl-1:8) Your code works fine for me. To help you debug your problem: you can use (agent-errors artisan) to discover what the exception is about, clear-agent-errors to clear the agent's error queue and you should probably try a fresh REPL to see if it isn't caused by some random thing you did at some point besides typing in this code... All best, Michał -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: refs, agents and add-watch
This solved the problem: (defn ask-material [a-key the-ref old-state new-state] (if (= new-state 0) (dosync (alter material + (int (rand 10) (str asked for materials)) When the function ask-materials is invoked, it updates the state of the agent that caused the change. (in this case artisan) Well that's what I thought until I read your reply, now I'm clueless. Is there some way to dump the state of all refs, atom, agents etc when they are updated? I was thinking of adding watchers to everything but that's incredibly messy. I just want to debug and also to see what's going on, possible to feed the updates to a 3d environment. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Contributing to Clojure.Contrib
Hi, On Feb 11, 12:57 am, Wardrop t...@tomwardrop.com wrote: As part of my second question, could someone take a look at the code I've posted and tell me if it's a good implementation and follows clojure idioms and standards. I haven't checked the algorithm itself, but just some random notes after skimming the code: * lazy-seq should wrap the whole thing! (lazy-seq (when-let [coll (seq coll)] ...) * take-while and afterwards a drop can be done with split-with in one go. * You could use condp: (condp = on-cons :join (do-stuff) :split (do- otherstuff) (throw ...)) Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: newbie encountering java.lang.OutOfMemoryError: Java heap space
Again, your input was incredibly beneficial for me. William: Thank you for your comments. As i wrote, eventually I came up with a different solution altogether. To answer your question concerning the previous code: my initial idea was that since (although unproven) all the different sequences finally converge to the 2^n series, and other sequences in different points (e.g the sequence starting with 5 converges with the one starting at 16), it would be possible to speed up the computation if i would have created a map where past sequences are kept. The idea was that the keys to the map are numbers already calculated and their respective values would be their chain-lengths. That is the reason I wanted to merge the known-map with a (zip)map whose keys are the unknown numbers in the current sequence (kept in the cur-map vector) and values - chain lengths - are those of the number who converged with an already known sequence plus one. This method proved to be consuming too much memory, hence my use a slightly different approach. You have all been very helpful! Cheers, Aviad On 10 February 2010 19:32, Will Hidden william.hid...@gmail.com wrote: Looking at your post I notice some things that strike me as 'odd'. The use of (def) in a form that is not a top most form. From my experience this leads to trouble in the best of times. I think a better way would be to close over your known-map with a closure. While I don't have high hopes that closing over known-map will solve your out of memory issue it starts, i believe, making the code more idiomatic. Once that is done I would look at simplifying what update- known-map and dist functions do. Its unclear to me why you do a merge of a zipmap of keys to numbers. Making that clearer might help. I also don't understand your use of a map to hold the intermediate solutions. My first thought upon reading the question was a pair of numbers, the first being the number and the second being the count of the Collatz chain would do the trick, but I could be missing something. (William Hidden) On Feb 10, 10:13 am, Aviad Reich avi@gmail.com wrote: thank you. I have -server and -Xmx1024m set in my 'swank-clojure-extra-vm-args, but the problem remains. Aviad On 10 February 2010 15:57, Joop Kiefte iko...@gmail.com wrote: (Disclaimer: never tried myself) http://hausheer.osola.com/docs/5 2010/2/10 Aviad R avi@gmail.com Hi all. I'm trying to learn clojure with the excellent Programming Clojure and projecteuler.net. I am encountering the java heap space error, and can't find a workaround, nor a smarter way to write my code (which I am certain exist). Trying to solve Problem 14 (some spoilers might be ahead, for those wanting to solve it in the future). The problem and my code are inhttps://pastee.org/hj3sh here is the problem: I am trying to produce a map of one O(million) key-value pairs using a recursive function. I can produce a map of the first 10 numbers in ~1300 msecs, with 217211 keys. However, for 15 and up, I get java.lang.OutOfMemoryError: Java heap space. so, I assume my code is ok on efficiency, but the recursion is too deep. am I right? can anyone suggest a way to overcome this problem? any additional tips and thoughts on the code would be of great help to me, as I am making my first steps in clojure. Thank you, Aviad -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com clojure%2bunsubscr...@googlegroups.comclojure%252bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- Communication is essential. So we need decent tools when communication is lacking, when language capability is hard to acquire... -http://esperanto.net -http://esperanto-jongeren.nl Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com clojure%2bunsubscr...@googlegroups.comclojure%252bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send