Re: Correct mapping from Lisp to Clojure?

2010-01-19 Thread Laurent PETIT
Hello, Just one thought, since I also tried to convert some emacs lisp code to clojure recently ( paredit.el ). It seemed a good idea at first, something like : 1. I write a one-to-on conversion, using the same idioms that are used in CL in clojure 2. I write a bunch of non-regression tests 3.

how to require a library

2010-01-19 Thread Boštjan Jerko
Hello! I'm absolute beginner in the field of functional programming and have some experience with Java, but it was long time ago. Since I need to work with JVM and want to learn functional programming I've decided to use and learn Clojure. Now to my problem: I'm writing a small twitter client

Re: Correct mapping from Lisp to Clojure?

2010-01-19 Thread Simon Brooke
On 19 Jan, 06:12, Sean Devlin francoisdev...@gmail.com wrote: Did you watch Rich's video Clojure for Lispers?  That might help (The only one I can answer for sure is that Clojure's let is CL's let*) Ah! that's very handy, I too was wondering how to do a let*! It's certainly expressively

Re: Correct mapping from Lisp to Clojure?

2010-01-19 Thread Simon Brooke
On 19 Jan, 08:33, Laurent PETIT laurent.pe...@gmail.com wrote: Hello, Just one thought, since I also tried to convert some emacs lisp code to clojure recently ( paredit.el ). It seemed a good idea at first, something like : 1. I write a one-to-on conversion, using the same idioms that are

Some vars protected from binding?

2010-01-19 Thread Jacek Generowicz
(def ++ +) (defn foo-core [a b] (+ a b)) (defn foo-user [a b] (++ a b)) (binding [+ - ++ -] [(foo-core 1 1) (foo-user 1 1)]) Gives the result: [2 0] which suggests that some vars are immune to binding. Could someone please point me to the chapter and verse describing this?

JUnit XML output doesn't conform maven surefire-report plugin schema

