Re: clojure.contrib.sql = clojure.java.jdbc - looking for feedback!
On Apr 22, 10:32 pm, Shantanu Kumar kumar.shant...@gmail.com wrote: I'm going to be working on clojure.java.jdbc, with Steve Gilardi, and I'd like to get people's feedback on what you like / what you don't like / what you need changed or added in clojure.contrib.sql so that clojure.java.jdbccan become what the community wants for 1.3.0. Thanks for asking -- personally I think c.c.sql has a lot to improve on the configuration aspect (some of which I have started incorporating here:https://bitbucket.org/kumarshantanu/clj-dbspec/src ). Listed below: 1. Allow _ (underscore) in field names 2. Provide a mechanism to show the SQL being executed (configurable, so that it can be turned off) 3. Allow users to flexibly convert from Clojure name to DB entity name 4. Allow users to flexibly convert from DB entity name to Clojure name (this affects resultset-seq) 5. Provide a mode to prevent write operations DB entity name can be table name, column name, schema name etc. Besides configuration, I think it can benefit from the following: 6. An INSERT function that returns the generated key(s) 7. The function for creating tables is non-portable across databases -- make it known in the docstring 8. Allow users to specify :fetch-size, :fetch-direction, :timeout etc through the config-map and make functions honor that. I think a default fetch-size of 1000 would be good for performance and more predictable across databases: http://download.oracle.com/javase/6/docs/api/java/sql/Statement.html Regards, Shantanu -- You 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: core.logic now compatible with Clojure 1.2.X
On Wed, May 25, 2011 at 1:36 AM, Sunil Nandihalli sunil.nandiha...@gmail.com wrote: Thats really nice to hear.. but is the version on clojars compatible with 1.2 yet? Thanks Sunil. I actually spoke a tiny bit too soon. There's one bug related to the numerics change between 1.2 and 1.3. I'm waiting for some guidance on how to proceed. Soon as I'm sure I have something that will work for both versions I'll push the 1.2 compat core.logic to Clojars. David -- You 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, Swank, and Leiningen with Emacs on Mac OS X
Have you tried this one? https://github.com/technomancy/swank-clojure On May 22, 10:53 am, dokondr doko...@gmail.com wrote: Hello, I am trying to install Clojure tools on Mac OS X according to the instructions: Clojure, Swank, and Leiningen with Emacs on Linuxhttp://riddell.us/ClojureSwankLeiningenWithEmacsOnLinux.html Everything goes fine until these steps: ~$ lein deps ~$ lein swank In my project.clj I have: (defproject test-project 0.1.0 :description Test Project :dependencies [[org.clojure/clojure 1.3.0-master-SNAPSHOT] [org.clojure/clojure-contrib 1.3.0-SNAPSHOT]] :dev-dependencies [[swank-clojure 1.2.1]]) Running 'lein deps' gives these errors: Downloading: org/clojure/clojure-contrib/1.3.0-SNAPSHOT/clojure- contrib-1.3.0-SNAPSHOT.pom from cloju\ re-snapshots Downloading: org/clojure/clojure-contrib/1.3.0-SNAPSHOT/clojure- contrib-1.3.0-SNAPSHOT.pom from cloja\ rs Downloading: org/clojure/clojure-contrib/1.3.0-SNAPSHOT/clojure- contrib-1.3.0-SNAPSHOT.jar from cloju\ re-snapshots Downloading: org/clojure/clojure-contrib/1.3.0-SNAPSHOT/clojure- contrib-1.3.0-SNAPSHOT.jar from cloja\ rs An error has occurred while processing the Maven artifact tasks. Diagnosis: Unable to resolve artifact: Missing: -- 1) org.clojure:clojure-contrib:jar:1.3.0-SNAPSHOT Try downloading the file manually from the project website. Then, install it using the command: mvn install:install-file -DgroupId=org.clojure - DartifactId=clojure-contrib -Dversion=1.3.0-SNA\ PSHOT -Dpackaging=jar -Dfile=/path/to/file Alternatively, if you host your own repository you can deploy the file there: mvn deploy:deploy-file -DgroupId=org.clojure - DartifactId=clojure-contrib -Dversion=1.3.0-SNAPS\ HOT -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] - DrepositoryId=[id] Path to dependency: 1) org.apache.maven:super-pom:jar:2.0 2) org.clojure:clojure-contrib:jar:1.3.0-SNAPSHOT When I run 'lein swank' I get: That's not a task. Use lein help to list all tasks. Any ideas how to install these tools without so much pain? Thanks, Dmitri -- You 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, Swank, and Leiningen with Emacs on Mac OS X
And this one https://github.com/technomancy/leiningen/ On May 22, 10:53 am, dokondr doko...@gmail.com wrote: Hello, I am trying to install Clojure tools on Mac OS X according to the instructions: Clojure, Swank, and Leiningen with Emacs on Linuxhttp://riddell.us/ClojureSwankLeiningenWithEmacsOnLinux.html Everything goes fine until these steps: ~$ lein deps ~$ lein swank In my project.clj I have: (defproject test-project 0.1.0 :description Test Project :dependencies [[org.clojure/clojure 1.3.0-master-SNAPSHOT] [org.clojure/clojure-contrib 1.3.0-SNAPSHOT]] :dev-dependencies [[swank-clojure 1.2.1]]) Running 'lein deps' gives these errors: Downloading: org/clojure/clojure-contrib/1.3.0-SNAPSHOT/clojure- contrib-1.3.0-SNAPSHOT.pom from cloju\ re-snapshots Downloading: org/clojure/clojure-contrib/1.3.0-SNAPSHOT/clojure- contrib-1.3.0-SNAPSHOT.pom from cloja\ rs Downloading: org/clojure/clojure-contrib/1.3.0-SNAPSHOT/clojure- contrib-1.3.0-SNAPSHOT.jar from cloju\ re-snapshots Downloading: org/clojure/clojure-contrib/1.3.0-SNAPSHOT/clojure- contrib-1.3.0-SNAPSHOT.jar from cloja\ rs An error has occurred while processing the Maven artifact tasks. Diagnosis: Unable to resolve artifact: Missing: -- 1) org.clojure:clojure-contrib:jar:1.3.0-SNAPSHOT Try downloading the file manually from the project website. Then, install it using the command: mvn install:install-file -DgroupId=org.clojure - DartifactId=clojure-contrib -Dversion=1.3.0-SNA\ PSHOT -Dpackaging=jar -Dfile=/path/to/file Alternatively, if you host your own repository you can deploy the file there: mvn deploy:deploy-file -DgroupId=org.clojure - DartifactId=clojure-contrib -Dversion=1.3.0-SNAPS\ HOT -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] - DrepositoryId=[id] Path to dependency: 1) org.apache.maven:super-pom:jar:2.0 2) org.clojure:clojure-contrib:jar:1.3.0-SNAPSHOT When I run 'lein swank' I get: That's not a task. Use lein help to list all tasks. Any ideas how to install these tools without so much pain? Thanks, Dmitri -- You 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: Aquamacs, swank-clojure: clojure-jack-in returns command not found
Thanks, that seemed to work so far. On May 22, 2:34 pm, Alex Ott alex...@gmail.com wrote: I think, that lein isn't in your search path. You can add directory with lein script explicitly using something like: (setenv PATH (concat your-lein-dir: (getenv PATH))) On Sun, May 22, 2011 at 2:17 PM, michele michelemen...@gmail.com wrote: I have tried to find a solution to this problem, but to no avail. According tohttps://github.com/technomancy/swank-clojure: USAGE The simplest way is to just jack-in from an existing project using Leiningen: Install clojure-mode either from Marmalade or from git. lein plugin install swank-clojure 1.3.1 From inside a project, invoke M-xclojure-jack-in That's all it takes! There are no extra install steps beyond clojure- mode on the Emacs side and the swank-clojure plugin on the Leiningen side. When running the following command inAquamacs: M-xclojure-jack-in I get this result: /bin/bash: lein: command not found I have installed Lein, but what does From inside a project mean? I have a feeling I'm running the command from the wrong place, but I don't know how to run a command in Emacs from somewhere else. I just started to learn Emacs, which I really like (even though the documentation how to install i.e. Clojure could be clearer). -- You 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 -- With best wishes, Alex Otthttp://alexott.net/ Tiwtter: alexott_en (English), alexott (Russian) Skype: alex.ott -- You 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: Aquamacs, swank-clojure: clojure-jack-in returns command not found
I had similar issues with Aquamacs. It went away when I installed Phil's emacs-starter-kit before trying to install anything else. Kudos for this great piece of bundle! Las sent from my mobile device On May 25, 2011 8:51 AM, michele michelemen...@gmail.com wrote: Thanks, that seemed to work so far. On May 22, 2:34 pm, Alex Ott alex...@gmail.com wrote: I think, that lein isn't in your search path. You can add directory with lein script explicitly using something like: (setenv PATH (concat your-lein-dir: (getenv PATH))) On Sun, May 22, 2011 at 2:17 PM, michele michelemen...@gmail.com wrote: I have tried to find a solution to this problem, but to no avail. According tohttps://github.com/technomancy/swank-clojure: USAGE The simplest way is to just jack-in from an existing project using Leiningen: Install clojure-mode either from Marmalade or from git. lein plugin install swank-clojure 1.3.1 From inside a project, invoke M-xclojure-jack-in That's all it takes! There are no extra install steps beyond clojure- mode on the Emacs side and the swank-clojure plugin on the Leiningen side. When running the following command inAquamacs: M-xclojure-jack-in I get this result: /bin/bash: lein: command not found I have installed Lein, but what does From inside a project mean? I have a feeling I'm running the command from the wrong place, but I don't know how to run a command in Emacs from somewhere else. I just started to learn Emacs, which I really like (even though the documentation how to install i.e. Clojure could be clearer). -- You 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 -- With best wishes,Alex Otthttp://alexott.net/ Tiwtter: alexott_en (English), alexott (Russian) Skype: alex.ott -- You 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
OutOfMemoryError: PermGen space on JEE
Hi! After few redeployments of system written in JEE I get PermGen space error. It occurs definitely after starting to use Clojure in a manner: some code goes to files.clj and then it is loaded and used like: RT.load(namespace, false); var = RT.var(namespace, method.getName()); var.invoke(); (3 lines above where just an example to show that we know what we are talking about.) Any toughts? The application server is Glassfish 2.1.1 Bye! -- You 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: OutOfMemoryError: PermGen space on JEE
Few options to try: 1. If you are on Windows/Linux/Solaris, try JRockit instead of the HotSpot VM. http://www.oracle.com/technetwork/middleware/jrockit/downloads/index.html 2. If you are still on HotSpot try setting the JAVA_OPTS to a combination of the following options: -Xms512m -Xmx1024m -XX:+UseConcMarkSweepGC -XX:MaxPermSize=128m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled Regards, Shantanu On May 25, 1:43 am, Michael Jaaka michael.ja...@googlemail.com wrote: Hi! After few redeployments of system written in JEE I get PermGen space error. It occurs definitely after starting to use Clojure in a manner: some code goes to files.clj and then it is loaded and used like: RT.load(namespace, false); var = RT.var(namespace, method.getName()); var.invoke(); (3 lines above where just an example to show that we know what we are talking about.) Any toughts? The application server is Glassfish 2.1.1 Bye! -- You 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
Run Clojure tests
Hi, I have test cases ( clojure.test) . I use Maven for runing tests. If I start it from Eclipse (clojure:test) it works fine but if I start it from console (mvn clojure:test) it complains that can not found Clojure's scripts on classpath. I've got this : Caused by: java.io.FileNotFoundException: Could not locate amsi/common/worker__init.class or amsi/common/worker.clj on classpath: What is the best approach to solve this problem (easy way to add scripts to classpath)? Thaks Zlaja -- You 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: Run Clojure tests
Hi Zlaja, I'm no maven expert but I'll try and point you in the right direction. See the clojure-maven-plugin docs here: https://github.com/talios/clojure-maven-plugin You should be able to add source folders to the classpath by using the configuration element inside the plugin declaration: plugin groupIdcom.theoryinpractise/groupId artifactIdclojure-maven-plugin/artifactId configuration sourceDirectories sourceDirectorysrc/main/clojure/sourceDirectory /sourceDirectories testSourceDirectories testSourceDirectorysrc/test/clojure/testSourceDirectory /testSourceDirectories /configuration /plugin I imagine if you have an extra directory with clojure sources you should add it as another sourceDirectory tag. NB: I haven't tested this, just following my nose. Thanks, Ambrose On Wed, May 25, 2011 at 6:54 PM, Zlatko Josic zlatko.jo...@gmail.comwrote: Hi, I have test cases ( clojure.test) . I use Maven for runing tests. If I start it from Eclipse (clojure:test) it works fine but if I start it from console (mvn clojure:test) it complains that can not found Clojure's scripts on classpath. I've got this : Caused by: java.io.FileNotFoundException: Could not locate amsi/common/worker__init.class or amsi/common/worker.clj on classpath: What is the best approach to solve this problem (easy way to add scripts to classpath)? Thaks Zlaja -- You 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: Run Clojure tests
Very good nose :) That was the problem. It works fine now. Thank you Zlaja On Wed, May 25, 2011 at 1:17 PM, Ambrose Bonnaire-Sergeant abonnaireserge...@gmail.com wrote: Hi Zlaja, I'm no maven expert but I'll try and point you in the right direction. See the clojure-maven-plugin docs here: https://github.com/talios/clojure-maven-plugin You should be able to add source folders to the classpath by using the configuration element inside the plugin declaration: plugin groupIdcom.theoryinpractise/groupId artifactIdclojure-maven-plugin/artifactId configuration sourceDirectories sourceDirectorysrc/main/clojure/sourceDirectory /sourceDirectories testSourceDirectories testSourceDirectorysrc/test/clojure/testSourceDirectory /testSourceDirectories /configuration /plugin I imagine if you have an extra directory with clojure sources you should add it as another sourceDirectory tag. NB: I haven't tested this, just following my nose. Thanks, Ambrose On Wed, May 25, 2011 at 6:54 PM, Zlatko Josic zlatko.jo...@gmail.comwrote: Hi, I have test cases ( clojure.test) . I use Maven for runing tests. If I start it from Eclipse (clojure:test) it works fine but if I start it from console (mvn clojure:test) it complains that can not found Clojure's scripts on classpath. I've got this : Caused by: java.io.FileNotFoundException: Could not locate amsi/common/worker__init.class or amsi/common/worker.clj on classpath: What is the best approach to solve this problem (easy way to add scripts to classpath)? Thaks Zlaja -- You 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
Re: Run Clojure tests
On Wed, May 25, 2011 at 7:27 PM, Zlatko Josic zlatko.jo...@gmail.comwrote: Very good nose :) That was the problem. It works fine now. Thank you Great, my pleasure. Ambrose -- You 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: core.logic now compatible with Clojure 1.2.X
On Wed, May 25, 2011 at 1:36 AM, Sunil Nandihalli sunil.nandiha...@gmail.com wrote: Thats really nice to hear.. but is the version on clojars compatible with 1.2 yet? Thanks Sunil. I fixed the 1.2 vs 1.3 numerics issue with the help of the Clojure/core team. The version on Github as well as the version on Clojars are now 1.2.X 1.3.X compatible. You can add the following to your project.clj [core.logic 0.6.1-SNAPSHOT] And you should be good to go. David -- You 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: OutOfMemoryError: PermGen space on JEE
This is a fairly notorious problem with app server redeployments, and is orthogonal to using clojure. On May 25, 1:43 am, Michael Jaaka michael.ja...@googlemail.com wrote: Hi! After few redeployments of system written in JEE I get PermGen space error. It occurs definitely after starting to use Clojure in a manner: some code goes to files.clj and then it is loaded and used like: RT.load(namespace, false); var = RT.var(namespace, method.getName()); var.invoke(); (3 lines above where just an example to show that we know what we are talking about.) Any toughts? The application server is Glassfish 2.1.1 Bye! -- You 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 convert a string to a data structure
Hi, If I have a following string for example: [{:a blah :b 23}(:d 34 :c hello}] how can I convert it to a clojure data structure? Thanks, Ron. -- You 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 convert a string to a data structure
On Wed, May 25, 2011 at 9:04 PM, ron peterson peterson.ron...@gmail.com wrote: Hi, If I have a following string for example: [{:a blah :b 23}(:d 34 :c hello}] how can I convert it to a clojure data structure? = (read-string [{:a \blah\ :b 23}{:d 34 :c \hello\}]) [{:a blah :b 23}{:d 34 :c hello}] = -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- You 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 convert a string to a data structure
Use: (read-string (read-string [{:a \blah\ :b 23} {:d 34 :c \hello\}]) I believe your expression is wrong, (:d should be {:d. Luc P. On Wed, 25 May 2011 18:04:11 -0700 (PDT) ron peterson peterson.ron...@gmail.com wrote: Hi, If I have a following string for example: [{:a blah :b 23}(:d 34 :c hello}] how can I convert it to a clojure data structure? Thanks, Ron. -- Luc P. The rabid Muppet -- You 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
Efficient sparse vector representation...
Hi all, has anyone spent some thought on how to efficiently represent sparse vectors in Clojure? A naive scheme I came up with is using a vector of [idx val] pairs, e.g.: (def sparse-vec [[12 a][23 aa][25 aaa][234 ]]) Accessing a value at an idx can be done so: (get-nth sparse-vec 25) = aaa with: (defn get-nth [sparse-vec n] (let [indices (map (fn [[i _]] i) sparse-vec) idx (java.util.Collections/binarySearch indices n) [_ v] (nth sparse-vec idx)] v)) For this to work the indices have to be in order. Can anyone think of more efficient (algorithmically and implementation wise) ways of doing this? Kind Regards Andreas -- You 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: Efficient sparse vector representation...
I think you've reinvented hashmaps: {12 a 23 aa 25 aaa 234 } On May 25, 6:51 pm, Andreas Kostler andreas.koestler.le...@gmail.com wrote: Hi all, has anyone spent some thought on how to efficiently represent sparse vectors in Clojure? A naive scheme I came up with is using a vector of [idx val] pairs, e.g.: (def sparse-vec [[12 a][23 aa][25 aaa][234 ]]) Accessing a value at an idx can be done so: (get-nth sparse-vec 25) = aaa with: (defn get-nth [sparse-vec n] (let [indices (map (fn [[i _]] i) sparse-vec) idx (java.util.Collections/binarySearch indices n) [_ v] (nth sparse-vec idx)] v)) For this to work the indices have to be in order. Can anyone think of more efficient (algorithmically and implementation wise) ways of doing this? Kind Regards Andreas -- You 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
difference between Composite Form Special Form
In page 19 of Pratical Clojure by Luke VanderHart Stuart Sierra, Chapter 2, there is a paragraph, Special forms definition : Special forms are a particular type of composite form. For most purposes, they are used very similarly to a function call. The difference is that the first form of a special form is not a function defined somewhere, but a special system form that’s built into Clojure. 1st question, Is the form word is a typo here? Isn't the word will be item? If not, is def a form? That means, this code contains 3 forms. :-s Cause later on, when the write was explaining an example, he used item. (def message Hello, World!) Analyzing the first form, (def message Hello, World!) , you see first that it is enclosed in parenthesis. Therefore, it is a list, and will be evaluated as a function application or a special form. There are three items in the list: def, message and Hello, World!. The first item on the list, def, will be the function or special form that is called. In this case, it's a special form. But like a function, it takes two parameters—the var to define, and the value to which to bind it. Evaluating this form creates a var which establishes a binding of the value Hello, World! to the symbol message. 2nd question, Is a composite form is a special form only when, the first item of a list is something that is only predefined withing Clojure? If yes, then is it possible to create custom special form? Is then the custom composite form is gonna be called as a special form? Cause, according to the definition, my custom is not something built in clojure, it is defined somewhere else? EDIT: I guess the answer to my first question is no, its not a typo. def IS a form. cause later on the write said, The second form (println message) is also a list and this time it’s a normal function application. It has two component forms—each of them is a symbol That means, (println message) the whole thing is a form, and every thing else(function arguments) that it holds is also a form. But, at the beginning the writer said, there are four basic varieties of forms. 1. Literal, 2. Symbol, 3. Composite form and 4. Special form. According to the definition of Symbols from the book, its not a symbol. Symbol Definition: Symbols are forms which resolve to a value. They may be thought of as roughly similar to variables, although this is not technically accurate since they are not actually variable in the same way variables in most languages are. In Clojure, symbols are used to identify function arguments, and globally or locally defined values. Symbols and their resolution are discussed in more detail in the following sections. Cause, writing def and pressing return key produces the following error message, In which category, def falls into? -- You 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: Efficient sparse vector representation...
Yes and no. I need efficient two way lookup. So, I need to do something like For every key in {12 a 23 aa 234 } Get the token in a map that is organised like this: {token1 id1 token2 id2 token2 id3} Naively, I could have two maps with the reverse lookups. l1 = {token1 id1 token2 id2 token3 id3} reverse = {id1 token1 id2 token2 ...} Given that there will be many, many tokens this seems a bit too much overhead. You could basically do a binarySearch on a sorted hash map (sorted by vals (e.g. ids)) but I thought doing the search on a vec of vectors would be more efficient and the vec of vecs representation would be more compact. I guess that's what I'm trying to figure out. Andreas P.S. Lookup by token is more frequent than lookup by id, hence the bin search on id. The sparse vec will be [id val] pairs. There is a big map of token- id. So I can get to the id of a word vial (token-map token) If I now have a map of {id1 token1 id1 token2 ... } On 26/05/2011, at 12:00 PM, Alan Malloy wrote: I think you've reinvented hashmaps: {12 a 23 aa 25 aaa 234 } On May 25, 6:51 pm, Andreas Kostler andreas.koestler.le...@gmail.com wrote: Hi all, has anyone spent some thought on how to efficiently represent sparse vectors in Clojure? A naive scheme I came up with is using a vector of [idx val] pairs, e.g.: (def sparse-vec [[12 a][23 aa][25 aaa][234 ]]) Accessing a value at an idx can be done so: (get-nth sparse-vec 25) = aaa with: (defn get-nth [sparse-vec n] (let [indices (map (fn [[i _]] i) sparse-vec) idx (java.util.Collections/binarySearch indices n) [_ v] (nth sparse-vec idx)] v)) For this to work the indices have to be in order. Can anyone think of more efficient (algorithmically and implementation wise) ways of doing this? Kind Regards Andreas -- You 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 -- Test-driven Dentistry (TDD!) - Not everything should be test driven - Michael Fogus -- ** Andreas Koestler, Software Engineer Leica Geosystems Pty Ltd 270 Gladstone Road, Dutton Park QLD 4102 Main: +61 7 3891 9772 Direct: +61 7 3117 8808 Fax: +61 7 3891 9336 Email: andreas.koest...@leica-geosystems.com www.leica-geosystems.com* when it has to be right, Leica Geosystems Please consider the environment before printing this email. -- You 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: core.logic now compatible with Clojure 1.2.X
Thank you, thank you, thank you for making this happen (and your Vimeo talks)! -ck On May 25, 12:19 pm, David Nolen dnolen.li...@gmail.com wrote: On Wed, May 25, 2011 at 1:36 AM, Sunil Nandihalli sunil.nandiha...@gmail.com wrote: Thats really nice to hear.. but is the version on clojars compatible with 1.2 yet? Thanks Sunil. I fixed the 1.2 vs 1.3 numerics issue with the help of the Clojure/core team. The version on Github as well as the version on Clojars are now 1.2.X 1.3.X compatible. You can add the following to your project.clj [core.logic 0.6.1-SNAPSHOT] And you should be good to go. David -- You 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: Debian packages
I'm curious about this as well, because of the ICFP programming contest. The contest organizers are soliciting requests for Debian packages to be installed on the contest environment. I don't suppose that this is the reason that you're asking? On May 24, 9:41 pm, Phil Hagelberg p...@hagelb.org wrote: It looks like Clojure 1.1.0 and the corresponding version of contrib were packaged for Debian. Is the fellow who packaged that still around? Are there any plans to package 1.2.1 and contrib 1.2.0? -Phil -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com 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: difference between Composite Form Special Form
On Wed, May 25, 2011 at 10:15 PM, iamcreasy quazir...@gmail.com wrote: 1st question, Is the form word is a typo here? Isn't the word will be item? If not, is def a form? That means, this code contains 3 forms. :-s Technically, anything that can be evaluated is a form. A composite form is something like a literal list, vector, set, or map. The literal list case is treated as an operator and arguments; the other three just evaluate to vectors, sets, or maps, respectively, whose members are the evaluations of the nested forms, so: + = the + function (+ 1 2)= 3 [+ 1 2]= a vector of the + function, 1, and 2. [(+ 1 2)] = [3] #{(+ 1 2) 4} = #{3 4} {:a (+ 1 2)} = {:a 3} 2nd question, Is a composite form is a special form only when, the first item of a list is something that is only predefined withing Clojure? If yes, then is it possible to create custom special form? Sort of. You can create a macro with defmacro, which like a special form controls the evaluation of its arguments instead of the arguments being evaluated first and the function only getting the results. Things like - and defn are macros: (- 3 (+ 1) (* 2)) adds 1 to 3, then doubles, yielding 8. This couldn't work with a function, as it would get arguments 3, 1, and 2 as (+ 1) would evaluate, first, to 1, and (* 2) to 2. It wouldn't know what to do with 3, 1, or 2 -- whether to add 1 and then multiply by 2, or subtract 1 and then add 2, or what. The macro, however, operates on the *forms* and gets 3, (+ 1), and (* 2) and combines the first two into (+ 3 1) and that and the third into (* (+ 3 1) 2) by inserting each form into the next one after the operator and before everything else. (defn foo [a b] (+ (* a a) (* b b))) also cannot be a normal function call. If it were there would be several errors: foo undefined (most likely), also a and b undefined, so the first argument foo could not be evaluated, nor could the second [a b], nor could the third (+ (* a a) (* b b)). But instead it works to generate a function definition. It's a macro that expands to a (def ...) form, in fact. But, at the beginning the writer said, there are four basic varieties of forms. 1. Literal, 2. Symbol, 3. Composite form and 4. Special form. I'd say it's a bit more complicated than that. We have six things that are evaluated somewhat differently: 1. nil, true, false, numbers, strings, regexps, keywords ... evaluate to themselves. 2. symbols are looked up when evaluated to find a local or global var value they evaluate to. 3. Set, vector, and map literals have subforms evaluated, then evaluate to a set, vector, or map with the subforms replaced by their evaluated values. 4. (foo bar baz), if foo is a special operator like def, is a special form and is evaluated according to the built-in rules for that form. 5. (foo bar baz) with foo not a special operator: the subform foo is looked up at compile time and if it's a macro, macro expansion is performed. The transformed code is then evaluated per these rules. 6. (foo bar baz) with foo not a special operator or a macro. At compile time, code is generated to evaluate foo, bar, and baz at runtime and then apply foo as a function to the arguments bar and baz. The latter three can, of course, have zero or more arguments, not just two, and generalize appropriately. Different things happen at compile and run time in each case: Thing Compile Run literal inserted into bytecoderecalled from memory symbol var resolved, deref compiled var is deref'd (def bar baz) bar var interned baz eval'd, bar set (macro x y) macro is expanded expansion is eval'd (func bar baz) fn-calling code compiled func called with args For special forms other than def, the behavior varies; (if bar baz quux) for example compiles to a conditional test and branch and at run time bar is eval'd, then the test and possibly the branch occurs, and either baz or quux is eval'd. According to the definition of Symbols from the book, its not a symbol. 'def is definitely a symbol. (No pun intended.) However (def ...) is recognized as a special form by the compiler. Note that: defsymbol (def ...) special form You can actually create variables named def and the like. If you reference them in other than operator position, it works: = (defn def [x] (+ x 2)) #'user/def = (map def [1 2 3 4 5]) (3 4 5 6 7) In operator position, though, you get the special form unless you qualify the name: = (def quux 42) #'user/quux = (user/def quux) 44 If you define it locally, you can't use it in operator position at all, unless you rename it: = (let [def (fn [x y] (+ x y 2)) a def] (println (def foo 42)) (println (a foo 42))) #'user/foo 86 nil The second let binding gives the local def another name, a, that can be used to invoke it. It ends up using the
Re: Efficient sparse vector representation...
On 26/05/2011, at 1:12 PM, Ken Wesson wrote: On Wed, May 25, 2011 at 10:22 PM, Andreas Kostler andreas.koestler.le...@gmail.com wrote: Yes and no. I need efficient two way lookup. So, I need to do something like For every key in {12 a 23 aa 234 } Get the token in a map that is organised like this: {token1 id1 token2 id2 token2 id3} Naively, I could have two maps with the reverse lookups. l1 = {token1 id1 token2 id2 token3 id3} reverse = {id1 token1 id2 token2 ...} Given that there will be many, many tokens this seems a bit too much overhead. You could basically do a binarySearch on a sorted hash map (sorted by vals (e.g. ids)) but I thought doing the search on a vec of vectors would be more efficient and the vec of vecs representation would be more compact. I guess that's what I'm trying to figure out. Andreas P.S. Lookup by token is more frequent than lookup by id, hence the bin search on id. If the token and id sets are disjoint (no single object can ever appear as each -- only one of those at most) then you can use a single map with a function put defined as: (defn put [m k v] (assoc (assoc m k v) v k)) which adds mappings in both directions. Then just use (m k) or (m v) to perform lookups in either direction. The overhead may be less than with two separate hashmaps, and the code is certainly simpler. Hi Ken, That indeed could be useful. What are your thoughts on the proposed solution of representing sparse vectors as maps (id- val)? Having a vec of vector or a map with ids and vals vectors {:ids [vec of ids] :vals [vec of val]} is just a lot easier to deal with for calculations. E.g normalisation ;; For a sparse vector as map (defn normalise-m [m] (let [vals (vals m) keys (keys m) l (Math/sqrt (reduce + (map #(* % %) vals)))] (zipmap keys (map #(/ % l) vals ;; For a map of id/val vecs (defn normalise [sv] (let [l (Math/sqrt (reduce + (map #(* % %) (:vals sv] {:i (:i sv) :vals (map #(/ % l) (:vals sv))})) The latter outperforms the former by more than a factor of 10. Has anyone used sparse vectors or think of a reasonable implementation? -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- You 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: Efficient sparse vector representation...
On that note, is there an easy way of measuring memory usage? Andreas On 26/05/2011, at 1:12 PM, Ken Wesson wrote: On Wed, May 25, 2011 at 10:22 PM, Andreas Kostler andreas.koestler.le...@gmail.com wrote: Yes and no. I need efficient two way lookup. So, I need to do something like For every key in {12 a 23 aa 234 } Get the token in a map that is organised like this: {token1 id1 token2 id2 token2 id3} Naively, I could have two maps with the reverse lookups. l1 = {token1 id1 token2 id2 token3 id3} reverse = {id1 token1 id2 token2 ...} Given that there will be many, many tokens this seems a bit too much overhead. You could basically do a binarySearch on a sorted hash map (sorted by vals (e.g. ids)) but I thought doing the search on a vec of vectors would be more efficient and the vec of vecs representation would be more compact. I guess that's what I'm trying to figure out. Andreas P.S. Lookup by token is more frequent than lookup by id, hence the bin search on id. If the token and id sets are disjoint (no single object can ever appear as each -- only one of those at most) then you can use a single map with a function put defined as: (defn put [m k v] (assoc (assoc m k v) v k)) which adds mappings in both directions. Then just use (m k) or (m v) to perform lookups in either direction. The overhead may be less than with two separate hashmaps, and the code is certainly simpler. -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- You 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: core.logic now compatible with Clojure 1.2.X
thanks David. Sunil. On Wed, May 25, 2011 at 9:49 PM, David Nolen dnolen.li...@gmail.com wrote: On Wed, May 25, 2011 at 1:36 AM, Sunil Nandihalli sunil.nandiha...@gmail.com wrote: Thats really nice to hear.. but is the version on clojars compatible with 1.2 yet? Thanks Sunil. I fixed the 1.2 vs 1.3 numerics issue with the help of the Clojure/core team. The version on Github as well as the version on Clojars are now 1.2.X 1.3.X compatible. You can add the following to your project.clj [core.logic 0.6.1-SNAPSHOT] And you should be good to go. David -- You 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