into map with vectors versus lists (Re: Creating map from string)
I expected this to work: (into {} (partition 2 (split (slurp data) #,))) But unfortunately, `into' doesn't seem to allow pushing lists of pairs into a map. But vectors are allowed: (into {} (map vec (partition 2 (split (slurp data) #, Can somebody explain why vectors are allowed and lists not? On 2010/12/03 15:40, Laurent PETIT wrote: Hi, 2010/12/3 Anclj anb...@gmail.com Hi, I have a string of data and I would like to get a map {:key value, :key value, …} How could I do that? I've got: user (split (slurp data) #,) [0 2 1 5 2 8 3 15 4 9] And I would like: {:0 2, :1 5, :2 8, :3 15, :4 9} Any idea? (let [s (split (slurp data) #,)] (zipmap (take-nth 2 s) (take-nth 2 (rest s 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 -- You 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: when to use io! macro?
I've recently discovered the io! macro. Is this something to try to use all the time.. or only in certain situations? It's useful when you are exposing some sort of an API (internal external) and want to prohibit the use of certain functions inside transactions. Regards, BG -- Baishampayan Ghose b.ghose at 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
range with decimal values
If I use the range fn with a decimal number for step I get back something like this: (range 0.05 0.16 0.01) user (0.05 0.060005 0.07 0.08 0.09 0.0 0.10999 0.11998 0.12998 0.13999 0.15) Really I want output more like i get from the following fn: (map float (range 5/100 16/100 1/100)) user (0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15) -- You 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
binary search tree in clojure
As an exercise in learning clojure, I implemented a basic binary search tree in clojure: https://gist.github.com/727982 Any feedback would be appreciated. -Todd -- You 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: Easy Way To Download Clojure Libraries From Git
I created a leiningen plugin especially for this purpose - when you just want to play with a library/a set of libraries and creating a brand new leiningen project feels too much. It's called lein-oneoff and available here: https://github.com/mtyaka/lein-oneoff It assumes your program/script to consist of a single file. You declare dependencies at the top of the file and then you can either run the script or start a repl or swank server with the classpath correctly set up for you. The plugin will download any missing dependencies and install them into the local maven repository automatically. Please see the README for more info. - Matjaz On Sat, Dec 4, 2010 at 6:47 AM, Asim Jalis asimja...@gmail.com wrote: Thanks! This is exactly what I was looking for. On Fri, Dec 3, 2010 at 6:12 PM, Alan Dipert a...@dipert.org wrote: Hi, David Liebke's cljr may meet your needs: https://github.com/liebke/cljr I also maintain a fork over at https://github.com/alandipert/cljr that runs Clojure 1.3-alpha3. HTH, Alan On Fri, Dec 3, 2010 at 9:04 PM, buckmeist...@gmail.com wrote: I second the recommendation to use leiningen. I can relate to your position of just wanting to play with the libraries and not being ready to create projects. But I'm not a classpath ninja of epic proportions. Really, I don't have a desire to be that. If you aren't either, you will want to use leiningen and create a project, following Sunil's instructions (and technomancy's readme at github is good for more detail/options). I found that for me, trying to use clojure without leiningen or a similar tool was a mistake. Thanks, Peter From: Sunil S Nandihalli sunil.nandiha...@gmail.com Sender: clojure@googlegroups.com Date: Sat, 4 Dec 2010 07:12:23 +0530 To: clojure@googlegroups.com ReplyTo: clojure@googlegroups.com Subject: Re: Easy Way To Download Clojure Libraries From Git Hi Asim, just do lein new and add [clojureql 1.0.0-beta2-SNAPSHOT] to your dependencies in project.clj and run lein deps it will automatically download all the necessary dependencies. If you directly want to do it from github .. I don't know how to do that. Sunil. On Sat, Dec 4, 2010 at 6:23 AM, Asim Jalis asimja...@gmail.com wrote: Is there an easy way to download Clojure libraries from Git and to play with them in the repl? It looks like all of them expect to be downloaded using leiningen, and leiningen requires creating a project, with dependencies on specific libraries. It would be nice if I could do something like: lein install https://github.com/LauJensen/clojureql and it would just grab it and install it and all its dependencies. My goal is just to play with different libraries -- I am not consuming them in projects yet. Asim -- You 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.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.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.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.
Fixing minmax algorithm
I'm trying to make a functional version of minmax algorithm as shown in John Hughes Why functional programming matters? work [http:// www.scribd.com/doc/26902/whyfp]. I'm hitting problems when applying maximise function on my gametree. For some reason the maximise call won't return the best value the position can get but a nested list of numbers. Like the call to min/ max functions is not done at all. The results nesting depends on the given search depth. For depth 2 it returns list of list of numbers. What am I doing wrong here? As far as I know the maximise / minimise functions should return one integer, not a list in any case? Here's my version of the maximise / minimise functions, haskell version in comments: ;; maximise (node n nil) = n ;; maximise (node n sub) = max (map minimise sub) (declare minimise) (defn- maximise [node] (if (empty? (:subtree node)) (:label node) (max (map minimise (:subtree node) ;; minimise (node n nil) = n ;; minimise (node n sub) = min (map maximise sub) (defn- minimise [node] (if (empty? (:subtree node)) (:label node) (min (map maximise (:subtree node) ;; evaluate = maximise . maptree static . prune 5 . gametree (defn evaluate-minmax [depth state] (do (println ###) (print EVALUATE-MINMAX[depth state]:) (prn depth state) (println ###) (let [tree (- state gametree (prune depth) (maptree static))] (do (println ###) (print Calling maximise on tree:) (prn tree) (println ###) (maximise tree) ### And output of the maximise call ### ### Calling maximise on tree:#:tursas.search2.Node{:label 21, :subtree (#:tursas.search2.Node{:label 79, :subtree (#:tursas.search2.Node{:label 4, :subtree nil} #:tursas.search2.Node{:label 76, :subtree nil} #:tursas.search2.Node{:label 82, :subtree nil} #:tursas.search2.Node{:label 82, :subtree nil} #:tursas.search2.Node{:label 67, :subtree nil} #:tursas.search2.Node{:label 30, :subtree nil} #:tursas.search2.Node{:label 94, :subtree nil} #:tursas.search2.Node{:label 70, :subtree nil} #:tursas.search2.Node{:label 82, :subtree nil} #:tursas.search2.Node{:label 84, :subtree nil} #:tursas.search2.Node{:label 54, :subtree nil} #:tursas.search2.Node{:label 29, :subtree nil})} #:tursas.search2.Node{:label 8, :subtree (#:tursas.search2.Node{:label 38, :subtree nil} #:tursas.search2.Node{:label 47, :subtree nil} #:tursas.search2.Node{:label 65, :subtree nil} #:tursas.search2.Node{:label 32, :subtree nil} #:tursas.search2.Node{:label 88, :subtree nil} #:tursas.search2.Node{:label 20, :subtree nil} #:tursas.search2.Node{:label 21, :subtree nil} #:tursas.search2.Node{:label 37, :subtree nil} #:tursas.search2.Node{:label 93, :subtree nil} #:tursas.search2.Node{:label 88, :subtree nil} #:tursas.search2.Node{:label 78, :subtree nil} #:tursas.search2.Node{:label 66, :subtree nil})} #:tursas.search2.Node{:label 34, :subtree (#:tursas.search2.Node{:label 42, :subtree nil} #:tursas.search2.Node{:label 56, :subtree nil} #:tursas.search2.Node{:label 72, :subtree nil} #:tursas.search2.Node{:label 55, :subtree nil} #:tursas.search2.Node{:label 29, :subtree nil} #:tursas.search2.Node{:label 79, :subtree nil} #:tursas.search2.Node{:label 86, :subtree nil} #:tursas.search2.Node{:label 30, :subtree nil} #:tursas.search2.Node{:label 74, :subtree nil} #:tursas.search2.Node{:label 87, :subtree nil} #:tursas.search2.Node{:label 58, :subtree nil} #:tursas.search2.Node{:label 84, :subtree nil})} #:tursas.search2.Node{:label 78, :subtree (#:tursas.search2.Node{:label 69, :subtree nil} #:tursas.search2.Node{:label 41, :subtree nil} #:tursas.search2.Node{:label 69, :subtree nil} #:tursas.search2.Node{:label 34, :subtree nil} #:tursas.search2.Node{:label 30, :subtree nil} #:tursas.search2.Node{:label 42, :subtree nil} #:tursas.search2.Node{:label 12, :subtree nil} #:tursas.search2.Node{:label 34, :subtree nil} #:tursas.search2.Node{:label 22, :subtree nil} #:tursas.search2.Node{:label 46, :subtree nil} #:tursas.search2.Node{:label 67, :subtree nil} #:tursas.search2.Node{:label 16, :subtree nil})} #:tursas.search2.Node{:label 61, :subtree (#:tursas.search2.Node{:label 52, :subtree nil} #:tursas.search2.Node{:label 84, :subtree nil} #:tursas.search2.Node{:label 84, :subtree nil} #:tursas.search2.Node{:label 65, :subtree nil} #:tursas.search2.Node{:label 30, :subtree nil} #:tursas.search2.Node{:label 75, :subtree nil} #:tursas.search2.Node{:label 57, :subtree nil} #:tursas.search2.Node{:label 87, :subtree nil} #:tursas.search2.Node{:label 96, :subtree nil})} #:tursas.search2.Node{:label 39, :subtree (#:tursas.search2.Node{:label 39, :subtree nil} #:tursas.search2.Node{:label 34, :subtree nil} #:tursas.search2.Node{:label 77, :subtree nil} #:tursas.search2.Node{:label 56, :subtree nil} #:tursas.search2.Node{:label 30, :subtree nil} #:tursas.search2.Node{:label 16, :subtree nil}
Re: range with decimal values
On Dec 4, 2010, at 8:42 AM, Glen Rubin wrote: If I use the range fn with a decimal number for step I get back something like this: (range 0.05 0.16 0.01) user (0.05 0.060005 0.07 0.08 0.09 0.0 0.10999 0.11998 0.12998 0.13999 0.15) Really I want output more like i get from the following fn: (map float (range 5/100 16/100 1/100)) user (0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15) Perhaps (map (partial * 0.01) (range 5 16))? -- You 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: range with decimal values
On Dec 4, 7:42 am, Glen Rubin rubing...@gmail.com wrote: (range 0.05 0.16 0.01) user (0.05 0.060005 0.07 0.08 0.09 0.0 0.10999 0.11998 0.12998 0.13999 0.15) You are seeing an artifact of the fact that floating point numbers cannot exactly represent decimal numbers. The repl is printing out the full precision of the numbers. If you are interested in formatting the numbers nicely, you can do something like this: user (map #(format %.2f %1) (range 0.05 0.16 0.01)) (0.05 0.06 0.07 0.08 0.09 0.10 0.11 0.12 0.13 0.14 0.15) Doing math with floating point numbers is generally fine, unless you have need for very high accuracy. Just format the final output when you want to display it. mch -- You 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
appengine-clj and appengine 1.4 SDK error
Greetings, My toy application stopped working after an upgrade to appengine SDK 1.4, does anyone else have the same experience? Any solutions? You can see error logs at https://github.com/r0man/appengine-clj/issues/#issue/5 (thank you r0man for helping out). The project can be found at https://bitbucket.org/tebeka/biggieurl/src Thanks, -- Miki -- You 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: Creating map from string
How about just (apply hash-map (split (slurp data) #,)) -- You 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: Apache ws-xmlrpc
I guess you should look at XML-RPC2, which has a simpler usage: http://ws.apache.org/xmlrpc/xmlrpc2/server.html Regards, Shantanu On Dec 4, 10:26 pm, Rock rocco.ro...@gmail.com wrote: I'm desperately trying to implement an xml-rpc server with Clojure (trying to convince the company I work for here in Italy to give it a shot). I'm pretty well versed in Lisp, but I have yet to acquire sufficient experience with Clojure's Java interop capabilities. I've read the docs for implementing a server with ws-xmlrpc here: http://ws.apache.org/xmlrpc/server.html But I really can't figure out how to translate this to Clojure. Thanks to all for any help in this respect. -- You 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: Creating map from string
Using 'apply hash-map' doesn't handle the transformations. Note the original post requested keywords for keys and integers for vals in the output. On Dec 4, 11:49 am, Tyler Perkins thinks.outs...@gmail.com wrote: How about just (apply hash-map (split (slurp data) #,)) -- You 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: Apache ws-xmlrpc
Looks pretty good. Thank you so much. This does however worry me a little from another point of view. There's always been a lot of talk about how easy it is to interface Clojure to Java. Yet, when it comes to a lot of situations (for instance, when dealing with annotations as in the JAX-WS SOAP web service facility), it doesn't seem at all straightforward. By the way, anybody know what the story is with Java annotations currently? I read somewhere that Clojure 1.2 (or possibly 1.3) can support them to a certain extent. On Dec 4, 8:11 pm, Shantanu Kumar kumar.shant...@gmail.com wrote: I guess you should look at XML-RPC2, which has a simpler usage:http://ws.apache.org/xmlrpc/xmlrpc2/server.html Regards, Shantanu On Dec 4, 10:26 pm, Rock rocco.ro...@gmail.com wrote: I'm desperately trying to implement an xml-rpc server with Clojure (trying to convince the company I work for here in Italy to give it a shot). I'm pretty well versed in Lisp, but I have yet to acquire sufficient experience with Clojure's Java interop capabilities. I've read the docs for implementing a server with ws-xmlrpc here: http://ws.apache.org/xmlrpc/server.html But I really can't figure out how to translate this to Clojure. Thanks to all for any help in this respect. -- You 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
ANN: Logos 0.1 - An Optimized miniKanren Logic Programming Library for Clojure
I announced it earlier this week on Twitter, but it's now come far along enough to be usable. You can write fun stuff like the following: (defn likes [x y] (cond-e ((== x 'john) (== y 'mary)) ((== x 'mary) (== y 'john (defn musician [x] (cond-e ((== x 'john)) ((== x 'bob (run* [q] (likes q 'mary) (musician q)) ;; [john] (run* [q] (musician q)) ;; [john bob] (run* [q] (exist [x y] (likes x y) (== [x y] q))) ;; [[john mary] [mary john]] My inspiration to start on this was Jim Duey's implementation. However I had two specific goals - * Focus on performance. While developing I compared performance against miniKanren under Racket - I made sure the Clojure implementation ran at least as fast, and in many cases it runs quite a bit faster * Implement growable sequences without resorting to Scheme's dotted pairs. This required me to develop a new protocol in which iteration might return a logic var instead of nil or a Seq. The implementation started with the one described William Byrd's dissertation. However a considerable number of changes were made- * substitutions are implemented as a protocol and a defrecord * substitutions internally use a PersistentHashMap as well as PersistentVector (for debugging) * supports unification of all the Clojure data structures supported by clojure.walk * goal and goal constructors are implements as deftypes (Mzero, Unit, Choice, Inc) and those implement IMPlus and IBind protocols. The code base is compact, some ~450 lines of Clojure. Future directions: * Friendlier interface for defining facts and running queries * There are many great ideas in William Byrd's thesis that need looking into. In particular I'm interested in tabling. * Investigating replacing the PersistentHashMap with a Skew Binary Random Access List or a Finger Tree. This would speed up the performance of the most expensive functions in the system, walk. In the Scheme implementations SBRALs can lead to 2.5X-100X in performance. * Modifying the core macros to optimize logic programs. * Parallel logic programming. Source and more info here, https://github.com/swannodette/logos. -- You 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: Creating map from string
On Dec 4, 12:21 pm, Tim Robinson tim.blacks...@gmail.com wrote: Using 'apply hash-map' doesn't handle the transformations. Note the original post requested keywords for keys and integers for vals in the output. I'm not the only one who overlooked that! :o) Might just as well use strings as keys. But OK, try this: (apply hash-map (- (str { (slurp data) }) read-string (map (fn [[k v]] [(keyword (str k)) v])) flatten)) -- You 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: Creating map from string
Or, better yet, (into {} (- (str { (slurp data) }) read-string (map (fn [[k v]] [(keyword (str k)) v] -- You 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: Fixing minmax algorithm
You're looking for apply. user2 (max 1 2 3) 3 user2 (max [1 2 3]) [1 2 3] user2 (apply max [1 2 3]) 3 -Jason On Dec 4, 3:30 am, zmyrgel timo.my...@gmail.com wrote: I'm trying to make a functional version of minmax algorithm as shown in John Hughes Why functional programming matters? work [http://www.scribd.com/doc/26902/whyfp]. I'm hitting problems when applying maximise function on my gametree. For some reason the maximise call won't return the best value the position can get but a nested list of numbers. Like the call to min/ max functions is not done at all. The results nesting depends on the given search depth. For depth 2 it returns list of list of numbers. What am I doing wrong here? As far as I know the maximise / minimise functions should return one integer, not a list in any case? Here's my version of the maximise / minimise functions, haskell version in comments: ;; maximise (node n nil) = n ;; maximise (node n sub) = max (map minimise sub) (declare minimise) (defn- maximise [node] (if (empty? (:subtree node)) (:label node) (max (map minimise (:subtree node) ;; minimise (node n nil) = n ;; minimise (node n sub) = min (map maximise sub) (defn- minimise [node] (if (empty? (:subtree node)) (:label node) (min (map maximise (:subtree node) ;; evaluate = maximise . maptree static . prune 5 . gametree (defn evaluate-minmax [depth state] (do (println ###) (print EVALUATE-MINMAX[depth state]:) (prn depth state) (println ###) (let [tree (- state gametree (prune depth) (maptree static))] (do (println ###) (print Calling maximise on tree:) (prn tree) (println ###) (maximise tree) ### And output of the maximise call ### ### Calling maximise on tree:#:tursas.search2.Node{:label 21, :subtree (#:tursas.search2.Node{:label 79, :subtree (#:tursas.search2.Node{:label 4, :subtree nil} #:tursas.search2.Node{:label 76, :subtree nil} #:tursas.search2.Node{:label 82, :subtree nil} #:tursas.search2.Node{:label 82, :subtree nil} #:tursas.search2.Node{:label 67, :subtree nil} #:tursas.search2.Node{:label 30, :subtree nil} #:tursas.search2.Node{:label 94, :subtree nil} #:tursas.search2.Node{:label 70, :subtree nil} #:tursas.search2.Node{:label 82, :subtree nil} #:tursas.search2.Node{:label 84, :subtree nil} #:tursas.search2.Node{:label 54, :subtree nil} #:tursas.search2.Node{:label 29, :subtree nil})} #:tursas.search2.Node{:label 8, :subtree (#:tursas.search2.Node{:label 38, :subtree nil} #:tursas.search2.Node{:label 47, :subtree nil} #:tursas.search2.Node{:label 65, :subtree nil} #:tursas.search2.Node{:label 32, :subtree nil} #:tursas.search2.Node{:label 88, :subtree nil} #:tursas.search2.Node{:label 20, :subtree nil} #:tursas.search2.Node{:label 21, :subtree nil} #:tursas.search2.Node{:label 37, :subtree nil} #:tursas.search2.Node{:label 93, :subtree nil} #:tursas.search2.Node{:label 88, :subtree nil} #:tursas.search2.Node{:label 78, :subtree nil} #:tursas.search2.Node{:label 66, :subtree nil})} #:tursas.search2.Node{:label 34, :subtree (#:tursas.search2.Node{:label 42, :subtree nil} #:tursas.search2.Node{:label 56, :subtree nil} #:tursas.search2.Node{:label 72, :subtree nil} #:tursas.search2.Node{:label 55, :subtree nil} #:tursas.search2.Node{:label 29, :subtree nil} #:tursas.search2.Node{:label 79, :subtree nil} #:tursas.search2.Node{:label 86, :subtree nil} #:tursas.search2.Node{:label 30, :subtree nil} #:tursas.search2.Node{:label 74, :subtree nil} #:tursas.search2.Node{:label 87, :subtree nil} #:tursas.search2.Node{:label 58, :subtree nil} #:tursas.search2.Node{:label 84, :subtree nil})} #:tursas.search2.Node{:label 78, :subtree (#:tursas.search2.Node{:label 69, :subtree nil} #:tursas.search2.Node{:label 41, :subtree nil} #:tursas.search2.Node{:label 69, :subtree nil} #:tursas.search2.Node{:label 34, :subtree nil} #:tursas.search2.Node{:label 30, :subtree nil} #:tursas.search2.Node{:label 42, :subtree nil} #:tursas.search2.Node{:label 12, :subtree nil} #:tursas.search2.Node{:label 34, :subtree nil} #:tursas.search2.Node{:label 22, :subtree nil} #:tursas.search2.Node{:label 46, :subtree nil} #:tursas.search2.Node{:label 67, :subtree nil} #:tursas.search2.Node{:label 16, :subtree nil})} #:tursas.search2.Node{:label 61, :subtree (#:tursas.search2.Node{:label 52, :subtree nil} #:tursas.search2.Node{:label 84, :subtree nil} #:tursas.search2.Node{:label 84, :subtree nil} #:tursas.search2.Node{:label 65, :subtree nil} #:tursas.search2.Node{:label 30, :subtree nil} #:tursas.search2.Node{:label 75, :subtree nil} #:tursas.search2.Node{:label 57, :subtree nil} #:tursas.search2.Node{:label 87, :subtree nil} #:tursas.search2.Node{:label 96, :subtree nil})} #:tursas.search2.Node{:label 39, :subtree
Re: Apache ws-xmlrpc
NULL POINTER EXCEPTION! I was trying to create a handler for the web service above. It should be the equivalent of (Java): public class Calculator { public int add(int i1, int i2) { return i1 + i2; } public int subtract(int i1, int i2) { return i1 - i2; } } So I basically wrote the following: (def Calculator (proxy [] [] (add [x y] (+ x y)) (subtract [x y] (- x y But I get the following error: java.lang.NullPointerException Anybody have a clue? On Dec 4, 9:09 pm, Rock rocco.ro...@gmail.com wrote: Looks pretty good. Thank you so much. This does however worry me a little from another point of view. There's always been a lot of talk about how easy it is to interface Clojure to Java. Yet, when it comes to a lot of situations (for instance, when dealing with annotations as in the JAX-WS SOAP web service facility), it doesn't seem at all straightforward. By the way, anybody know what the story is with Java annotations currently? I read somewhere that Clojure 1.2 (or possibly 1.3) can support them to a certain extent. On Dec 4, 8:11 pm, Shantanu Kumar kumar.shant...@gmail.com wrote: I guess you should look at XML-RPC2, which has a simpler usage:http://ws.apache.org/xmlrpc/xmlrpc2/server.html Regards, Shantanu On Dec 4, 10:26 pm, Rock rocco.ro...@gmail.com wrote: I'm desperately trying to implement an xml-rpc server with Clojure (trying to convince the company I work for here in Italy to give it a shot). I'm pretty well versed in Lisp, but I have yet to acquire sufficient experience with Clojure's Java interop capabilities. I've read the docs for implementing a server with ws-xmlrpc here: http://ws.apache.org/xmlrpc/server.html But I really can't figure out how to translate this to Clojure. Thanks to all for any help in this respect. -- You 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: ANN: Logos 0.1 - An Optimized miniKanren Logic Programming Library for Clojure
Very, very nice. Excellent work. I look forward to using it. I was looking at porting Kanren proper to Clojure. There appear to be some really good ideas in there that maybe could be added to Logos. Very well done. Jim On Dec 4, 2:41 pm, David Nolen dnolen.li...@gmail.com wrote: I announced it earlier this week on Twitter, but it's now come far along enough to be usable. You can write fun stuff like the following: (defn likes [x y] (cond-e ((== x 'john) (== y 'mary)) ((== x 'mary) (== y 'john (defn musician [x] (cond-e ((== x 'john)) ((== x 'bob (run* [q] (likes q 'mary) (musician q)) ;; [john] (run* [q] (musician q)) ;; [john bob] (run* [q] (exist [x y] (likes x y) (== [x y] q))) ;; [[john mary] [mary john]] My inspiration to start on this was Jim Duey's implementation. However I had two specific goals - * Focus on performance. While developing I compared performance against miniKanren under Racket - I made sure the Clojure implementation ran at least as fast, and in many cases it runs quite a bit faster * Implement growable sequences without resorting to Scheme's dotted pairs. This required me to develop a new protocol in which iteration might return a logic var instead of nil or a Seq. The implementation started with the one described William Byrd's dissertation. However a considerable number of changes were made- * substitutions are implemented as a protocol and a defrecord * substitutions internally use a PersistentHashMap as well as PersistentVector (for debugging) * supports unification of all the Clojure data structures supported by clojure.walk * goal and goal constructors are implements as deftypes (Mzero, Unit, Choice, Inc) and those implement IMPlus and IBind protocols. The code base is compact, some ~450 lines of Clojure. Future directions: * Friendlier interface for defining facts and running queries * There are many great ideas in William Byrd's thesis that need looking into. In particular I'm interested in tabling. * Investigating replacing the PersistentHashMap with a Skew Binary Random Access List or a Finger Tree. This would speed up the performance of the most expensive functions in the system, walk. In the Scheme implementations SBRALs can lead to 2.5X-100X in performance. * Modifying the core macros to optimize logic programs. * Parallel logic programming. Source and more info here,https://github.com/swannodette/logos. -- You 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: ANN: Logos 0.1 - An Optimized miniKanren Logic Programming Library for Clojure
Interesting. Is Byrd's dissertation available online? On Dec 4, 9:41 pm, David Nolen dnolen.li...@gmail.com wrote: I announced it earlier this week on Twitter, but it's now come far along enough to be usable. You can write fun stuff like the following: (defn likes [x y] (cond-e ((== x 'john) (== y 'mary)) ((== x 'mary) (== y 'john (defn musician [x] (cond-e ((== x 'john)) ((== x 'bob (run* [q] (likes q 'mary) (musician q)) ;; [john] (run* [q] (musician q)) ;; [john bob] (run* [q] (exist [x y] (likes x y) (== [x y] q))) ;; [[john mary] [mary john]] My inspiration to start on this was Jim Duey's implementation. However I had two specific goals - * Focus on performance. While developing I compared performance against miniKanren under Racket - I made sure the Clojure implementation ran at least as fast, and in many cases it runs quite a bit faster * Implement growable sequences without resorting to Scheme's dotted pairs. This required me to develop a new protocol in which iteration might return a logic var instead of nil or a Seq. The implementation started with the one described William Byrd's dissertation. However a considerable number of changes were made- * substitutions are implemented as a protocol and a defrecord * substitutions internally use a PersistentHashMap as well as PersistentVector (for debugging) * supports unification of all the Clojure data structures supported by clojure.walk * goal and goal constructors are implements as deftypes (Mzero, Unit, Choice, Inc) and those implement IMPlus and IBind protocols. The code base is compact, some ~450 lines of Clojure. Future directions: * Friendlier interface for defining facts and running queries * There are many great ideas in William Byrd's thesis that need looking into. In particular I'm interested in tabling. * Investigating replacing the PersistentHashMap with a Skew Binary Random Access List or a Finger Tree. This would speed up the performance of the most expensive functions in the system, walk. In the Scheme implementations SBRALs can lead to 2.5X-100X in performance. * Modifying the core macros to optimize logic programs. * Parallel logic programming. Source and more info here,https://github.com/swannodette/logos. -- You 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: ANN: Logos 0.1 - An Optimized miniKanren Logic Programming Library for Clojure
On Sat, Dec 4, 2010 at 6:39 PM, Jules julesjac...@gmail.com wrote: Interesting. Is Byrd's dissertation available online? Yes I added that and several other resource links to the bottom of the project's description on the GitHub repo. David On Dec 4, 9:41 pm, David Nolen dnolen.li...@gmail.com wrote: I announced it earlier this week on Twitter, but it's now come far along enough to be usable. You can write fun stuff like the following: (defn likes [x y] (cond-e ((== x 'john) (== y 'mary)) ((== x 'mary) (== y 'john (defn musician [x] (cond-e ((== x 'john)) ((== x 'bob (run* [q] (likes q 'mary) (musician q)) ;; [john] (run* [q] (musician q)) ;; [john bob] (run* [q] (exist [x y] (likes x y) (== [x y] q))) ;; [[john mary] [mary john]] My inspiration to start on this was Jim Duey's implementation. However I had two specific goals - * Focus on performance. While developing I compared performance against miniKanren under Racket - I made sure the Clojure implementation ran at least as fast, and in many cases it runs quite a bit faster * Implement growable sequences without resorting to Scheme's dotted pairs. This required me to develop a new protocol in which iteration might return a logic var instead of nil or a Seq. The implementation started with the one described William Byrd's dissertation. However a considerable number of changes were made- * substitutions are implemented as a protocol and a defrecord * substitutions internally use a PersistentHashMap as well as PersistentVector (for debugging) * supports unification of all the Clojure data structures supported by clojure.walk * goal and goal constructors are implements as deftypes (Mzero, Unit, Choice, Inc) and those implement IMPlus and IBind protocols. The code base is compact, some ~450 lines of Clojure. Future directions: * Friendlier interface for defining facts and running queries * There are many great ideas in William Byrd's thesis that need looking into. In particular I'm interested in tabling. * Investigating replacing the PersistentHashMap with a Skew Binary Random Access List or a Finger Tree. This would speed up the performance of the most expensive functions in the system, walk. In the Scheme implementations SBRALs can lead to 2.5X-100X in performance. * Modifying the core macros to optimize logic programs. * Parallel logic programming. Source and more info here,https://github.com/swannodette/logos. -- You 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: ANN: Logos 0.1 - An Optimized miniKanren Logic Programming Library for Clojure
On Sat, Dec 4, 2010 at 5:58 PM, jim jim.d...@gmail.com wrote: Very, very nice. Excellent work. I look forward to using it. I was looking at porting Kanren proper to Clojure. There appear to be some really good ideas in there that maybe could be added to Logos. Very well done. Jim I agree that there are many clever optimizations there that should be looked into. But my sense is that Kanren is an earlier project and miniKanren is the distillation of its lessons. 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: Temporary defs
On Sat, Dec 4, 2010 at 7:34 PM, Barry Dahlberg barry.dahlb...@gmail.com wrote: Hi Clojurians, I have a macro which creates a function for me and I would like to add some unit tests using clojure.test. How can I create a temporary scope so that any functions defined during the test are undefined afterwards? Here is a trivial example to illustrate: (deftest my-def-macro-test (my-def-macro foo bar) (if (= (foo) bar))) Ordinarily, if you want to define temporary functions you can just (let [x (fn [args] fnbody)] (do stuff with x)) (x undefined again here) However, if your macro outputs a defn that won't work. You may want to modify the macro to output just a (fn ...) form, and use (def x (the-macro args body)) to get global functions and (let [x (the-macro args body)] (do stuff with x)) to get local ones. -- You 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: Apache ws-xmlrpc
Yeah, thanks. I figured that one out experimenting. THE GREAT NEWS IS: I finally got Apache ws-xmlrpc working perfectly with Clojure. It wasn't so hard after all. Really cool. Works like a charm. I will be posting tomorrow the entire procedure. Too tired right now :) On Dec 5, 1:37 am, Mark Rathwell mark.rathw...@gmail.com wrote: Not sure what you are trying to do. If you have an existing java class or interface that you are trying to extend, you need to specify it. If you are trying to create a new class, you probably want to look at defrecord. If extending an existing java interface or class (that is on your classpath and import'd): (def calc (proxy [Calculator] [] (add [x y] (+ x y)) (subtract [x y] (- x y On Sat, Dec 4, 2010 at 5:49 PM, Rock rocco.ro...@gmail.com wrote: NULL POINTER EXCEPTION! I was trying to create a handler for the web service above. It should be the equivalent of (Java): public class Calculator { public int add(int i1, int i2) { return i1 + i2; } public int subtract(int i1, int i2) { return i1 - i2; } } So I basically wrote the following: (def Calculator (proxy [] [] (add [x y] (+ x y)) (subtract [x y] (- x y But I get the following error: java.lang.NullPointerException Anybody have a clue? On Dec 4, 9:09 pm, Rock rocco.ro...@gmail.com wrote: Looks pretty good. Thank you so much. This does however worry me a little from another point of view. There's always been a lot of talk about how easy it is to interface Clojure to Java. Yet, when it comes to a lot of situations (for instance, when dealing with annotations as in the JAX-WS SOAP web service facility), it doesn't seem at all straightforward. By the way, anybody know what the story is with Java annotations currently? I read somewhere that Clojure 1.2 (or possibly 1.3) can support them to a certain extent. On Dec 4, 8:11 pm, Shantanu Kumar kumar.shant...@gmail.com wrote: I guess you should look at XML-RPC2, which has a simpler usage: http://ws.apache.org/xmlrpc/xmlrpc2/server.html Regards, Shantanu On Dec 4, 10:26 pm, Rock rocco.ro...@gmail.com wrote: I'm desperately trying to implement an xml-rpc server with Clojure (trying to convince the company I work for here in Italy to give it a shot). I'm pretty well versed in Lisp, but I have yet to acquire sufficient experience with Clojure's Java interop capabilities. I've read the docs for implementing a server with ws-xmlrpc here: http://ws.apache.org/xmlrpc/server.html But I really can't figure out how to translate this to Clojure. Thanks to all for any help in this respect. -- You 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: Tailing a file in Clojure
Does any familiar with this NIO Watch service know if it handles NFS issues? We have an in-house log monitoring tool at work (doesn't everyone) which is written in Java, but the two big issues are message framing (knowing when a multi-line message has ended) and getting null bytes when tailing an NFS file. We have some fairly heavy code to handle these problems. I've thought about trying to write something similar in Clojure as a project, but haven't started to tackle it yet precisely because I didn't see any way to make it more efficient. -- You 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.contrib.seq vs. clojure.contrib.seq-utils
Hello everybody, Both of clojure.contrib.seq and clojure.contrib.seq-utils seem to give the same functionality.. any idea as to which one we r supposed to be using.. Sunil. -- You 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.contrib.seq vs. clojure.contrib.seq-utils
clojure.core.seq is preferred --- from clojure.core.seq_utils.clj ;;; seq_utils.clj -- Sequence utilities for Clojure ;; by Stuart Sierra, http://stuartsierra.com/ ;; last updated March 2, 2009 ;; Copyright (c) Stuart Sierra, 2008. All rights reserved. The use ;; and distribution terms for this software are covered by the Eclipse ;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) ;; which can be found in the file epl-v10.html at the root of this ;; distribution. By using this software in any fashion, you are ;; agreeing to be bound by the terms of this license. You must not ;; remove this notice, or any other, from this software. ;; Change Log ;; ;; DEPRECATED in 1.2. Some functions promoted to clojure.core and some ;; moved to c.c.seq --Robert McIntyre On Sun, Dec 5, 2010 at 12:04 AM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Hello everybody, Both of clojure.contrib.seq and clojure.contrib.seq-utils seem to give the same functionality.. any idea as to which one we r supposed to be using.. Sunil. -- You 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