2010-01-19 Thread maksym
XML output produced using (with-junit-output) has no attributes which are mandatory for schema that is used by surefire-report for HTML generation. failure has no attribute type. It can be easily added to clojure.test.junit.clj:116 (start-element tag false (assoc (if message {:message message}

stripping parenthesis

2010-01-19 Thread Scott
i am utilizing parenthesis to represent a tree structure within a genetic algorithm I am trying to write a function that can strip all parenthesis such that I can perform crossovers/mutations on the permutation. Ex. ( 1 2 3 4 (5 6 7 8) ((9 10 11 12)) (((13 14 15 16))) ) into ( 1 2 3 4 5 6 7 8

Re: Some vars protected from binding?

2010-01-19 Thread Meikel Brandmeyer
Hi, On Jan 19, 1:45 pm, Jacek Generowicz jacek.generow...@googlemail.com wrote: (def ++ +) (defn foo-core [a b] (+  a b)) (defn foo-user [a b] (++ a b)) (binding [+  -           ++ -]   [(foo-core 1 1) (foo-user 1 1)]) Gives the result:     [2 0] which suggests that some vars are

Re: stripping parenthesis

2010-01-19 Thread Laurent PETIT
Maybe you're in quest of http://richhickey.github.com/clojure-contrib/seq-utils-api.html#clojure.contrib.seq-utils/flatten ? HTH, -- Laurent 2010/1/19 Scott sbuck...@gmail.com: i am utilizing parenthesis to represent a tree structure within a genetic algorithm I am trying to write a

Re: ANN: dgraph 1.0, a dependency graph library for Clojure

2010-01-19 Thread Constantine Vetoshev
On Jan 18, 2:14 am, mac markus.gustavs...@gmail.com wrote: Updating stuff in the map became a little bit of a hassle so I made versions of assoc-in and update-in that work on dgraphs. Here they are in case anyone else is interested: (defn assoc-node   [dgraph m ks v]   (dgraph m (assoc-in

Re: stripping parenthesis

2010-01-19 Thread Scott
gotta love well thought out libraries Thanks Laurent one more question, what if one was to attempt the reverse, ie: ( 1 2 3 4 5 6 7 8 9 10 11 12 14 15 16 ) into ( 1 2 3 4 (5 6 7 8) ((9 10 11 12)) (((13 14 15 16))) ) thanks, sorry just getting started with clojure/lisp On Jan 19, 11:51 am,

Re: stripping parenthesis

2010-01-19 Thread Sean Devlin
It's unorthodox, but... (apply concat (map (fn [coll f] (f coll)) (partition 4 (range 1 17)) (iterate (partial comp list) identity))) Sean On Jan 19, 11:58 am, Scott sbuck...@gmail.com wrote: gotta love well thought out libraries Thanks Laurent one more question, what if one

Re: stripping parenthesis

2010-01-19 Thread Konrad Hinsen
On 19.01.2010, at 17:58, Scott wrote: one more question, what if one was to attempt the reverse, ie: ( 1 2 3 4 5 6 7 8 9 10 11 12 14 15 16 ) into ( 1 2 3 4 (5 6 7 8) ((9 10 11 12)) (((13 14 15 16))) ) There are certainly many ways to do it. Here is one: (defn insert [[f r]] (if (empty?

Re: how to require a library

2010-01-19 Thread Richard Newman
So I guess the twitter class is not found. As you can see I have some basic problems with classpath's and which library/class to import. Any recommendations how to tackle the issue? Make sure you explicitly include clojure-twitter.jar on your classpath. The containing directory is not

Re: stripping parenthesis

2010-01-19 Thread kyle smith
http://groups.google.com/group/clojure/browse_thread/thread/806ebb1cbe671969/82a25385a2a8a18d?lnk=gstq=unflatten#82a25385a2a8a18d -- You 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

Re: stripping parenthesis

2010-01-19 Thread Scott
thanks all! On Jan 19, 2:06 pm, kyle smith the1physic...@gmail.com wrote: http://groups.google.com/group/clojure/browse_thread/thread/806ebb1cb... -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: how to require a library

2010-01-19 Thread Boštjan Jerko
On 19.1.2010, at 19:53, Richard Newman wrote: Make sure you explicitly include clojure-twitter.jar on your classpath. The containing directory is not sufficient. How you do that depends on how you're invoking Clojure, and which OS you're using. Hi Richard, Thanks for the reply. I

Re: Correct mapping from Lisp to Clojure?

2010-01-19 Thread Conrad Taylor
On Jan 19, 12:33 am, Laurent PETIT laurent.pe...@gmail.com wrote: Hello, Just one thought, since I also tried to convert some emacs lisp code to clojure recently ( paredit.el ). It seemed a good idea at first, something like : 1. I write a one-to-on conversion, using the same idioms that

Re: how to require a library

2010-01-19 Thread Sean Devlin
If you add the jar as a Netbeans lib, Enclojure should do the work for you. Make sure to start a project REPL. On Jan 19, 2:37 pm, Boštjan Jerko boje...@gmail.com wrote: On 19.1.2010, at 19:53, Richard Newman wrote: Make sure you explicitly include clojure-twitter.jar on your classpath.

Re: Some vars protected from binding?

2010-01-19 Thread Phil Hagelberg
Jacek Generowicz jacek.generow...@googlemail.com writes: (def ++ +) (defn foo-core [a b] (+ a b)) (defn foo-user [a b] (++ a b)) (binding [+ - ++ -] [(foo-core 1 1) (foo-user 1 1)]) Gives the result: [2 0] which suggests that some vars are immune to binding. Could

deftype implementing methods with multiple argument lists

2010-01-19 Thread Konrad Hinsen
Protocols permit the declaration of functions with multiple argument lists: (defprotocol FooP (bar [x] [x y] )) It is straightforward to implement those using extend or extend-type: (deftype Foo [f] :as this) (extend-type ::Foo FooP (bar ([x] (:f x)) ([x y] [(:f x) y])))

Re: Correct mapping from Lisp to Clojure?

2010-01-19 Thread Conrad Taylor
On Jan 18, 10:33 pm, Richard Newman holyg...@gmail.com wrote: defvar defparamater def, pretty much. (Some of the niceties of CL semantics don't really   apply.) let* let. defconstant No equivalent. Use def and allow the JIT to do the is this constant?   work. mapcar map.

Re: deftype implementing methods with multiple argument lists

2010-01-19 Thread Stuart Sierra
You can include multiple definitions of the same method, with different arguments, in a deftype. (deftype Foo [f] (bar [x] ...) (bar [x y] ...)) Don't know if that's intended, but it works. -SS On Jan 19, 3:50 pm, Konrad Hinsen konrad.hin...@fastmail.net wrote: Protocols permit the

Re: Good refs on concurrency?

2010-01-19 Thread Gene Tani
On Jan 18, 5:48 pm, David Beckwith thirdreplica...@gmail.com wrote: And btw, thanks Erik, Gene, and Abhi for your suggestions!  I'll look at those. David :) A few others, while you're at it: - Chap 2 of Houser/Fogus' joy of Clojure MEAP, - the time, state, identity talks e.g.

Re: Why recur?

2010-01-19 Thread itsnotvalid
I kind of agree that loop acts as a point for recursion, however if the auo-TCO thing is possible, writing naturally recursing code would become possible. I think that recur could still exist independent like what other said. On Jan 18, 2:55 am, Richard Newman holyg...@gmail.com wrote: Other

Inspecting multimethods

2010-01-19 Thread Jacek Generowicz
Is there a way to (programatically) discover the set of methods belonging to a multimethod? Thank you. -- You 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

Re: Inspecting multimethods

2010-01-19 Thread Richard Newman
Is there a way to (programatically) discover the set of methods belonging to a multimethod? clojure.core/methods ([multifn]) Given a multimethod, returns a map of dispatch values - dispatch fns -- You received this message because you are subscribed to the Google Groups Clojure group. To

Empty defstruct

2010-01-19 Thread Andreas Wenger
Hi, I would like to know why defstruct without providing any keys (like (defstruct s)) is not allowed (exception: Must supply keys). Let me shortly describe why I think that this would be useful: Imagine you have a defstruct like in Rich's Ants demo: (defstruct cell :food :pher) ;may also have

Re: Empty defstruct

2010-01-19 Thread Kevin Downey
clojure structs are an optimized version of maps for a set of shared keys. if you don't have a defined set of shared keys you just have a map. so by all means, use a map On Tue, Jan 19, 2010 at 3:52 PM, Andreas Wenger andi.xeno...@googlemail.com wrote: Hi, I would like to know why defstruct

Re: Empty defstruct

2010-01-19 Thread Richard Newman
clojure structs are an optimized version of maps for a set of shared keys. if you don't have a defined set of shared keys you just have a map. so by all means, use a map I think Andreas's point is that there's a discontinuity: 0 required keys: map 1 required key: struct-map 2 required keys:

Re: Empty defstruct

2010-01-19 Thread Andreas Wenger
On 20 Jan., 00:56, Kevin Downey redc...@gmail.com wrote: clojure structs are an optimized version of maps for a set of shared keys. if you don't have a defined set of shared keys you just have a map. so by all means, use a map You're talking about the implementation in the background, but I am

Re: Empty defstruct

2010-01-19 Thread Andreas Wenger
I think Andreas's point is that there's a discontinuity: 0 required keys: map 1 required key:  struct-map 2 required keys: struct-map ... That's exactly the point! If I change only a little detail in my program, this can have impact on a huge part of my program. I can not see any reason why

Re: Empty defstruct

2010-01-19 Thread Kevin Downey
I fail to see how it requires changing a lot of code. it just means you need to change the place where you create your maps. which if you are also type tagging them is a lot of repetitive code, so it should already be factored out into a function, so then you just switch out one function. On Tue,

Re: Empty defstruct

2010-01-19 Thread Richard Newman
And documentary style is lost. Would be ok though, but not optimal. On the contrary, I think {:name Bill :age 23 :friends 20} is better than (struct-map person Bill 23 20) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group,

Re: Empty defstruct

2010-01-19 Thread Andreas Wenger
I fail to see how it requires changing a lot of code. it just means you need to change the place where you create your maps. which if you are also type tagging them is a lot of repetitive code, so it should already be factored out into a function, so then you just switch out one function.

Re: Empty defstruct

2010-01-19 Thread Andreas Wenger
And documentary style is lost. Would be ok though, but not optimal. On the contrary, I think    {:name Bill :age 23 :friends 20} is better than    (struct-map person Bill 23 20) Please review the definition of struct-map... Actually we seem to have the same opinion! Even better readable

Re: Empty defstruct

2010-01-19 Thread Kevin Downey
how is that not an argument? I'm pretty sure I just used it as one. keep in mind defstruct is largely to be superseded by deftype. http://clojure.org/contributing On Tue, Jan 19, 2010 at 4:10 PM, Andreas Wenger andi.xeno...@googlemail.com wrote: I fail to see how it requires changing a lot of

Re: Empty defstruct

2010-01-19 Thread Andreas Wenger
how is that not an argument? I'm pretty sure I just used it as one. What I wanted to say is that you are completely right, if you say that it is easy to create a workaround. But although doing this is easy, this does not mean that we should not fix this inconsistency (or do you see none?)

compojure/defservlet

2010-01-19 Thread Jeff Schwab
Hi: The compojure wikibook claims that compojure provides a defservlet function, along with other syntactic conveniences that I seem to be missing. Grepping the git log didn't turn up anything relevant, so I'm wondering: Is compojure supposed to provide defservlet, or should I fix the

Re: Empty defstruct

2010-01-19 Thread Kevin Downey
I think your use of workaround is pejorative. And can it even be called a work around if it is a best practice even when there is nothing to work around? On Tue, Jan 19, 2010 at 4:28 PM, Andreas Wenger andi.xeno...@googlemail.com wrote: how is that not an argument? I'm pretty sure I just used it

Using Runtime.exec to copy a file to a secure server.

2010-01-19 Thread CuppoJava
I've run into the need to copy the same file to 500 different nodes on a computing cluster, so I thought I'd save myself some time by writing a loop in Clojure to do that. But the server requires a password to be entered, and I'm not sure how to automatically supply that password. Here's the

Re: Empty defstruct

2010-01-19 Thread Timothy Pratley
2010/1/20 Andreas Wenger andi.xeno...@googlemail.com: (struct-map person :name Bill) Hi Andreas, Just another option to consider: {:type :person, :name Bill, :age 20} I'll steer clear of discussing the original question :) Regards, Tim. -- You received this message because you are

Re: Using Runtime.exec to copy a file to a secure server.

2010-01-19 Thread Timothy Pratley
2010/1/20 CuppoJava patrickli_2...@hotmail.com: (.. Runtime getRuntime (exec scp myfile.txt u...@server:)) (Thread/sleep 1000) (.. Runtime getRuntime (exec mypassword)) This creates two separate unrelated processes. You could instead get the stream of the original process and send it the info.

Re: Using Runtime.exec to copy a file to a secure server.

2010-01-19 Thread Richard Newman
You should probably use SSH keys instead of passwords. If you can't for some reason... Two interesting avenues: use shell-out, or use Ant. http://ant.apache.org/manual/OptionalTasks/scp.html (use 'clojure.contrib.shell-out) ;; Returns a map with useful keys like :exit. (sh :return-map true

Re: compojure/defservlet

2010-01-19 Thread Rob Lachlan
I can't find it either. The closest thing seems to be the servlet macro: (definline servlet Create a servlet from a sequence of routes. Automatically updates if the routes binding is redefined. [routes] `(proxy [HttpServlet] [] (~'service [request# response#] (request-handler

Re: Using Runtime.exec to copy a file to a secure server.

2010-01-19 Thread CuppoJava
Thanks for your replies. I'll checkout shell-out to see what it's doing differently than what I'm doing. That will help me figure out what I'm missing. -Patrick -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: Good refs on concurrency?

2010-01-19 Thread ajay gopalakrishnan
I think the strongest argument I ever found and which indicates the complexity involved with Concurrent programming are the following 2 articles: 1. The too much milk problemhttp://docs.google.com/leaf?id=0B1V4iBbCJCL0OTJkY2U5MDUtMGEzNS00NGExLThkZjItYjE3MmQ4NWJmNGJmhl=en This is taken from